|
|
|||
File indexing completed on 2026-06-25 08:29:34
0001 // Copyright (c) 1991-1999 Matra Datavision 0002 // Copyright (c) 1999-2022 OPEN CASCADE SAS 0003 // 0004 // This file is part of Open CASCADE Technology software library. 0005 // 0006 // This library is free software; you can redistribute it and/or modify it under 0007 // the terms of the GNU Lesser General Public License version 2.1 as published 0008 // by the Free Software Foundation, with special exception defined in the file 0009 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0010 // distribution for complete text of the license and disclaimer of any warranty. 0011 // 0012 // Alternatively, this file may be used under the terms of Open CASCADE 0013 // commercial license or contractual agreement. 0014 0015 #ifndef _GeomConvert_FuncCylinderLSDist_HeaderFile 0016 #define _GeomConvert_FuncCylinderLSDist_HeaderFile 0017 0018 #include <Standard.hxx> 0019 #include <Standard_DefineAlloc.hxx> 0020 0021 #include <math_MultipleVarFunctionWithGradient.hxx> 0022 #include <TColgp_HArray1OfXYZ.hxx> 0023 #include <math_Vector.hxx> 0024 #include <gp_Dir.hxx> 0025 0026 //! Function for search of cylinder canonic parameters: coordinates of center local coordinate 0027 //! system, direction of axis and radius from set of points by least square method. 0028 //! 0029 //! The class inherits math_MultipleVarFunctionWithGradient and thus is intended 0030 //! for use in math_BFGS algorithm. 0031 //! 0032 //! Parametrisation: 0033 //! Cylinder is defined by its axis and radius. Axis is defined by 3 cartesian coordinates at 0034 //! location x0, y0, z0 and direction, which is constant and set by user: dir.x, dir.y, dir.z The 0035 //! criteria is: F(x0, y0, z0, theta, phi, R) = Sum[|(P(i) - Loc)^dir|^2 - R^2]^2 => min P(i) is 0036 //! i-th sample point, Loc, dir - axis location and direction, R - radius 0037 //! 0038 //! The square vector product |(P(i) - Loc)^dir|^2 is: 0039 //! 0040 //! [(y - y0)*dir.z - (z - z0)*dir.y]^2 + 0041 //! [(z - z0)*dir.x - (x - x0)*dir.z]^2 + 0042 //! [(x - x0)*dir.y - (y - y0)*dir.x]^2 0043 //! 0044 //! First derivative of square vector product are: 0045 //! Dx0 = 2*[(z - z0)*dir.x - (x - x0)*dir.z]*dir.z 0046 //! -2*[(x - x0)*dir.y - (y - y0)*dir.x]*dir.y 0047 //! Dy0 = -2*[(y - y0)*dir.z - (z - z0)*dir.y]*dir.z 0048 //! +2*[(x - x0)*dir.y - (y - y0)*dir.x]*dir.x 0049 //! Dz0 = 2*[(y - y0)*dir.z - (z - z0)*dir.y]*dir.y 0050 //! -2*[(z - z0)*dir.x - (x - x0)*dir.z]*dir.x 0051 //! 0052 //! dF/dx0 : G1(...) = 2*Sum{[...]*Dx0} 0053 //! dF/dy0 : G2(...) = 2*Sum{[...]*Dy0} 0054 //! dF/dz0 : G3(...) = 2*Sum{[...]*Dz0} 0055 //! dF/dR : G4(...) = -4*R*Sum[...] 0056 //! [...] = [|(P(i) - Loc)^dir|^2 - R^2] 0057 class GeomConvert_FuncCylinderLSDist : public math_MultipleVarFunctionWithGradient 0058 { 0059 public: 0060 DEFINE_STANDARD_ALLOC 0061 0062 //! Constructor. 0063 Standard_EXPORT GeomConvert_FuncCylinderLSDist() {}; 0064 0065 Standard_EXPORT GeomConvert_FuncCylinderLSDist(const Handle(TColgp_HArray1OfXYZ)& thePoints, 0066 const gp_Dir& theDir); 0067 0068 void SetPoints(const Handle(TColgp_HArray1OfXYZ)& thePoints) { myPoints = thePoints; } 0069 0070 void SetDir(const gp_Dir& theDir) { myDir = theDir; } 0071 0072 //! Number of variables. 0073 Standard_EXPORT Standard_Integer NbVariables() const Standard_OVERRIDE; 0074 0075 //! Value. 0076 Standard_EXPORT Standard_Boolean Value(const math_Vector& X, Standard_Real& F) Standard_OVERRIDE; 0077 0078 //! Gradient. 0079 Standard_EXPORT Standard_Boolean Gradient(const math_Vector& X, math_Vector& G) Standard_OVERRIDE; 0080 0081 //! Value and gradient. 0082 Standard_EXPORT Standard_Boolean Values(const math_Vector& X, 0083 Standard_Real& F, 0084 math_Vector& G) Standard_OVERRIDE; 0085 0086 private: 0087 Handle(TColgp_HArray1OfXYZ) myPoints; 0088 gp_Dir myDir; 0089 }; 0090 #endif // _GeomConvert_FuncCylinderLSDist_HeaderFile
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|