# GeomConvert_FuncCylinderLSDist Class Reference

Function for search of cylinder canonic parameters: coordinates of center local coordinate system, direction of axis and radius from set of points by least square method. More...

`#include <GeomConvert_FuncCylinderLSDist.hxx>`

Inheritance diagram for GeomConvert_FuncCylinderLSDist:
[legend]

## Public Member Functions

GeomConvert_FuncCylinderLSDist ()
Constructor. More...

GeomConvert_FuncCylinderLSDist (const Handle< TColgp_HArray1OfXYZ > &thePoints, const gp_Dir &theDir)

void SetPoints (const Handle< TColgp_HArray1OfXYZ > &thePoints)

void SetDir (const gp_Dir &theDir)

Standard_Integer NbVariables () const override
Number of variables. More...

Standard_Boolean Value (const math_Vector &X, Standard_Real &F) override
Value. More...

Standard_Boolean Gradient (const math_Vector &X, math_Vector &G) override

Standard_Boolean Values (const math_Vector &X, Standard_Real &F, math_Vector &G) override

Public Member Functions inherited from math_MultipleVarFunction
virtual Standard_Integer GetStateNumber ()
return the state of the function corresponding to the latestt call of any methods associated to the function. This function is called by each of the algorithms described later which define the function Integer Algorithm::StateNumber(). The algorithm has the responsibility to call this function when it has found a solution (i.e. a root or a minimum) and has to maintain the association between the solution found and this StateNumber. Byu default, this method returns 0 (which means for the algorithm: no state has been saved). It is the responsibility of the programmer to decide if he needs to save the current state of the function and to return an Integer that allows retrieval of the state. More...

virtual ~math_MultipleVarFunction ()

## Detailed Description

Function for search of cylinder canonic parameters: coordinates of center local coordinate system, direction of axis and radius from set of points by least square method.

The class inherits math_MultipleVarFunctionWithGradient and thus is intended for use in math_BFGS algorithm.

Parametrisation: Cylinder is defined by its axis and radius. Axis is defined by 3 cartesian coordinats it location x0, y0, z0 and direction, which is constant and set by user: dir.x, dir.y, dir.z The criteria is: F(x0, y0, z0, theta, phi, R) = Sum[|(P(i) - Loc)^dir|^2 - R^2]^2 => min P(i) is i-th sample point, Loc, dir - axis location and direction, R - radius

The square vector product |(P(i) - Loc)^dir|^2 is:

[(y - y0)*dir.z - (z - z0)*dir.y]^2 + [(z - z0)*dir.x - (x - x0)*dir.z]^2 + [(x - x0)*dir.y - (y - y0)*dir.x]^2

First derivative of square vector product are: Dx0 = 2*[(z - z0)*dir.x - (x - x0)*dir.z]*dir.z -2*[(x - x0)*dir.y - (y - y0)*dir.x]*dir.y Dy0 = -2*[(y - y0)*dir.z - (z - z0)*dir.y]*dir.z +2*[(x - x0)*dir.y - (y - y0)*dir.x]*dir.x Dz0 = 2*[(y - y0)*dir.z - (z - z0)*dir.y]*dir.y -2*[(z - z0)*dir.x - (x - x0)*dir.z]*dir.x

dF/dx0 : G1(...) = 2*Sum{[...]*Dx0} dF/dy0 : G2(...) = 2*Sum{[...]*Dy0} dF/dz0 : G3(...) = 2*Sum{[...]*Dz0} dF/dR : G4(...) = -4*R*Sum[...] [...] = [|(P(i) - Loc)^dir|^2 - R^2]

## ◆ GeomConvert_FuncCylinderLSDist() [1/2]

 GeomConvert_FuncCylinderLSDist::GeomConvert_FuncCylinderLSDist ( )
inline

Constructor.

## ◆ GeomConvert_FuncCylinderLSDist() [2/2]

 GeomConvert_FuncCylinderLSDist::GeomConvert_FuncCylinderLSDist ( const Handle< TColgp_HArray1OfXYZ > & thePoints, const gp_Dir & theDir )

## Member Function Documentation

 Standard_Boolean GeomConvert_FuncCylinderLSDist::Gradient ( const math_Vector & X, math_Vector & G )
overridevirtual

## ◆ NbVariables()

 Standard_Integer GeomConvert_FuncCylinderLSDist::NbVariables ( ) const
overridevirtual

Number of variables.

## ◆ SetDir()

 void GeomConvert_FuncCylinderLSDist::SetDir ( const gp_Dir & theDir )
inline

## ◆ SetPoints()

 void GeomConvert_FuncCylinderLSDist::SetPoints ( const Handle< TColgp_HArray1OfXYZ > & thePoints )
inline

## ◆ Value()

 Standard_Boolean GeomConvert_FuncCylinderLSDist::Value ( const math_Vector & X, Standard_Real & F )
overridevirtual

## ◆ Values()

 Standard_Boolean GeomConvert_FuncCylinderLSDist::Values ( const math_Vector & X, Standard_Real & F, math_Vector & G )
overridevirtual