1 // Created on: 1992-01-20
2 // Created by: Remi GILET
3 // Copyright (c) 1992-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
18 #include <Geom2dAdaptor_Curve.hxx>
19 #include <Geom2dGcc_CurveTool.hxx>
20 #include <Geom2dGcc_FunctionTanCuPnt.hxx>
22 #include <gp_Pnt2d.hxx>
24 #include <gp_Vec2d.hxx>
26 //=========================================================================
27 // soit P1 le point sur la courbe Geom2dAdaptor_Curve d abscisse u. +
28 // soit C le point ThePoint. +
29 // Nous cherchons donc les zeros de la fonction suivante: +
33 // --------------- = F(u) +
36 // La derivee de cette fonction est : +
37 // CP1 /\ N (T.N)*((CP1/\T).((CP1/\T)) +
38 // f(u) = -------- - -------------------------------- +
39 // N.N N*N*N*CP1*CP1*CP1 +
40 //=========================================================================
41 Geom2dGcc_FunctionTanCuPnt::
42 Geom2dGcc_FunctionTanCuPnt(const Geom2dAdaptor_Curve& C ,
43 const gp_Pnt2d& Point ) {
49 Standard_Boolean Geom2dGcc_FunctionTanCuPnt::
50 Value (const Standard_Real X ,
51 Standard_Real& Fval ) {
54 Geom2dGcc_CurveTool::D1(TheCurv,X,Point,Vect);
55 Standard_Real NormeD1 = Vect.Magnitude();
56 gp_Vec2d TheDirection(ThePoint,Point);
57 Standard_Real NormeDir = TheDirection.Magnitude();
58 Fval = TheDirection.Crossed(Vect)/(NormeD1*NormeDir);
62 Standard_Boolean Geom2dGcc_FunctionTanCuPnt::
63 Derivative (const Standard_Real X ,
64 Standard_Real& Deriv ) {
68 Geom2dGcc_CurveTool::D2(TheCurv,X,Point,Vec1,Vec2);
69 gp_Vec2d TheDirection(ThePoint.XY(),gp_XY(Point.XY()));
70 Standard_Real NormeD1 = Vec1.Magnitude();
71 Standard_Real NormeDir = TheDirection.Magnitude();
72 Deriv = TheDirection.Crossed(Vec2)/(NormeD1*NormeDir)-
73 (TheDirection.Crossed(Vec1)/(NormeD1*NormeDir))*
74 (Vec1.Dot(Vec2)/(NormeD1*NormeD1)+
75 Vec1.Dot(TheDirection)/(NormeDir*NormeDir));
79 Standard_Boolean Geom2dGcc_FunctionTanCuPnt::
80 Values (const Standard_Real X ,
82 Standard_Real& Deriv ) {
86 Geom2dGcc_CurveTool::D2(TheCurv,X,Point,Vec1,Vec2);
87 gp_Vec2d TheDirection(ThePoint.XY(),gp_XY(Point.XY()));
88 Standard_Real NormeD1 = Vec1.Magnitude();
89 Standard_Real NormeDir = TheDirection.Magnitude();
90 Fval = TheDirection.Crossed(Vec1)/(NormeD1*NormeDir);
91 Deriv = TheDirection.Crossed(Vec2)/(NormeD1*NormeDir)-
92 (TheDirection.Crossed(Vec1)/(NormeD1*NormeDir))*
93 (Vec1.Dot(Vec2)/(NormeD1*NormeD1)+
94 Vec1.Dot(TheDirection)/(NormeDir*NormeDir));
96 // std::cout << "U = "<< X << " F ="<< Fval <<" DF ="<< Deriv<<std::endl;