b311480e |
1 | // Created on: 1992-01-20 |
2 | // Created by: Remi GILET |
3 | // Copyright (c) 1992-1999 Matra Datavision |
4 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
5 | // |
6 | // The content of this file is subject to the Open CASCADE Technology Public |
7 | // License Version 6.5 (the "License"). You may not use the content of this file |
8 | // except in compliance with the License. Please obtain a copy of the License |
9 | // at http://www.opencascade.org and read it completely before using this file. |
10 | // |
11 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
12 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
13 | // |
14 | // The Original Code and all software distributed under the License is |
15 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
16 | // Initial Developer hereby disclaims all such warranties, including without |
17 | // limitation, any warranties of merchantability, fitness for a particular |
18 | // purpose or non-infringement. Please see the License for the specific terms |
19 | // and conditions governing the rights and limitations under the License. |
20 | |
7fd59977 |
21 | |
22 | #include <gp_Vec2d.hxx> |
23 | #include <gp_Pnt2d.hxx> |
24 | #include <gp_Vec.hxx> |
25 | #include <gp_Pnt.hxx> |
26 | |
27 | //========================================================================= |
28 | // soit P1 le point sur la courbe TheCurve d abscisse u. + |
29 | // soit C le point ThePoint. + |
30 | // Nous cherchons donc les zeros de la fonction suivante: + |
31 | // + |
32 | // --> --> + |
33 | // CP1 /\ T + |
34 | // --------------- = F(u) + |
35 | // ||CP1|| * ||T|| + |
36 | // + |
37 | // La derivee de cette fonction est : + |
38 | // CP1 /\ N (T.N)*((CP1/\T).((CP1/\T)) + |
39 | // f(u) = -------- - -------------------------------- + |
40 | // N.N N*N*N*CP1*CP1*CP1 + |
41 | //========================================================================= |
42 | |
43 | GccIter_FunctionTanCuPnt:: |
44 | GccIter_FunctionTanCuPnt(const TheCurve& C , |
45 | const gp_Pnt2d& Point ) { |
46 | TheCurv = C; |
47 | ThePoint = Point; |
48 | } |
49 | |
50 | |
51 | Standard_Boolean GccIter_FunctionTanCuPnt:: |
52 | Value (const Standard_Real X , |
53 | Standard_Real& Fval ) { |
54 | gp_Pnt2d Point; |
55 | gp_Vec2d Vect; |
56 | TheCurveTool::D1(TheCurv,X,Point,Vect); |
57 | Standard_Real NormeD1 = Vect.Magnitude(); |
58 | gp_Vec2d TheDirection(ThePoint,Point); |
59 | Standard_Real NormeDir = TheDirection.Magnitude(); |
60 | Fval = TheDirection.Crossed(Vect)/(NormeD1*NormeDir); |
61 | return Standard_True; |
62 | } |
63 | |
64 | Standard_Boolean GccIter_FunctionTanCuPnt:: |
65 | Derivative (const Standard_Real X , |
66 | Standard_Real& Deriv ) { |
67 | gp_Pnt2d Point; |
68 | gp_Vec2d Vec1; |
69 | gp_Vec2d Vec2; |
70 | TheCurveTool::D2(TheCurv,X,Point,Vec1,Vec2); |
71 | gp_Vec2d TheDirection(ThePoint.XY(),gp_XY(Point.XY())); |
72 | Standard_Real NormeD1 = Vec1.Magnitude(); |
73 | Standard_Real NormeDir = TheDirection.Magnitude(); |
74 | Deriv = TheDirection.Crossed(Vec2)/(NormeD1*NormeDir)- |
75 | (TheDirection.Crossed(Vec1)/(NormeD1*NormeDir))* |
76 | (Vec1.Dot(Vec2)/(NormeD1*NormeD1)+ |
77 | Vec1.Dot(TheDirection)/(NormeDir*NormeDir)); |
78 | return Standard_True; |
79 | } |
80 | |
81 | Standard_Boolean GccIter_FunctionTanCuPnt:: |
82 | Values (const Standard_Real X , |
83 | Standard_Real& Fval , |
84 | Standard_Real& Deriv ) { |
85 | gp_Pnt2d Point; |
86 | gp_Vec2d Vec1; |
87 | gp_Vec2d Vec2; |
88 | TheCurveTool::D2(TheCurv,X,Point,Vec1,Vec2); |
89 | gp_Vec2d TheDirection(ThePoint.XY(),gp_XY(Point.XY())); |
90 | Standard_Real NormeD1 = Vec1.Magnitude(); |
91 | Standard_Real NormeDir = TheDirection.Magnitude(); |
92 | Fval = TheDirection.Crossed(Vec1)/(NormeD1*NormeDir); |
93 | Deriv = TheDirection.Crossed(Vec2)/(NormeD1*NormeDir)- |
94 | (TheDirection.Crossed(Vec1)/(NormeD1*NormeDir))* |
95 | (Vec1.Dot(Vec2)/(NormeD1*NormeD1)+ |
96 | Vec1.Dot(TheDirection)/(NormeDir*NormeDir)); |
97 | |
98 | // cout << "U = "<< X << " F ="<< Fval <<" DF ="<< Deriv<<endl; |
99 | |
100 | return Standard_True; |
101 | } |