54e37688 |
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 | |
54e37688 |
17 | |
54e37688 |
18 | #include <ElCLib.hxx> |
42cf5bc1 |
19 | #include <Geom2dAdaptor_Curve.hxx> |
54e37688 |
20 | #include <Geom2dGcc_CurveTool.hxx> |
42cf5bc1 |
21 | #include <Geom2dGcc_FunctionTanCuCu.hxx> |
22 | #include <gp_Circ2d.hxx> |
23 | #include <gp_Pnt2d.hxx> |
24 | #include <gp_Vec2d.hxx> |
25 | #include <math_Matrix.hxx> |
26 | #include <Standard_ConstructionError.hxx> |
54e37688 |
27 | |
28 | void Geom2dGcc_FunctionTanCuCu:: |
29 | InitDerivative(const math_Vector& X, |
30 | gp_Pnt2d& Point1, |
31 | gp_Pnt2d& Point2, |
32 | gp_Vec2d& Tan1 , |
33 | gp_Vec2d& Tan2 , |
34 | gp_Vec2d& D21 , |
35 | gp_Vec2d& D22 ) |
36 | { |
37 | switch (TheType) |
38 | { |
39 | case Geom2dGcc_CuCu: |
40 | { |
41 | Geom2dGcc_CurveTool::D2(TheCurve1,X(1),Point1,Tan1,D21); |
42 | Geom2dGcc_CurveTool::D2(TheCurve2,X(2),Point2,Tan2,D22); |
43 | } |
44 | break; |
45 | case Geom2dGcc_CiCu: |
46 | { |
47 | ElCLib::D2(X(1),TheCirc1,Point1,Tan1,D21); |
48 | Geom2dGcc_CurveTool::D2(TheCurve2,X(2),Point2,Tan2,D22); |
49 | } |
50 | break; |
51 | default: |
52 | { |
53 | } |
54 | } |
55 | } |
56 | |
57 | Geom2dGcc_FunctionTanCuCu:: |
58 | Geom2dGcc_FunctionTanCuCu(const Geom2dAdaptor_Curve& C1 , |
59 | const Geom2dAdaptor_Curve& C2 ) { |
60 | TheCurve1 = C1; |
61 | TheCurve2 = C2; |
62 | TheType = Geom2dGcc_CuCu; |
63 | } |
64 | |
65 | Geom2dGcc_FunctionTanCuCu:: |
66 | Geom2dGcc_FunctionTanCuCu(const gp_Circ2d& C1 , |
67 | const Geom2dAdaptor_Curve& C2 ) { |
68 | TheCirc1 = C1; |
69 | TheCurve2 = C2; |
70 | TheType = Geom2dGcc_CiCu; |
71 | } |
72 | |
73 | |
74 | //========================================================================= |
75 | // soit P1 le point sur la courbe TheCurve1 d abscisse u1. + |
76 | // soit P2 le point sur la courbe TheCurve2 d abscisse u2. + |
77 | // soit T1 la tangente a la courbe TheCurve1 en P1. + |
78 | // soit T2 la tangente a la courbe TheCurve2 en P2. + |
79 | // Nous voulons P1 et P2 tels que : + |
80 | // ---> --> + |
81 | // * P1P2 /\ T1 = 0 + |
82 | // + |
83 | // --> --> + |
84 | // * T1 /\ T2 = 0 + |
85 | // + |
86 | // Nous cherchons donc les zeros des fonctions suivantes: + |
87 | // ---> --> + |
88 | // * P1P2 /\ T1 + |
89 | // --------------- = F1(u) + |
90 | // ---> --> + |
91 | // ||P1P2||*||T1|| + |
92 | // + |
93 | // --> --> + |
94 | // * T1 /\ T2 + |
95 | // --------------- = F2(u) + |
96 | // --> --> + |
97 | // ||T2||*||T1|| + |
98 | // + |
99 | // Les derivees de ces fonctions sont : + |
100 | // 2 2 + |
101 | // dF1 P1P2/\N1 (P1P2/\T1)*[T1*(-T1).P1P2+P1P2*(T1.N1)] + |
102 | // ----- = --------------- - ----------------------------------------- + |
103 | // du1 3 3 + |
104 | // ||P1P2||*||T1|| ||P1P2|| * ||T1|| + |
105 | // + |
106 | // 2 + |
107 | // dF1 T2/\T1 (P1P2/\T1)*[T1*(T2.P1P2) + |
108 | // ----- = --------------- - ----------------------------------------- + |
109 | // du2 3 3 + |
110 | // ||P1P2||*||T1|| ||P1P2|| * ||T1|| + |
111 | // + |
112 | // 2 + |
113 | // dF2 N1/\T2 T1/\T2*(N1.T1)T2 + |
114 | // ----- = ---------------- - ----------------------------- + |
115 | // du1 3 3 + |
116 | // ||T1||*||T2|| ||T1|| * ||T2|| + |
117 | // + |
118 | // 2 + |
119 | // dF2 T1/\N2 T1/\T2*(N2.T2)T1 + |
120 | // ----- = ---------------- - ----------------------------- + |
121 | // du2 3 3 + |
122 | // ||T1||*||T2|| ||T1|| * ||T2|| + |
123 | // + |
124 | //========================================================================= |
125 | |
126 | Standard_Integer Geom2dGcc_FunctionTanCuCu:: |
127 | NbVariables() const { return 2; } |
128 | |
129 | Standard_Integer Geom2dGcc_FunctionTanCuCu:: |
130 | NbEquations() const { return 2; } |
131 | |
132 | Standard_Boolean Geom2dGcc_FunctionTanCuCu:: |
133 | Value (const math_Vector& X , |
134 | math_Vector& Fval ) { |
135 | gp_Pnt2d Point1; |
136 | gp_Pnt2d Point2; |
137 | gp_Vec2d Vect11; |
138 | gp_Vec2d Vect21; |
139 | gp_Vec2d Vect12; |
140 | gp_Vec2d Vect22; |
141 | InitDerivative(X,Point1,Point2,Vect11,Vect21,Vect12,Vect22); |
142 | Standard_Real NormeD11 = Vect11.Magnitude(); |
143 | Standard_Real NormeD21 = Vect21.Magnitude(); |
144 | gp_Vec2d TheDirection(Point1,Point2); |
145 | Standard_Real squaredir = TheDirection.Dot(TheDirection); |
146 | Fval(1) = TheDirection.Crossed(Vect11)/(NormeD11*squaredir); |
147 | Fval(2) = Vect11.Crossed(Vect21)/(NormeD11*NormeD21); |
148 | return Standard_True; |
149 | } |
150 | |
151 | Standard_Boolean Geom2dGcc_FunctionTanCuCu:: |
152 | Derivatives (const math_Vector& X , |
153 | math_Matrix& Deriv ) { |
154 | gp_Pnt2d Point1; |
155 | gp_Pnt2d Point2; |
156 | gp_Vec2d Vect11; |
157 | gp_Vec2d Vect21; |
158 | gp_Vec2d Vect12; |
159 | gp_Vec2d Vect22; |
160 | InitDerivative(X,Point1,Point2,Vect11,Vect21,Vect12,Vect22); |
161 | Standard_Real NormeD11 = Vect11.Magnitude(); |
162 | Standard_Real NormeD21 = Vect21.Magnitude(); |
0797d9d3 |
163 | #ifdef OCCT_DEBUG |
54e37688 |
164 | gp_Vec2d V2V1(Vect11.XY(),Vect21.XY()); |
165 | #else |
166 | Vect11.XY(); |
167 | Vect21.XY(); |
168 | #endif |
169 | gp_Vec2d TheDirection(Point1,Point2); |
170 | Standard_Real squaredir = TheDirection.Dot(TheDirection); |
171 | Deriv(1,1) = TheDirection.Crossed(Vect12)/(NormeD11*squaredir)+ |
172 | (TheDirection.Crossed(Vect11)*NormeD11*NormeD11*Vect11.Dot(TheDirection))/ |
173 | (NormeD11*NormeD11*NormeD11*squaredir*squaredir*squaredir); |
174 | Deriv(1,2) = Vect21.Crossed(Vect11)/(NormeD11*squaredir)- |
175 | (TheDirection.Crossed(Vect11)*NormeD11*NormeD11*Vect21.Dot(TheDirection))/ |
176 | (NormeD11*NormeD11*NormeD11*squaredir*squaredir*squaredir); |
177 | Deriv(2,1)=(Vect12.Crossed(Vect21))/(NormeD11*NormeD21)- |
178 | (Vect11.Crossed(Vect21))*(Vect12.Dot(Vect11))*NormeD21*NormeD21/ |
179 | (NormeD11*NormeD11*NormeD11*NormeD21*NormeD21*NormeD21); |
180 | Deriv(2,2)=(Vect11.Crossed(Vect22))/(NormeD11*NormeD21)- |
181 | (Vect11.Crossed(Vect21))*(Vect22.Dot(Vect21))*NormeD11*NormeD11/ |
182 | (NormeD11*NormeD11*NormeD11*NormeD21*NormeD21*NormeD21); |
183 | return Standard_True; |
184 | } |
185 | |
186 | Standard_Boolean Geom2dGcc_FunctionTanCuCu:: |
187 | Values (const math_Vector& X , |
188 | math_Vector& Fval , |
189 | math_Matrix& Deriv ) { |
190 | gp_Pnt2d Point1; |
191 | gp_Pnt2d Point2; |
192 | gp_Vec2d Vect11; |
193 | gp_Vec2d Vect21; |
194 | gp_Vec2d Vect12; |
195 | gp_Vec2d Vect22; |
196 | InitDerivative(X,Point1,Point2,Vect11,Vect21,Vect12,Vect22); |
197 | Standard_Real NormeD11 = Vect11.Magnitude(); |
198 | Standard_Real NormeD21 = Vect21.Magnitude(); |
0797d9d3 |
199 | #ifdef OCCT_DEBUG |
54e37688 |
200 | gp_Vec2d V2V1(Vect11.XY(),Vect21.XY()); |
201 | #else |
202 | Vect11.XY(); |
203 | Vect21.XY(); |
204 | #endif |
205 | gp_Vec2d TheDirection(Point1,Point2); |
206 | Standard_Real squaredir = TheDirection.Dot(TheDirection); |
207 | Fval(1) = TheDirection.Crossed(Vect11)/(NormeD11*squaredir); |
208 | Fval(2) = Vect11.Crossed(Vect21)/(NormeD11*NormeD21); |
209 | Deriv(1,1) = TheDirection.Crossed(Vect12)/(NormeD11*squaredir)+ |
210 | (TheDirection.Crossed(Vect11)*NormeD11*NormeD11*Vect11.Dot(TheDirection))/ |
211 | (NormeD11*NormeD11*NormeD11*squaredir*squaredir*squaredir); |
212 | Deriv(1,2) = Vect21.Crossed(Vect11)/(NormeD11*squaredir)- |
213 | (TheDirection.Crossed(Vect11)*NormeD11*NormeD11*Vect21.Dot(TheDirection))/ |
214 | (NormeD11*NormeD11*NormeD11*squaredir*squaredir*squaredir); |
215 | Deriv(2,1)=(Vect12.Crossed(Vect21))/(NormeD11*NormeD21)- |
216 | (Vect11.Crossed(Vect21))*(Vect12.Dot(Vect11))*NormeD21*NormeD21/ |
217 | (NormeD11*NormeD11*NormeD11*NormeD21*NormeD21*NormeD21); |
218 | Deriv(2,2)=(Vect11.Crossed(Vect22))/(NormeD11*NormeD21)- |
219 | (Vect11.Crossed(Vect21))*(Vect22.Dot(Vect21))*NormeD11*NormeD11/ |
220 | (NormeD11*NormeD11*NormeD11*NormeD21*NormeD21*NormeD21); |
221 | return Standard_True; |
222 | } |