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
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
19 #include <Geom2dAdaptor_Curve.hxx>
20 #include <Geom2dGcc_CurveTool.hxx>
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>
28 void Geom2dGcc_FunctionTanCuCu::
29 InitDerivative(const math_Vector& X,
41 Geom2dGcc_CurveTool::D2(TheCurve1,X(1),Point1,Tan1,D21);
42 Geom2dGcc_CurveTool::D2(TheCurve2,X(2),Point2,Tan2,D22);
47 ElCLib::D2(X(1),TheCirc1,Point1,Tan1,D21);
48 Geom2dGcc_CurveTool::D2(TheCurve2,X(2),Point2,Tan2,D22);
57 Geom2dGcc_FunctionTanCuCu::
58 Geom2dGcc_FunctionTanCuCu(const Geom2dAdaptor_Curve& C1 ,
59 const Geom2dAdaptor_Curve& C2 ) {
62 TheType = Geom2dGcc_CuCu;
65 Geom2dGcc_FunctionTanCuCu::
66 Geom2dGcc_FunctionTanCuCu(const gp_Circ2d& C1 ,
67 const Geom2dAdaptor_Curve& C2 ) {
70 TheType = Geom2dGcc_CiCu;
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 : +
86 // Nous cherchons donc les zeros des fonctions suivantes: +
89 // --------------- = F1(u) +
95 // --------------- = F2(u) +
99 // Les derivees de ces fonctions sont : +
101 // dF1 P1P2/\N1 (P1P2/\T1)*[T1*(-T1).P1P2+P1P2*(T1.N1)] +
102 // ----- = --------------- - ----------------------------------------- +
104 // ||P1P2||*||T1|| ||P1P2|| * ||T1|| +
107 // dF1 T2/\T1 (P1P2/\T1)*[T1*(T2.P1P2) +
108 // ----- = --------------- - ----------------------------------------- +
110 // ||P1P2||*||T1|| ||P1P2|| * ||T1|| +
113 // dF2 N1/\T2 T1/\T2*(N1.T1)T2 +
114 // ----- = ---------------- - ----------------------------- +
116 // ||T1||*||T2|| ||T1|| * ||T2|| +
119 // dF2 T1/\N2 T1/\T2*(N2.T2)T1 +
120 // ----- = ---------------- - ----------------------------- +
122 // ||T1||*||T2|| ||T1|| * ||T2|| +
124 //=========================================================================
126 Standard_Integer Geom2dGcc_FunctionTanCuCu::
127 NbVariables() const { return 2; }
129 Standard_Integer Geom2dGcc_FunctionTanCuCu::
130 NbEquations() const { return 2; }
132 Standard_Boolean Geom2dGcc_FunctionTanCuCu::
133 Value (const math_Vector& X ,
134 math_Vector& Fval ) {
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;
151 Standard_Boolean Geom2dGcc_FunctionTanCuCu::
152 Derivatives (const math_Vector& X ,
153 math_Matrix& Deriv ) {
160 InitDerivative(X,Point1,Point2,Vect11,Vect21,Vect12,Vect22);
161 Standard_Real NormeD11 = Vect11.Magnitude();
162 Standard_Real NormeD21 = Vect21.Magnitude();
164 gp_Vec2d V2V1(Vect11.XY(),Vect21.XY());
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;
186 Standard_Boolean Geom2dGcc_FunctionTanCuCu::
187 Values (const math_Vector& X ,
189 math_Matrix& Deriv ) {
196 InitDerivative(X,Point1,Point2,Vect11,Vect21,Vect12,Vect22);
197 Standard_Real NormeD11 = Vect11.Magnitude();
198 Standard_Real NormeD21 = Vect21.Magnitude();
200 gp_Vec2d V2V1(Vect11.XY(),Vect21.XY());
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;