0031939: Coding - correction of spelling errors in comments [part 3]
[occt.git] / src / Geom2dGcc / Geom2dGcc_FunctionTanCuPnt.cxx
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
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17
18 #include <Geom2dAdaptor_Curve.hxx>
19 #include <Geom2dGcc_CurveTool.hxx>
20 #include <Geom2dGcc_FunctionTanCuPnt.hxx>
21 #include <gp_Pnt.hxx>
22 #include <gp_Pnt2d.hxx>
23 #include <gp_Vec.hxx>
24 #include <gp_Vec2d.hxx>
25
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:                +
30 //                                                                        +
31 //                 -->   -->                                              +
32 //                 CP1 /\ T                                               +
33 //             ---------------  =  F(u)                                   +
34 //             ||CP1|| * ||T||                                            +
35 //                                                                        +
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  ) {
44                              TheCurv = C;
45                              ThePoint = Point;
46 }
47
48
49 Standard_Boolean Geom2dGcc_FunctionTanCuPnt::
50 Value (const Standard_Real  X    ,
51        Standard_Real& Fval ) {
52          gp_Pnt2d Point;
53          gp_Vec2d Vect;
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);
59          return Standard_True;
60 }
61
62 Standard_Boolean Geom2dGcc_FunctionTanCuPnt::
63 Derivative (const Standard_Real  X     ,
64             Standard_Real& Deriv ) {
65               gp_Pnt2d Point;
66               gp_Vec2d Vec1;
67               gp_Vec2d Vec2;
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));
76               return Standard_True;
77 }
78
79 Standard_Boolean Geom2dGcc_FunctionTanCuPnt::
80 Values (const Standard_Real  X     ,
81         Standard_Real& Fval  ,
82         Standard_Real& Deriv ) {
83           gp_Pnt2d Point;
84           gp_Vec2d Vec1;
85           gp_Vec2d Vec2;
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));
95
96           //  std::cout  << "U = "<< X << " F ="<< Fval <<" DF ="<< Deriv<<std::endl;
97
98           return Standard_True;
99 }