|
|
|||
File indexing completed on 2026-09-23 09:17:30
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 <gp_XYZ.hxx> 0023 #include <NCollection_Array1.hxx> 0024 #include <NCollection_HArray1.hxx> 0025 #include <math_Vector.hxx> 0026 #include <gp_Dir.hxx> 0027 0028 //! Function for search of cylinder canonic parameters: coordinates of center local coordinate 0029 //! system, direction of axis and radius from set of points by least square method. 0030 //! 0031 //! The class inherits math_MultipleVarFunctionWithGradient and thus is intended 0032 //! for use in math_BFGS algorithm. 0033 //! 0034 //! Parametrisation: 0035 //! Cylinder is defined by its axis and radius. Axis is defined by 3 cartesian coordinates at 0036 //! location x0, y0, z0 and direction, which is constant and set by user: dir.x, dir.y, dir.z The 0037 //! criteria is: F(x0, y0, z0, theta, phi, R) = Sum[|(P(i) - Loc)^dir|^2 - R^2]^2 => min P(i) is 0038 //! i-th sample point, Loc, dir - axis location and direction, R - radius 0039 //! 0040 //! The square vector product |(P(i) - Loc)^dir|^2 is: 0041 //! 0042 //! [(y - y0)*dir.z - (z - z0)*dir.y]^2 + 0043 //! [(z - z0)*dir.x - (x - x0)*dir.z]^2 + 0044 //! [(x - x0)*dir.y - (y - y0)*dir.x]^2 0045 //! 0046 //! First derivative of square vector product are: 0047 //! Dx0 = 2*[(z - z0)*dir.x - (x - x0)*dir.z]*dir.z 0048 //! -2*[(x - x0)*dir.y - (y - y0)*dir.x]*dir.y 0049 //! Dy0 = -2*[(y - y0)*dir.z - (z - z0)*dir.y]*dir.z 0050 //! +2*[(x - x0)*dir.y - (y - y0)*dir.x]*dir.x 0051 //! Dz0 = 2*[(y - y0)*dir.z - (z - z0)*dir.y]*dir.y 0052 //! -2*[(z - z0)*dir.x - (x - x0)*dir.z]*dir.x 0053 //! 0054 //! dF/dx0 : G1(...) = 2*Sum{[...]*Dx0} 0055 //! dF/dy0 : G2(...) = 2*Sum{[...]*Dy0} 0056 //! dF/dz0 : G3(...) = 2*Sum{[...]*Dz0} 0057 //! dF/dR : G4(...) = -4*R*Sum[...] 0058 //! [...] = [|(P(i) - Loc)^dir|^2 - R^2] 0059 class GeomConvert_FuncCylinderLSDist : public math_MultipleVarFunctionWithGradient 0060 { 0061 public: 0062 DEFINE_STANDARD_ALLOC 0063 0064 //! Constructor. 0065 Standard_EXPORT GeomConvert_FuncCylinderLSDist() = default; 0066 0067 Standard_EXPORT GeomConvert_FuncCylinderLSDist( 0068 const occ::handle<NCollection_HArray1<gp_XYZ>>& thePoints, 0069 const gp_Dir& theDir); 0070 0071 void SetPoints(const occ::handle<NCollection_HArray1<gp_XYZ>>& thePoints) 0072 { 0073 myPoints = thePoints; 0074 } 0075 0076 void SetDir(const gp_Dir& theDir) { myDir = theDir; } 0077 0078 //! Number of variables. 0079 Standard_EXPORT int NbVariables() const override; 0080 0081 //! Value. 0082 Standard_EXPORT bool Value(const math_Vector& X, double& F) override; 0083 0084 //! Gradient. 0085 Standard_EXPORT bool Gradient(const math_Vector& X, math_Vector& G) override; 0086 0087 //! Value and gradient. 0088 Standard_EXPORT bool Values(const math_Vector& X, double& F, math_Vector& G) override; 0089 0090 private: 0091 occ::handle<NCollection_HArray1<gp_XYZ>> myPoints; 0092 gp_Dir myDir; 0093 }; 0094 #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 |
|