7fd59977 |
1 | // File: GccIter_FunctionTanCuPnt.gxx |
2 | // Created: Mon Jan 20 16:35:40 1992 |
3 | // Author: Remi GILET |
4 | // <reg@phobox> |
5 | |
6 | #include <gp_Vec2d.hxx> |
7 | #include <gp_Pnt2d.hxx> |
8 | #include <gp_Vec.hxx> |
9 | #include <gp_Pnt.hxx> |
10 | |
11 | //========================================================================= |
12 | // soit P1 le point sur la courbe TheCurve d abscisse u. + |
13 | // soit C le point ThePoint. + |
14 | // Nous cherchons donc les zeros de la fonction suivante: + |
15 | // + |
16 | // --> --> + |
17 | // CP1 /\ T + |
18 | // --------------- = F(u) + |
19 | // ||CP1|| * ||T|| + |
20 | // + |
21 | // La derivee de cette fonction est : + |
22 | // CP1 /\ N (T.N)*((CP1/\T).((CP1/\T)) + |
23 | // f(u) = -------- - -------------------------------- + |
24 | // N.N N*N*N*CP1*CP1*CP1 + |
25 | //========================================================================= |
26 | |
27 | GccIter_FunctionTanCuPnt:: |
28 | GccIter_FunctionTanCuPnt(const TheCurve& C , |
29 | const gp_Pnt2d& Point ) { |
30 | TheCurv = C; |
31 | ThePoint = Point; |
32 | } |
33 | |
34 | |
35 | Standard_Boolean GccIter_FunctionTanCuPnt:: |
36 | Value (const Standard_Real X , |
37 | Standard_Real& Fval ) { |
38 | gp_Pnt2d Point; |
39 | gp_Vec2d Vect; |
40 | TheCurveTool::D1(TheCurv,X,Point,Vect); |
41 | Standard_Real NormeD1 = Vect.Magnitude(); |
42 | gp_Vec2d TheDirection(ThePoint,Point); |
43 | Standard_Real NormeDir = TheDirection.Magnitude(); |
44 | Fval = TheDirection.Crossed(Vect)/(NormeD1*NormeDir); |
45 | return Standard_True; |
46 | } |
47 | |
48 | Standard_Boolean GccIter_FunctionTanCuPnt:: |
49 | Derivative (const Standard_Real X , |
50 | Standard_Real& Deriv ) { |
51 | gp_Pnt2d Point; |
52 | gp_Vec2d Vec1; |
53 | gp_Vec2d Vec2; |
54 | TheCurveTool::D2(TheCurv,X,Point,Vec1,Vec2); |
55 | gp_Vec2d TheDirection(ThePoint.XY(),gp_XY(Point.XY())); |
56 | Standard_Real NormeD1 = Vec1.Magnitude(); |
57 | Standard_Real NormeDir = TheDirection.Magnitude(); |
58 | Deriv = TheDirection.Crossed(Vec2)/(NormeD1*NormeDir)- |
59 | (TheDirection.Crossed(Vec1)/(NormeD1*NormeDir))* |
60 | (Vec1.Dot(Vec2)/(NormeD1*NormeD1)+ |
61 | Vec1.Dot(TheDirection)/(NormeDir*NormeDir)); |
62 | return Standard_True; |
63 | } |
64 | |
65 | Standard_Boolean GccIter_FunctionTanCuPnt:: |
66 | Values (const Standard_Real X , |
67 | Standard_Real& Fval , |
68 | Standard_Real& Deriv ) { |
69 | gp_Pnt2d Point; |
70 | gp_Vec2d Vec1; |
71 | gp_Vec2d Vec2; |
72 | TheCurveTool::D2(TheCurv,X,Point,Vec1,Vec2); |
73 | gp_Vec2d TheDirection(ThePoint.XY(),gp_XY(Point.XY())); |
74 | Standard_Real NormeD1 = Vec1.Magnitude(); |
75 | Standard_Real NormeDir = TheDirection.Magnitude(); |
76 | Fval = TheDirection.Crossed(Vec1)/(NormeD1*NormeDir); |
77 | Deriv = TheDirection.Crossed(Vec2)/(NormeD1*NormeDir)- |
78 | (TheDirection.Crossed(Vec1)/(NormeD1*NormeDir))* |
79 | (Vec1.Dot(Vec2)/(NormeD1*NormeD1)+ |
80 | Vec1.Dot(TheDirection)/(NormeDir*NormeDir)); |
81 | |
82 | // cout << "U = "<< X << " F ="<< Fval <<" DF ="<< Deriv<<endl; |
83 | |
84 | return Standard_True; |
85 | } |