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