0026377: Passing Handle objects as arguments to functions as non-const reference...
[occt.git] / src / ElCLib / ElCLib.cxx
CommitLineData
b311480e 1// Created on: 1991-09-09
2// Created by: Michel Chauvat
3// Copyright (c) 1991-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 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
973c2be1 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
b311480e 16
7fd59977 17// Evolutions JCV Dec 1991 ajout de calculs de derivees et traitement
18// d'entites 2d
19// JCV Mars 1992 ajout method SetLinearForm
20
21#define No_Standard_OutOfRange
22
42cf5bc1 23
24#include <ElCLib.hxx>
7fd59977 25#include <gp.hxx>
42cf5bc1 26#include <gp_Ax1.hxx>
27#include <gp_Ax2.hxx>
28#include <gp_Ax2d.hxx>
29#include <gp_Ax22d.hxx>
30#include <gp_Circ.hxx>
31#include <gp_Circ2d.hxx>
32#include <gp_Dir.hxx>
33#include <gp_Dir2d.hxx>
34#include <gp_Elips.hxx>
35#include <gp_Elips2d.hxx>
36#include <gp_Hypr.hxx>
37#include <gp_Hypr2d.hxx>
38#include <gp_Lin.hxx>
39#include <gp_Lin2d.hxx>
40#include <gp_Parab.hxx>
41#include <gp_Parab2d.hxx>
42#include <gp_Pnt.hxx>
43#include <gp_Pnt2d.hxx>
44#include <gp_Vec.hxx>
45#include <gp_Vec2d.hxx>
7fd59977 46
c6541a0c 47static Standard_Real PIPI = M_PI + M_PI;
7fd59977 48
49//=======================================================================
50//function : InPeriod
51//purpose :
52//=======================================================================
53
54Standard_Real ElCLib::InPeriod(const Standard_Real U,
55 const Standard_Real UFirst,
56 const Standard_Real ULast)
57{
58 Standard_Real u = U, period = ULast - UFirst;
59 Standard_Real Eps = Epsilon(period);
60
61 while (Eps < (UFirst-u)) u += period;
62 while (Eps > (ULast -u)) u -= period;
63 if ( u < UFirst) u = UFirst;
64 return u;
65}
66
67//=======================================================================
68//function : AdjustPeriodic
69//purpose :
70//=======================================================================
71
72void ElCLib::AdjustPeriodic(const Standard_Real UFirst,
73 const Standard_Real ULast,
74 const Standard_Real Preci,
75 Standard_Real& U1,
76 Standard_Real& U2)
77{
78 Standard_Real period = ULast - UFirst;
79 U1 -= Floor((U1-UFirst)/period) * period;
80 if (ULast - U1 < Preci) U1 -= period;
81 U2 -= Floor((U2-U1)/period) * period;
82 if (U2 - U1 < Preci) U2 += period;
83}
84
85//=======================================================================
86//function : LineValue
87//purpose :
88//=======================================================================
89
90gp_Pnt ElCLib::LineValue (const Standard_Real U,
91 const gp_Ax1& Pos)
92{
93 const gp_XYZ& ZDir = Pos.Direction().XYZ();
94 const gp_XYZ& PLoc = Pos.Location ().XYZ();
95 return gp_Pnt(U * ZDir.X() + PLoc.X(),
96 U * ZDir.Y() + PLoc.Y(),
97 U * ZDir.Z() + PLoc.Z());
98}
99
100//=======================================================================
101//function : CircleValue
102//purpose :
103//=======================================================================
104
105gp_Pnt ElCLib::CircleValue (const Standard_Real U,
106 const gp_Ax2& Pos,
107 const Standard_Real Radius)
108{
109 const gp_XYZ& XDir = Pos.XDirection().XYZ();
110 const gp_XYZ& YDir = Pos.YDirection().XYZ();
111 const gp_XYZ& PLoc = Pos.Location ().XYZ();
112 Standard_Real A1 = Radius * cos(U);
113 Standard_Real A2 = Radius * sin(U);
114 return gp_Pnt(A1 * XDir.X() + A2 * YDir.X() + PLoc.X(),
115 A1 * XDir.Y() + A2 * YDir.Y() + PLoc.Y(),
116 A1 * XDir.Z() + A2 * YDir.Z() + PLoc.Z());
117}
118
119//=======================================================================
120//function : EllipseValue
121//purpose :
122//=======================================================================
123
124gp_Pnt ElCLib::EllipseValue (const Standard_Real U,
125 const gp_Ax2& Pos,
126 const Standard_Real MajorRadius,
127 const Standard_Real MinorRadius)
128{
129 const gp_XYZ& XDir = Pos.XDirection().XYZ();
130 const gp_XYZ& YDir = Pos.YDirection().XYZ();
131 const gp_XYZ& PLoc = Pos.Location ().XYZ();
132 Standard_Real A1 = MajorRadius * cos(U);
133 Standard_Real A2 = MinorRadius * sin(U);
134 return gp_Pnt(A1 * XDir.X() + A2 * YDir.X() + PLoc.X(),
135 A1 * XDir.Y() + A2 * YDir.Y() + PLoc.Y(),
136 A1 * XDir.Z() + A2 * YDir.Z() + PLoc.Z());
137}
138
139//=======================================================================
140//function : HyperbolaValue
141//purpose :
142//=======================================================================
143
144gp_Pnt ElCLib::HyperbolaValue (const Standard_Real U,
145 const gp_Ax2& Pos,
146 const Standard_Real MajorRadius,
147 const Standard_Real MinorRadius)
148{
149 const gp_XYZ& XDir = Pos.XDirection().XYZ();
150 const gp_XYZ& YDir = Pos.YDirection().XYZ();
151 const gp_XYZ& PLoc = Pos.Location ().XYZ();
152 Standard_Real A1 = MajorRadius * cosh(U);
153 Standard_Real A2 = MinorRadius * sinh(U);
154 return gp_Pnt(A1 * XDir.X() + A2 * YDir.X() + PLoc.X(),
155 A1 * XDir.Y() + A2 * YDir.Y() + PLoc.Y(),
156 A1 * XDir.Z() + A2 * YDir.Z() + PLoc.Z());
157}
158
159//=======================================================================
160//function : ParabolaValue
161//purpose :
162//=======================================================================
163
164gp_Pnt ElCLib::ParabolaValue (const Standard_Real U,
165 const gp_Ax2& Pos,
166 const Standard_Real Focal)
167{
168 if (Focal == 0.0) {
169 const gp_XYZ& XDir = Pos.XDirection().XYZ();
170 const gp_XYZ& PLoc = Pos.Location ().XYZ();
171 return gp_Pnt(U * XDir.X() + PLoc.X(),
172 U * XDir.Y() + PLoc.Y(),
173 U * XDir.Z() + PLoc.Z());
174 }
175 const gp_XYZ& XDir = Pos.XDirection().XYZ();
176 const gp_XYZ& YDir = Pos.YDirection().XYZ();
177 const gp_XYZ& PLoc = Pos.Location ().XYZ();
178 Standard_Real A1 = U * U / (4.0 * Focal);
179 return gp_Pnt(A1 * XDir.X() + U * YDir.X() + PLoc.X(),
180 A1 * XDir.Y() + U * YDir.Y() + PLoc.Y(),
181 A1 * XDir.Z() + U * YDir.Z() + PLoc.Z());
182}
183
184//=======================================================================
185//function : LineD1
186//purpose :
187//=======================================================================
188
189void ElCLib::LineD1 (const Standard_Real U,
190 const gp_Ax1& Pos,
191 gp_Pnt& P,
192 gp_Vec& V1)
193{
194 gp_XYZ Coord = Pos.Direction().XYZ();
195 V1.SetXYZ (Coord);
196 Coord.SetLinearForm (U, Coord, Pos.Location().XYZ());
197 P.SetXYZ (Coord);
198}
199
200//=======================================================================
201//function : CircleD1
202//purpose :
203//=======================================================================
204
205void ElCLib::CircleD1 (const Standard_Real U,
206 const gp_Ax2& Pos,
207 const Standard_Real Radius,
208 gp_Pnt& P,
209 gp_Vec& V1)
210{
211 Standard_Real Xc = Radius * Cos (U);
212 Standard_Real Yc = Radius * Sin (U);
213 gp_XYZ Coord0;
214 gp_XYZ Coord1 (Pos.XDirection().XYZ());
215 gp_XYZ Coord2 (Pos.YDirection().XYZ());
216 //Point courant :
217 Coord0.SetLinearForm (Xc, Coord1, Yc, Coord2, Pos.Location().XYZ());
218 P.SetXYZ (Coord0);
219 //D1 :
220 Coord0.SetLinearForm (-Yc, Coord1, Xc, Coord2);
221 V1.SetXYZ (Coord0);
222}
223
224//=======================================================================
225//function : EllipseD1
226//purpose :
227//=======================================================================
228
229void ElCLib::EllipseD1 (const Standard_Real U,
230 const gp_Ax2& Pos,
231 const Standard_Real MajorRadius,
232 const Standard_Real MinorRadius,
233 gp_Pnt& P,
234 gp_Vec& V1)
235{
236 Standard_Real Xc = Cos (U);
237 Standard_Real Yc = Sin (U);
238 gp_XYZ Coord0;
239 gp_XYZ Coord1 (Pos.XDirection().XYZ());
240 gp_XYZ Coord2 (Pos.YDirection().XYZ());
241 //Point courant :
242 Coord0.SetLinearForm (Xc*MajorRadius, Coord1,
243 Yc*MinorRadius, Coord2,
244 Pos.Location().XYZ());
245 P.SetXYZ (Coord0);
246 //D1 :
247 Coord0.SetLinearForm (-Yc*MajorRadius, Coord1, Xc*MinorRadius, Coord2);
248 V1.SetXYZ (Coord0);
249}
250
251//=======================================================================
252//function : HyperbolaD1
253//purpose :
254//=======================================================================
255
256void ElCLib::HyperbolaD1 (const Standard_Real U,
257 const gp_Ax2& Pos,
258 const Standard_Real MajorRadius,
259 const Standard_Real MinorRadius,
260 gp_Pnt& P,
261 gp_Vec& V1)
262{
263 Standard_Real Xc = Cosh (U);
264 Standard_Real Yc = Sinh (U);
265 gp_XYZ Coord0;
266 gp_XYZ Coord1 (Pos.XDirection().XYZ());
267 gp_XYZ Coord2 (Pos.YDirection().XYZ());
268 //Point courant :
269 Coord0.SetLinearForm (Xc*MajorRadius, Coord1,
270 Yc*MinorRadius, Coord2,
271 Pos.Location().XYZ());
272 P.SetXYZ (Coord0);
273 //D1 :
274 Coord0.SetLinearForm (Yc*MajorRadius, Coord1, Xc*MinorRadius, Coord2);
275 V1.SetXYZ (Coord0);
276}
277
278//=======================================================================
279//function : ParabolaD1
280//purpose :
281//=======================================================================
282
283void ElCLib::ParabolaD1 (const Standard_Real U,
284 const gp_Ax2& Pos,
285 const Standard_Real Focal,
286 gp_Pnt& P,
287 gp_Vec& V1)
288{
289 gp_XYZ Coord0;
290 gp_XYZ Coord1 (Pos.XDirection().XYZ());
291 if (Focal == 0.0) { //Parabole degenere en une droite
292 V1.SetXYZ (Coord1);
293 Coord1.Multiply (U);
294 Coord1.Add (Pos.Location().XYZ());
295 P.SetXYZ (Coord1);
296 }
297 else {
298 gp_XYZ Coord2 (Pos.YDirection().XYZ());
299 Coord0.SetLinearForm (U / (2.0 * Focal), Coord1, Coord2);
300 V1.SetXYZ (Coord0);
301 Coord0.SetLinearForm ((U * U) / (4.0 * Focal), Coord1,
302 U, Coord2,
303 Pos.Location().XYZ());
304 P.SetXYZ (Coord0);
305 }
306}
307
308//=======================================================================
309//function : CircleD2
310//purpose :
311//=======================================================================
312
313void ElCLib::CircleD2 (const Standard_Real U,
314 const gp_Ax2& Pos,
315 const Standard_Real Radius,
316 gp_Pnt& P,
317 gp_Vec& V1,
318 gp_Vec& V2)
319{
320 Standard_Real Xc = Radius * cos(U);
321 Standard_Real Yc = Radius * sin(U);
322 gp_XYZ Coord0;
323 gp_XYZ Coord1 (Pos.XDirection().XYZ());
324 gp_XYZ Coord2 (Pos.YDirection().XYZ());
325 //Point courant :
326 Coord0.SetLinearForm (Xc, Coord1, Yc, Coord2, Pos.Location().XYZ());
327 P.SetXYZ (Coord0);
328 //D1 :
329 Coord0.SetLinearForm (-Yc, Coord1, Xc, Coord2);
330 V1.SetXYZ (Coord0);
331 //D2 :
332 Coord0.SetLinearForm (-Xc, Coord1, -Yc, Coord2);
333 V2.SetXYZ (Coord0);
334}
335
336//=======================================================================
337//function : EllipseD2
338//purpose :
339//=======================================================================
340
341void ElCLib::EllipseD2 (const Standard_Real U,
342 const gp_Ax2& Pos,
343 const Standard_Real MajorRadius,
344 const Standard_Real MinorRadius,
345 gp_Pnt& P,
346 gp_Vec& V1,
347 gp_Vec& V2)
348{
349 Standard_Real Xc = cos(U);
350 Standard_Real Yc = sin(U);
351 gp_XYZ Coord0;
352 gp_XYZ Coord1 (Pos.XDirection().XYZ());
353 gp_XYZ Coord2 (Pos.YDirection().XYZ());
354 //Point courant :
355 Coord0.SetLinearForm (Xc*MajorRadius, Coord1,
356 Yc*MinorRadius, Coord2,
357 Pos.Location().XYZ());
358 P.SetXYZ (Coord0);
359 //D1 :
360 Coord0.SetLinearForm (-Yc*MajorRadius, Coord1, Xc*MinorRadius, Coord2);
361 V1.SetXYZ (Coord0);
362 //D2 :
363 Coord0.SetLinearForm (-Xc*MajorRadius, Coord1, -Yc*MinorRadius, Coord2);
364 V2.SetXYZ (Coord0);
365}
366
367//=======================================================================
368//function : HyperbolaD2
369//purpose :
370//=======================================================================
371
372void ElCLib::HyperbolaD2 (const Standard_Real U,
373 const gp_Ax2& Pos,
374 const Standard_Real MajorRadius,
375 const Standard_Real MinorRadius,
376 gp_Pnt& P,
377 gp_Vec& V1,
378 gp_Vec& V2)
379{
380 Standard_Real Xc = cosh(U);
381 Standard_Real Yc = sinh(U);
382 gp_XYZ Coord0;
383 gp_XYZ Coord1 (Pos.XDirection().XYZ());
384 gp_XYZ Coord2 (Pos.YDirection().XYZ());
385
386 //Point courant et D2:
387 Coord0.SetLinearForm (Xc*MajorRadius, Coord1, Yc*MinorRadius, Coord2);
388 V2.SetXYZ (Coord0);
389 Coord0.Add (Pos.Location().XYZ());
390 P.SetXYZ (Coord0);
391 //D1 :
392 Coord0.SetLinearForm (Yc*MajorRadius, Coord1, Xc*MinorRadius, Coord2);
393 V1.SetXYZ (Coord0);
394}
395
396//=======================================================================
397//function : ParabolaD2
398//purpose :
399//=======================================================================
400
401void ElCLib::ParabolaD2 (const Standard_Real U,
402 const gp_Ax2& Pos,
403 const Standard_Real Focal,
404 gp_Pnt& P,
405 gp_Vec& V1,
406 gp_Vec& V2)
407{
408 gp_XYZ Coord0(0.0, 0.0, 0.0);
409 gp_XYZ Coord1 (Pos.XDirection().XYZ());
410 if (Focal == 0.0) {
411 V2.SetCoord (0.0, 0.0, 0.0);
412 V1.SetXYZ (Coord1);
413 Coord1.Multiply (U);
414 Coord1.Add (Pos.Location().XYZ());
415 P.SetXYZ (Coord1);//was: P.SetXYZ (Coord0);
416
417 }
418 else {
419 gp_XYZ Coord2 (Pos.YDirection().XYZ());
420 Coord0.SetLinearForm ((U * U) / (4.0 * Focal), Coord1,
421 U, Coord2,
422 Pos.Location().XYZ());
423 P.SetXYZ (Coord0);
424 Coord0.SetLinearForm (U / (2.0 * Focal), Coord1, Coord2);
425 V1.SetXYZ (Coord0);
426 Coord1.Multiply (1.0 / (2.0 * Focal));
427 V2.SetXYZ (Coord1);
428 }
429}
430
431//=======================================================================
432//function : CircleD3
433//purpose :
434//=======================================================================
435
436void ElCLib::CircleD3 (const Standard_Real U,
437 const gp_Ax2& Pos,
438 const Standard_Real Radius,
439 gp_Pnt& P,
440 gp_Vec& V1,
441 gp_Vec& V2,
442 gp_Vec& V3)
443{
444 Standard_Real Xc = Radius * cos(U);
445 Standard_Real Yc = Radius * sin(U);
446 gp_XYZ Coord0;
447 gp_XYZ Coord1 (Pos.XDirection().XYZ());
448 gp_XYZ Coord2 (Pos.YDirection().XYZ());
449 //Point Courant :
450 Coord0.SetLinearForm (Xc, Coord1, Yc, Coord2, Pos.Location().XYZ());
451 P.SetXYZ (Coord0);
452 //D1 :
453 Coord0.SetLinearForm (-Yc, Coord1, Xc, Coord2);
454 V1.SetXYZ (Coord0);
455 //D2 :
456 Coord0.SetLinearForm (-Xc, Coord1, -Yc, Coord2);
457 V2.SetXYZ (Coord0);
458 //D3 :
459 Coord0.SetLinearForm (Yc, Coord1, -Xc, Coord2);
460 V3.SetXYZ (Coord0);
461}
462
463//=======================================================================
464//function : EllipseD3
465//purpose :
466//=======================================================================
467
468void ElCLib::EllipseD3 (const Standard_Real U,
469 const gp_Ax2& Pos,
470 const Standard_Real MajorRadius,
471 const Standard_Real MinorRadius,
472 gp_Pnt& P,
473 gp_Vec& V1,
474 gp_Vec& V2,
475 gp_Vec& V3)
476{
477 Standard_Real Xc = cos(U);
478 Standard_Real Yc = sin(U);
479 gp_XYZ Coord0;
480 gp_XYZ Coord1 (Pos.XDirection().XYZ());
481 gp_XYZ Coord2 (Pos.YDirection().XYZ());
482 //Point Courant :
483 Coord0.SetLinearForm (Xc*MajorRadius, Coord1,
484 Yc*MinorRadius, Coord2,
485 Pos.Location().XYZ());
486 P.SetXYZ (Coord0);
487 //D1 :
488 Coord0.SetLinearForm (-Yc*MajorRadius, Coord1, Xc*MinorRadius, Coord2);
489 V1.SetXYZ (Coord0);
490 //D2 :
491 Coord0.SetLinearForm (-Xc*MajorRadius, Coord1, -Yc*MinorRadius, Coord2);
492 V2.SetXYZ (Coord0);
493 //D3
494 Coord0.SetLinearForm (Yc*MajorRadius, Coord1, -Xc*MinorRadius, Coord2);
495 V3.SetXYZ (Coord0);
496}
497
498//=======================================================================
499//function : HyperbolaD3
500//purpose :
501//=======================================================================
502
503void ElCLib::HyperbolaD3 (const Standard_Real U,
504 const gp_Ax2& Pos,
505 const Standard_Real MajorRadius,
506 const Standard_Real MinorRadius,
507 gp_Pnt& P,
508 gp_Vec& V1,
509 gp_Vec& V2,
510 gp_Vec& V3)
511{
512 Standard_Real Xc = cosh(U);
513 Standard_Real Yc = sinh(U);
514 gp_XYZ Coord0;
515 gp_XYZ Coord1 (Pos.XDirection().XYZ());
516 gp_XYZ Coord2 (Pos.YDirection().XYZ());
517 //Point courant et D2 :
518 Coord0.SetLinearForm (Xc*MajorRadius, Coord1, Yc*MinorRadius, Coord2);
519 V2.SetXYZ (Coord0);
520 Coord0.Add (Pos.Location().XYZ());
521 P.SetXYZ (Coord0);
522 //D1 et D3 :
523 Coord0.SetLinearForm (Yc*MajorRadius, Coord1, Xc*MinorRadius, Coord2);
524 V1.SetXYZ (Coord0);
525 V3.SetXYZ (Coord0);
526}
527
528//=======================================================================
529//function : LineValue
530//purpose :
531//=======================================================================
532
533gp_Pnt2d ElCLib::LineValue (const Standard_Real U,
534 const gp_Ax2d& Pos)
535{
536 const gp_XY& ZDir = Pos.Direction().XY();
537 const gp_XY& PLoc = Pos.Location ().XY();
538 return gp_Pnt2d(U * ZDir.X() + PLoc.X(),
539 U * ZDir.Y() + PLoc.Y());
540}
541
542//=======================================================================
543//function : CircleValue
544//purpose :
545//=======================================================================
546
547gp_Pnt2d ElCLib::CircleValue (const Standard_Real U,
548 const gp_Ax22d& Pos,
549 const Standard_Real Radius)
550{
551 const gp_XY& XDir = Pos.XDirection().XY();
552 const gp_XY& YDir = Pos.YDirection().XY();
553 const gp_XY& PLoc = Pos.Location ().XY();
554 Standard_Real A1 = Radius * cos(U);
555 Standard_Real A2 = Radius * sin(U);
556 return gp_Pnt2d(A1 * XDir.X() + A2 * YDir.X() + PLoc.X(),
557 A1 * XDir.Y() + A2 * YDir.Y() + PLoc.Y());
558}
559
560//=======================================================================
561//function : EllipseValue
562//purpose :
563//=======================================================================
564
565gp_Pnt2d ElCLib::EllipseValue (const Standard_Real U,
566 const gp_Ax22d& Pos,
567 const Standard_Real MajorRadius,
568 const Standard_Real MinorRadius)
569{
570 const gp_XY& XDir = Pos.XDirection().XY();
571 const gp_XY& YDir = Pos.YDirection().XY();
572 const gp_XY& PLoc = Pos.Location ().XY();
573 Standard_Real A1 = MajorRadius * cos(U);
574 Standard_Real A2 = MinorRadius * sin(U);
575 return gp_Pnt2d(A1 * XDir.X() + A2 * YDir.X() + PLoc.X(),
576 A1 * XDir.Y() + A2 * YDir.Y() + PLoc.Y());
577}
578
579//=======================================================================
580//function : HyperbolaValue
581//purpose :
582//=======================================================================
583
584gp_Pnt2d ElCLib::HyperbolaValue (const Standard_Real U,
585 const gp_Ax22d& Pos,
586 const Standard_Real MajorRadius,
587 const Standard_Real MinorRadius)
588{
589 const gp_XY& XDir = Pos.XDirection().XY();
590 const gp_XY& YDir = Pos.YDirection().XY();
591 const gp_XY& PLoc = Pos.Location ().XY();
592 Standard_Real A1 = MajorRadius * cosh(U);
593 Standard_Real A2 = MinorRadius * sinh(U);
594 return gp_Pnt2d(A1 * XDir.X() + A2 * YDir.X() + PLoc.X(),
595 A1 * XDir.Y() + A2 * YDir.Y() + PLoc.Y());
596}
597
598//=======================================================================
599//function : ParabolaValue
600//purpose :
601//=======================================================================
602
603gp_Pnt2d ElCLib::ParabolaValue (const Standard_Real U,
604 const gp_Ax22d& Pos,
605 const Standard_Real Focal)
606{
607 if (Focal == 0.0) {
608 const gp_XY& XDir = Pos.XDirection().XY();
609 const gp_XY& PLoc = Pos.Location ().XY();
610 return gp_Pnt2d(U * XDir.X() + PLoc.X(),
611 U * XDir.Y() + PLoc.Y());
612 }
613 const gp_XY& XDir = Pos.XDirection().XY();
614 const gp_XY& YDir = Pos.YDirection().XY();
615 const gp_XY& PLoc = Pos.Location ().XY();
616 Standard_Real A1 = U * U / (4.0 * Focal);
617 return gp_Pnt2d(A1 * XDir.X() + U * YDir.X() + PLoc.X(),
618 A1 * XDir.Y() + U * YDir.Y() + PLoc.Y());
619}
620
621//=======================================================================
622//function : LineD1
623//purpose :
624//=======================================================================
625
626void ElCLib::LineD1(const Standard_Real U,
627 const gp_Ax2d& Pos,
628 gp_Pnt2d& P,
629 gp_Vec2d& V1)
630{
631 gp_XY Coord = Pos.Direction().XY();
632 V1.SetXY (Coord);
633 Coord.SetLinearForm (U, Coord, Pos.Location().XY());
634 P.SetXY (Coord);
635}
636
637//=======================================================================
638//function : CircleD1
639//purpose :
640//=======================================================================
641
642void ElCLib::CircleD1 (const Standard_Real U,
643 const gp_Ax22d& Pos,
644 const Standard_Real Radius,
645 gp_Pnt2d& P,
646 gp_Vec2d& V1)
647{
648 gp_XY Vxy;
649 gp_XY Xdir (Pos.XDirection().XY());
650 gp_XY Ydir (Pos.YDirection().XY());
651 Standard_Real Xc = Radius * cos(U);
652 Standard_Real Yc = Radius * sin(U);
653 //Point courant :
654 Vxy.SetLinearForm (Xc, Xdir, Yc, Ydir, Pos.Location().XY());
655 P.SetXY (Vxy);
656 //V1 :
657 Vxy.SetLinearForm (-Yc, Xdir, Xc, Ydir);
658 V1.SetXY (Vxy);
659}
660
661//=======================================================================
662//function : EllipseD1
663//purpose :
664//=======================================================================
665
666void ElCLib::EllipseD1 (const Standard_Real U,
667 const gp_Ax22d& Pos,
668 const Standard_Real MajorRadius,
669 const Standard_Real MinorRadius,
670 gp_Pnt2d& P,
671 gp_Vec2d& V1)
672{
673 gp_XY Vxy;
674 gp_XY Xdir ((Pos.XDirection()).XY());
675 gp_XY Ydir ((Pos.YDirection()).XY());
676 Standard_Real Xc = cos(U);
677 Standard_Real Yc = sin(U);
678 //Point courant :
679 Vxy.SetLinearForm (Xc*MajorRadius, Xdir,
680 Yc*MinorRadius, Ydir,
681 Pos.Location().XY());
682 P.SetXY (Vxy);
683
684 //V1 :
685 Vxy.SetLinearForm (-Yc*MajorRadius, Xdir, Xc*MinorRadius, Ydir);
686 V1.SetXY (Vxy);
687}
688
689//=======================================================================
690//function : HyperbolaD1
691//purpose :
692//=======================================================================
693
694void ElCLib::HyperbolaD1 (const Standard_Real U,
695 const gp_Ax22d& Pos,
696 const Standard_Real MajorRadius,
697 const Standard_Real MinorRadius,
698 gp_Pnt2d& P,
699 gp_Vec2d& V1)
700{
701 gp_XY Vxy;
702 gp_XY Xdir ((Pos.XDirection()).XY());
703 gp_XY Ydir ((Pos.YDirection()).XY());
704 Standard_Real Xc = cosh(U);
705 Standard_Real Yc = sinh(U);
706 //Point courant :
707 Vxy.SetLinearForm (Xc*MajorRadius, Xdir,
708 Yc*MinorRadius, Ydir,
709 Pos.Location().XY());
710 P.SetXY (Vxy);
711
712 //V1 :
713 Vxy.SetLinearForm (Yc*MajorRadius, Xdir, Xc*MinorRadius, Ydir);
714 V1.SetXY (Vxy);
715}
716
717//=======================================================================
718//function : ParabolaD1
719//purpose :
720//=======================================================================
721
722void ElCLib::ParabolaD1 (const Standard_Real U,
723 const gp_Ax22d& Pos,
724 const Standard_Real Focal,
725 gp_Pnt2d& P,
726 gp_Vec2d& V1)
727{
728 gp_XY Vxy;
729 gp_XY Xdir (Pos.XDirection().XY());
730 if (Focal == 0.0) { //Parabole degenere en une droite
731 V1.SetXY (Xdir);
732 Vxy.SetLinearForm (U, Xdir, Pos.Location().XY());
733 }
734 else {
735 gp_XY Ydir (Pos.YDirection().XY());
736 Vxy.SetLinearForm (U / (2.0 * Focal), Xdir, Ydir);
737 V1.SetXY (Vxy);
738 Vxy.SetLinearForm ((U * U) / (4.0 * Focal), Xdir,
739 U, Ydir,
740 Pos.Location().XY());
741 }
742 P.SetXY (Vxy);
743}
744
745//=======================================================================
746//function : CircleD2
747//purpose :
748//=======================================================================
749
750void ElCLib::CircleD2 (const Standard_Real U,
751 const gp_Ax22d& Pos,
752 const Standard_Real Radius,
753 gp_Pnt2d& P,
754 gp_Vec2d& V1,
755 gp_Vec2d& V2)
756{
757 gp_XY Vxy;
758 gp_XY Xdir (Pos.XDirection().XY());
759 gp_XY Ydir (Pos.YDirection().XY());
760 Standard_Real Xc = Radius * cos(U);
761 Standard_Real Yc = Radius * sin(U);
762 //V2 :
763 Vxy.SetLinearForm (Xc, Xdir, Yc, Ydir);
764 V2.SetXY (Vxy);
765 V2.Reverse();
766 Vxy.Add (Pos.Location().XY());
767 P.SetXY (Vxy);
768
769 //V1 :
770 Vxy.SetLinearForm (-Yc, Xdir, Xc, Ydir);
771 V1.SetXY (Vxy);
772}
773
774//=======================================================================
775//function : EllipseD2
776//purpose :
777//=======================================================================
778
779void ElCLib::EllipseD2 (const Standard_Real U,
780 const gp_Ax22d& Pos,
781 const Standard_Real MajorRadius,
782 const Standard_Real MinorRadius,
783 gp_Pnt2d& P,
784 gp_Vec2d& V1,
785 gp_Vec2d& V2)
786{
787 gp_XY Vxy;
788 gp_XY Xdir (Pos.XDirection().XY());
789 gp_XY Ydir (Pos.YDirection().XY());
790 Standard_Real Xc = cos(U);
791 Standard_Real Yc = sin(U);
792
793 //V2 :
794 Vxy.SetLinearForm (Xc*MajorRadius, Xdir, Yc*MinorRadius, Ydir);
795 V2.SetXY (Vxy);
796 V2.Reverse ();
797
798 //Point courant :
799 Vxy.Add (Pos.Location().XY());
800 P.SetXY (Vxy);
801
802 //V1 :
803 Vxy.SetLinearForm (-Yc*MajorRadius, Xdir, Xc*MinorRadius, Ydir);
804 V1.SetXY (Vxy);
805}
806
807//=======================================================================
808//function : HyperbolaD2
809//purpose :
810//=======================================================================
811
812void ElCLib::HyperbolaD2 (const Standard_Real U,
813 const gp_Ax22d& Pos,
814 const Standard_Real MajorRadius,
815 const Standard_Real MinorRadius,
816 gp_Pnt2d& P,
817 gp_Vec2d& V1,
818 gp_Vec2d& V2)
819{
820 gp_XY Vxy;
821 gp_XY Xdir (Pos.XDirection().XY());
822 gp_XY Ydir (Pos.YDirection().XY());
823 Standard_Real Xc = cosh(U);
824 Standard_Real Yc = sinh(U);
825
826 //V2 :
827 Vxy.SetLinearForm (Xc*MajorRadius, Xdir, Yc*MinorRadius, Ydir);
828 V2.SetXY (Vxy);
829
830 //Point courant :
831 Vxy.Add (Pos.Location().XY());
832 P.SetXY (Vxy);
833
834 //V1 :
835 Vxy.SetLinearForm (Yc*MajorRadius, Xdir, Xc*MinorRadius, Ydir);
836 V1.SetXY (Vxy);
837}
838
839//=======================================================================
840//function : ParabolaD2
841//purpose :
842//=======================================================================
843
844void ElCLib::ParabolaD2 (const Standard_Real U,
845 const gp_Ax22d& Pos,
846 const Standard_Real Focal,
847 gp_Pnt2d& P,
848 gp_Vec2d& V1,
849 gp_Vec2d& V2)
850{
851 gp_XY Vxy;
852 gp_XY Xdir (Pos.XDirection().XY());
853 if (Focal == 0.0) {
854 V2.SetCoord (0.0, 0.0);
855 V1.SetXY (Xdir);
856 Vxy.SetLinearForm (U, Xdir, Pos.Location().XY());
857 }
858 else {
859 gp_XY Ydir (Pos.YDirection().XY());
860 Vxy = Xdir.Multiplied (1.0 / (2.0 * Focal));
861 V2.SetXY (Vxy);
862 Vxy.SetLinearForm (U, Vxy, Ydir);
863 V1.SetXY (Vxy);
864 Vxy.SetLinearForm (U * U / (4.0 * Focal), Xdir, U, Ydir);
865 Vxy.Add (Pos.Location().XY());
866 }
867 P.SetXY (Vxy);
868}
869
870//=======================================================================
871//function : CircleD3
872//purpose :
873//=======================================================================
874
875void ElCLib::CircleD3 (const Standard_Real U,
876 const gp_Ax22d& Pos,
877 const Standard_Real Radius,
878 gp_Pnt2d& P,
879 gp_Vec2d& V1,
880 gp_Vec2d& V2,
881 gp_Vec2d& V3)
882{
883 gp_XY Vxy;
884 gp_XY Xdir (Pos.XDirection().XY());
885 gp_XY Ydir (Pos.YDirection().XY());
886 Standard_Real Xc = Radius * cos(U);
887 Standard_Real Yc = Radius * sin(U);
888
889 //V2 :
890 Vxy.SetLinearForm (Xc, Xdir, Yc, Ydir);
891 V2.SetXY (Vxy);
892 V2.Reverse();
893
894 //Point courant :
895 Vxy.Add (Pos.Location().XY());
896 P.SetXY (Vxy);
897
898 //V1 :
899 Vxy.SetLinearForm (-Yc, Xdir, Xc, Ydir);
900 V1.SetXY (Vxy);
901
902 //V3 :
903 V3.SetXY (Vxy);
904 V3.Reverse ();
905}
906
907//=======================================================================
908//function : EllipseD3
909//purpose :
910//=======================================================================
911
912void ElCLib::EllipseD3 (const Standard_Real U,
913 const gp_Ax22d& Pos,
914 const Standard_Real MajorRadius,
915 const Standard_Real MinorRadius,
916 gp_Pnt2d& P,
917 gp_Vec2d& V1,
918 gp_Vec2d& V2,
919 gp_Vec2d& V3)
920{
921 gp_XY Vxy;
922 gp_XY Xdir (Pos.XDirection().XY());
923 gp_XY Ydir (Pos.YDirection().XY());
924 Standard_Real Xc = cos(U);
925 Standard_Real Yc = sin(U);
926
927 //V2 :
928 Vxy.SetLinearForm (Xc*MajorRadius, Xdir, Yc*MinorRadius, Ydir);
929 V2.SetXY (Vxy);
930 V2.Reverse ();
931
932 //Point courant :
933 Vxy.Add (Pos.Location().XY());
934 P.SetXY (Vxy);
935
936 //V1 :
937 Vxy.SetLinearForm (-Yc*MajorRadius, Xdir, Xc*MinorRadius, Ydir);
938 V1.SetXY (Vxy);
939
940 //V3 :
941 V3.SetXY (Vxy);
942 V3.Reverse ();
943}
944
945//=======================================================================
946//function : HyperbolaD3
947//purpose :
948//=======================================================================
949
950void ElCLib::HyperbolaD3 (const Standard_Real U,
951 const gp_Ax22d& Pos,
952 const Standard_Real MajorRadius,
953 const Standard_Real MinorRadius,
954 gp_Pnt2d& P,
955 gp_Vec2d& V1,
956 gp_Vec2d& V2,
957 gp_Vec2d& V3)
958{
959 gp_XY Vxy;
960 gp_XY Xdir (Pos.XDirection().XY());
961 gp_XY Ydir (Pos.YDirection().XY());
962 Standard_Real Xc = cosh(U);
963 Standard_Real Yc = sinh(U);
964
965 //V2 :
966 Vxy.SetLinearForm (Xc*MajorRadius, Xdir, Yc*MinorRadius, Ydir);
967 V2.SetXY (Vxy);
968
969 //Point courant :
970 Vxy.Add (Pos.Location().XY());
971 P.SetXY (Vxy);
972
973 //V1 :
974 Vxy.SetLinearForm (Yc*MajorRadius, Xdir, Xc*MinorRadius, Ydir);
975 V1.SetXY (Vxy);
976
977 //V3 :
978 V3.SetXY (Vxy);
979}
980
981//=======================================================================
982//function : LineDN
983//purpose :
984//=======================================================================
985
986gp_Vec ElCLib::LineDN (const Standard_Real,
987 const gp_Ax1& Pos,
988 const Standard_Integer N)
989{
990 if (N == 1) { return gp_Vec(Pos.Direction()); }
991 return gp_Vec (0., 0., 0.);
992}
993
994//=======================================================================
995//function : CircleDN
996//purpose :
997//=======================================================================
998
999gp_Vec ElCLib::CircleDN (const Standard_Real U,
1000 const gp_Ax2& Pos,
1001 const Standard_Real Radius,
1002 const Standard_Integer N)
1003{
1004 Standard_Real Xc=0, Yc=0;
1005 if (N == 1) {
1006 Xc = Radius * -sin(U);
1007 Yc = Radius * cos(U);
1008 }
1009 else if ((N + 2) % 4 == 0) {
1010 Xc = Radius * -cos(U);
1011 Yc = Radius * -sin(U);
1012 }
1013 else if ((N + 1) % 4 == 0) {
1014 Xc = Radius * sin(U);
1015 Yc = Radius * -cos(U);
1016 }
1017 else if (N % 4 == 0) {
1018 Xc = Radius * cos(U);
1019 Yc = Radius * sin(U);
1020 }
1021 else if ((N-1) % 4 == 0) {
1022 Xc = Radius * -sin(U);
1023 Yc = Radius * cos(U);
1024 }
1025 gp_XYZ Coord1 (Pos.XDirection().XYZ());
1026 Coord1.SetLinearForm (Xc, Coord1, Yc, Pos.YDirection().XYZ());
1027 return gp_Vec (Coord1);
1028}
1029
1030//=======================================================================
1031//function : EllipseDN
1032//purpose :
1033//=======================================================================
1034
1035gp_Vec ElCLib::EllipseDN (const Standard_Real U,
1036 const gp_Ax2& Pos,
1037 const Standard_Real MajorRadius,
1038 const Standard_Real MinorRadius,
1039 const Standard_Integer N)
1040{
1041 Standard_Real Xc=0, Yc=0;
1042 if (N == 1) {
1043 Xc = MajorRadius * -sin(U);
1044 Yc = MinorRadius * cos(U);
1045 }
1046 else if ((N + 2) % 4 == 0) {
1047 Xc = MajorRadius * -cos(U);
1048 Yc = MinorRadius * -sin(U);
1049 }
1050 else if ((N + 1) % 4 == 0) {
1051 Xc = MajorRadius * sin(U);
1052 Yc = MinorRadius * -cos(U);
1053 }
1054 else if (N % 4 == 0) {
1055 Xc = MajorRadius * cos(U);
1056 Yc = MinorRadius * sin(U);
1057 }
1058 else if ((N-1) % 4 == 0) {
1059 Xc = MajorRadius * -sin(U);
1060 Yc = MinorRadius * cos(U);
1061 }
1062 gp_XYZ Coord1 (Pos.XDirection().XYZ());
1063 Coord1.SetLinearForm (Xc, Coord1, Yc, Pos.YDirection().XYZ());
1064 return gp_Vec (Coord1);
1065}
1066
1067//=======================================================================
1068//function : HyperbolaDN
1069//purpose :
1070//=======================================================================
1071
1072gp_Vec ElCLib::HyperbolaDN (const Standard_Real U,
1073 const gp_Ax2& Pos,
1074 const Standard_Real MajorRadius,
1075 const Standard_Real MinorRadius,
1076 const Standard_Integer N)
1077{
1078 Standard_Real Xc=0, Yc=0;
1079 if (IsOdd (N)) {
1080 Xc = MajorRadius * sinh(U);
1081 Yc = MinorRadius * cosh(U);
1082 }
1083 else if (IsEven (N)) {
1084 Xc = MajorRadius * cosh(U);
1085 Yc = MinorRadius * sinh(U);
1086 }
1087 gp_XYZ Coord1 (Pos.XDirection().XYZ());
1088 Coord1.SetLinearForm (Xc, Coord1, Yc, Pos.YDirection().XYZ());
1089 return gp_Vec (Coord1);
1090}
1091
1092//=======================================================================
1093//function : ParabolaDN
1094//purpose :
1095//=======================================================================
1096
1097gp_Vec ElCLib::ParabolaDN (const Standard_Real U,
1098 const gp_Ax2& Pos,
1099 const Standard_Real Focal,
1100 const Standard_Integer N)
1101{
1102 if (N <= 2) {
1103 gp_XYZ Coord1 (Pos.XDirection().XYZ());
1104 if (N == 1) {
1105 if (Focal == 0.0) {
1106 return gp_Vec(Coord1);
1107 }
1108 else {
1109 Coord1.SetLinearForm
1110 (U / (2.0 * Focal), Coord1, Pos.YDirection().XYZ());
1111 return gp_Vec (Coord1);
1112 }
1113 }
1114 else if (N == 2) {
1115 if (Focal == 0.0) {
1116 return gp_Vec(0.0, 0.0, 0.0);
1117 }
1118 else {
1119 Coord1.Multiply ( 1.0 / (2.0 * Focal));
1120 return gp_Vec (Coord1);
1121 }
1122 }
1123 }
1124 return gp_Vec (0.,0.,0.);
1125}
1126
1127//=======================================================================
1128//function : LineDN
1129//purpose :
1130//=======================================================================
1131
1132gp_Vec2d ElCLib::LineDN (const Standard_Real,
1133 const gp_Ax2d& Pos,
1134 const Standard_Integer N)
1135{
1136 if (N == 1) { return gp_Vec2d (Pos.Direction ()); }
1137 return gp_Vec2d (0.0, 0.0);
1138}
1139
1140//=======================================================================
1141//function : CircleDN
1142//purpose :
1143//=======================================================================
1144
1145gp_Vec2d ElCLib::CircleDN (const Standard_Real U,
1146 const gp_Ax22d& Pos,
1147 const Standard_Real Radius,
1148 const Standard_Integer N)
1149{
1150 Standard_Real Xc=0, Yc=0;
1151 if (N == 1) {
1152 Xc = Radius * -sin(U);
1153 Yc = Radius * cos(U);
1154 }
1155 else if ((N + 2) % 4 == 0) {
1156 Xc = Radius * -cos(U);
1157 Yc = Radius * -sin(U);
1158 }
1159 else if ((N + 1) % 4 == 0) {
1160 Xc = Radius * sin(U);
1161 Yc = Radius * -cos(U);
1162 }
1163 else if (N % 4 == 0) {
1164 Xc = Radius * cos(U);
1165 Yc = Radius * sin(U);
1166 }
1167 else if ((N-1) % 4 == 0) {
1168 Xc = Radius * -sin(U);
1169 Yc = Radius * cos(U);
1170 }
1171 gp_XY Xdir (Pos.XDirection().XY());
1172 gp_XY Ydir (Pos.YDirection().XY());
1173 Xdir.SetLinearForm (Xc, Xdir, Yc, Ydir);
1174 return gp_Vec2d (Xdir);
1175}
1176
1177//=======================================================================
1178//function : EllipseDN
1179//purpose :
1180//=======================================================================
1181
1182gp_Vec2d ElCLib::EllipseDN (const Standard_Real U,
1183 const gp_Ax22d& Pos,
1184 const Standard_Real MajorRadius,
1185 const Standard_Real MinorRadius,
1186 const Standard_Integer N)
1187{
1188 Standard_Real Xc=0, Yc=0;
1189 if (N == 1) {
1190 Xc = MajorRadius * -sin(U);
1191 Yc = MinorRadius * cos(U);
1192 }
1193 else if ((N + 2) % 4 == 0) {
1194 Xc = MajorRadius * -cos(U);
1195 Yc = MinorRadius * -sin(U);
1196 }
1197 else if ((N + 1) % 4 == 0) {
1198 Xc = MajorRadius * sin(U);
1199 Yc = MinorRadius * -cos(U);
1200 }
1201 else if (N % 4 == 0) {
1202 Xc = MajorRadius * cos(U);
1203 Yc = MinorRadius * sin(U);
1204 }
1205 else if ((N-1) % 4 == 0) {
1206 Xc = MajorRadius * -sin(U);
1207 Yc = MinorRadius * cos(U);
1208 }
1209 gp_XY Xdir (Pos.XDirection().XY());
1210 gp_XY Ydir (Pos.YDirection().XY());
1211 Xdir.SetLinearForm (Xc, Xdir, Yc, Ydir);
1212 return gp_Vec2d (Xdir);
1213}
1214
1215//=======================================================================
1216//function : HyperbolaDN
1217//purpose :
1218//=======================================================================
1219
1220gp_Vec2d ElCLib::HyperbolaDN (const Standard_Real U,
1221 const gp_Ax22d& Pos,
1222 const Standard_Real MajorRadius,
1223 const Standard_Real MinorRadius,
1224 const Standard_Integer N)
1225{
1226 Standard_Real Xc=0, Yc=0;
1227 if (IsOdd (N)) {
1228 Xc = MajorRadius * sinh(U);
1229 Yc = MinorRadius * cosh(U);
1230 }
1231 else if (IsEven (N)) {
1232 Xc = MajorRadius * cosh(U);
1233 Yc = MinorRadius * sinh(U);
1234 }
1235 gp_XY Xdir (Pos.XDirection().XY());
1236 gp_XY Ydir (Pos.YDirection().XY());
1237 Xdir.SetLinearForm (Xc, Xdir, Yc, Ydir);
1238 return gp_Vec2d (Xdir);
1239}
1240
1241//=======================================================================
1242//function : ParabolaDN
1243//purpose :
1244//=======================================================================
1245
1246gp_Vec2d ElCLib::ParabolaDN (const Standard_Real U,
1247 const gp_Ax22d& Pos,
1248 const Standard_Real Focal,
1249 const Standard_Integer N)
1250{
1251 if (N <= 2) {
1252 gp_XY Xdir (Pos.XDirection().XY());
1253 if (N == 1) {
1254 if (Focal == 0.0) {
1255 return gp_Vec2d (Xdir);
1256 }
1257 else {
1258 gp_XY Ydir (Pos.YDirection().XY());
1259 Xdir.SetLinearForm (U / (2.0 * Focal), Xdir, Ydir);
1260 return gp_Vec2d (Xdir);
1261 }
1262 }
1263 else if (N == 2) {
1264 if (Focal == 0.0) {
1265 return gp_Vec2d (0.0, 0.0);
1266 }
1267 else {
1268 Xdir.Multiply ( 1.0 / (2.0 * Focal));
1269 return gp_Vec2d (Xdir);
1270 }
1271 }
1272 }
1273 return gp_Vec2d (0.0, 0.0);
1274}
1275
1276//=======================================================================
1277//function : LineParameter
1278//purpose :
1279//=======================================================================
1280
1281Standard_Real ElCLib::LineParameter (const gp_Ax1& L, const gp_Pnt& P)
1282{
1283 return (P.XYZ() - L.Location().XYZ()).Dot (L.Direction().XYZ());
1284}
1285
1286//=======================================================================
1287//function : CircleParameter
1288//purpose :
1289//=======================================================================
1290
1291Standard_Real ElCLib::CircleParameter (const gp_Ax2& Pos,
1292 const gp_Pnt& P)
1293{
1294 Standard_Real Teta = (Pos.XDirection()) .AngleWithRef
1295 (gp_Vec (Pos.Location(), P), Pos.Direction());
1296 if (Teta < -1.e-16) Teta += PIPI;
1297 else if (Teta < 0) Teta = 0;
1298 return Teta;
1299}
1300
1301//=======================================================================
1302//function : EllipseParameter
1303//purpose :
1304//=======================================================================
1305
1306Standard_Real ElCLib::EllipseParameter (const gp_Ax2& Pos,
1307 const Standard_Real MajorRadius,
1308 const Standard_Real MinorRadius,
1309 const gp_Pnt& P)
1310{
1311 gp_XYZ OP = P.XYZ()-Pos.Location().XYZ();
1312 gp_XYZ xaxis = Pos.XDirection().XYZ();
1313 gp_XYZ yaxis = Pos.YDirection().XYZ();
1314 Standard_Real NY = OP.Dot(yaxis);
1315 Standard_Real NX = OP.Dot(xaxis);
1316
1317 if( (Abs(NX) <= gp::Resolution())
1318 &&(Abs(NY) <= gp::Resolution()))
1319 //-- The point P is on the Axis of the Ellipse.
1320 return(0.0);
1321
1322 yaxis.Multiply (NY * (MajorRadius/MinorRadius));
1323 gp_XYZ Om = xaxis.Multiplied (NX);
1324 Om.Add (yaxis);
1325 Standard_Real Teta = gp_Vec(xaxis).AngleWithRef
1326 (gp_Vec(Om), gp_Vec(Pos.Direction()));
1327 if (Teta < -1.e-16) Teta += PIPI;
1328 else if (Teta < 0) Teta = 0;
1329 return Teta;
1330}
1331
1332//=======================================================================
1333//function : HyperbolaParameter
1334//purpose :
1335//=======================================================================
1336
1337Standard_Real ElCLib::HyperbolaParameter (const gp_Ax2& Pos,
1338 const Standard_Real,
1339 const Standard_Real MinorRadius,
1340 const gp_Pnt& P)
1341{
1342 Standard_Real sht =
1343 gp_Vec(Pos.Location (), P).Dot
1344 (gp_Vec (Pos.YDirection())) / MinorRadius;
d8d01f6e 1345
ad779564 1346#if __QNX__
d8d01f6e 1347 return std::asinh(sht);
1348#else
7fd59977 1349 return asinh(sht);
d8d01f6e 1350#endif
7fd59977 1351}
1352
1353//=======================================================================
1354//function : ParabolaParameter
1355//purpose :
1356//=======================================================================
1357
1358Standard_Real ElCLib::ParabolaParameter (const gp_Ax2& Pos,
1359 const gp_Pnt& P)
1360{
1361 return gp_Vec(Pos.Location(),P).Dot(gp_Vec(Pos.YDirection()));
1362}
1363
1364//=======================================================================
1365//function : LineParameter
1366//purpose :
1367//=======================================================================
1368
1369Standard_Real ElCLib::LineParameter (const gp_Ax2d& L,
1370 const gp_Pnt2d& P)
1371{
1372 gp_XY Coord = P.XY();
1373 Coord.Subtract (L.Location().XY());
1374 return Coord.Dot (L.Direction().XY());
1375}
1376
1377//=======================================================================
1378//function : CircleParameter
1379//purpose :
1380//=======================================================================
1381
1382Standard_Real ElCLib::CircleParameter (const gp_Ax22d& Pos,
1383 const gp_Pnt2d& P)
1384{
1385 Standard_Real Teta = (Pos.XDirection()).Angle
1386 (gp_Vec2d (Pos.Location(),P));
1387 Teta = ((Pos.XDirection() ^ Pos.YDirection()) >= 0.0) ? Teta: -Teta;
1388 if (Teta < -1.e-16) Teta += PIPI;
1389 else if (Teta < 0) Teta = 0;
1390 return Teta;
1391}
1392
1393//=======================================================================
1394//function : EllipseParameter
1395//purpose :
1396//=======================================================================
1397
1398Standard_Real ElCLib::EllipseParameter (const gp_Ax22d& Pos,
1399 const Standard_Real MajorRadius,
1400 const Standard_Real MinorRadius,
1401 const gp_Pnt2d& P)
1402{
1403 gp_XY OP = P.XY();
1404 OP.Subtract (Pos.Location().XY());
1405 gp_XY xaxis = Pos.XDirection().XY();
1406 gp_XY yaxis = Pos.YDirection().XY();
1407 gp_XY Om = xaxis.Multiplied (OP.Dot(xaxis));
1408 yaxis.Multiply ( (OP.Dot(yaxis)) * (MajorRadius/MinorRadius) );
1409 Om.Add (yaxis);
1410 Standard_Real Teta = gp_Vec2d(xaxis).Angle (gp_Vec2d(Om));
1411 Teta = ((Pos.XDirection() ^ Pos.YDirection()) >= 0.0) ? Teta: -Teta;
1412 if (Teta < -1.e-16) Teta += PIPI;
1413 else if (Teta < 0) Teta = 0;
1414 return Teta;
1415}
1416
1417//=======================================================================
1418//function : HyperbolaParameter
1419//purpose :
1420//=======================================================================
1421
1422Standard_Real ElCLib::HyperbolaParameter (const gp_Ax22d& Pos,
1423 const Standard_Real,
1424 const Standard_Real MinorRadius,
1425 const gp_Pnt2d& P)
1426{
1427 gp_Vec2d V (Pos.YDirection().XY());
1428 Standard_Real sht = gp_Vec2d(Pos.Location(),P).Dot(V) /MinorRadius;
ad779564 1429#if __QNX__
d8d01f6e 1430 return std::asinh(sht);
1431#else
1432 return asinh(sht);
1433#endif
7fd59977 1434}
1435
1436//=======================================================================
1437//function : ParabolaParameter
1438//purpose :
1439//=======================================================================
1440
1441Standard_Real ElCLib::ParabolaParameter (const gp_Ax22d& Pos,
1442 const gp_Pnt2d& P)
1443{
1444 gp_Vec2d Directrix (Pos.YDirection().XY());
1445 return gp_Vec2d(Pos.Location(),P).Dot(Directrix);
1446}
1447
1448//=======================================================================
1449//function : To3d
1450//purpose :
1451//=======================================================================
1452
1453gp_Pnt ElCLib::To3d (const gp_Ax2& Pos, const gp_Pnt2d& P)
1454{
1455 gp_XYZ Vxy = Pos.XDirection().XYZ();
1456 Vxy.SetLinearForm (P.X(), Vxy, P.Y(), Pos.YDirection().XYZ(),
1457 Pos.Location().XYZ());
1458 return gp_Pnt (Vxy);
1459
1460}
1461
1462//=======================================================================
1463//function : To3d
1464//purpose :
1465//=======================================================================
1466
1467gp_Dir ElCLib::To3d (const gp_Ax2& Pos, const gp_Dir2d& V)
1468{
1469 gp_Vec Vx = Pos.XDirection();
1470 gp_Vec Vy = Pos.YDirection();
1471 Vx.Multiply (V.X());
1472 Vy.Multiply (V.Y());
1473 Vx.Add(Vy);
1474 return gp_Dir (Vx);
1475}
1476
1477//=======================================================================
1478//function : To3d
1479//purpose :
1480//=======================================================================
1481
1482gp_Vec ElCLib::To3d (const gp_Ax2& Pos, const gp_Vec2d& V)
1483{
1484 gp_Vec Vx = Pos.XDirection();
1485 gp_Vec Vy = Pos.YDirection();
1486 Vx.Multiply (V.X());
1487 Vy.Multiply (V.Y());
1488 Vx.Add(Vy);
1489 return Vx;
1490}
1491
1492//=======================================================================
1493//function : To3d
1494//purpose :
1495//=======================================================================
1496
1497gp_Ax1 ElCLib::To3d (const gp_Ax2& Pos, const gp_Ax2d& A)
1498{
1499 gp_Pnt P = ElCLib::To3d (Pos, A.Location());
1500 gp_Vec V = ElCLib::To3d (Pos, A.Direction());
1501 return gp_Ax1 (P, V);
1502}
1503
1504//=======================================================================
1505//function : To3d
1506//purpose :
1507//=======================================================================
1508
1509gp_Ax2 ElCLib::To3d (const gp_Ax2& Pos, const gp_Ax22d& A)
1510{
1511 gp_Pnt P = ElCLib::To3d (Pos, A.Location());
1512 gp_Vec VX = ElCLib::To3d (Pos, A.XDirection());
1513 gp_Vec VY = ElCLib::To3d (Pos, A.YDirection());
1514 return gp_Ax2 (P, VX.Crossed(VY), VX);
1515}
1516
1517//=======================================================================
1518//function : To3d
1519//purpose :
1520//=======================================================================
1521
1522gp_Lin ElCLib::To3d (const gp_Ax2& Pos, const gp_Lin2d& L)
1523{
1524 return gp_Lin (ElCLib::To3d (Pos, L.Position()));
1525}
1526
1527//=======================================================================
1528//function : To3d
1529//purpose :
1530//=======================================================================
1531
1532gp_Circ ElCLib::To3d (const gp_Ax2& Pos, const gp_Circ2d& C)
1533{
1534 return gp_Circ (ElCLib::To3d (Pos, C.Axis()), C.Radius());
1535}
1536
1537//=======================================================================
1538//function : To3d
1539//purpose :
1540//=======================================================================
1541
1542gp_Elips ElCLib::To3d (const gp_Ax2& Pos, const gp_Elips2d& E)
1543{
1544 return gp_Elips (ElCLib::To3d (Pos, E.Axis ()), E.MajorRadius (),
1545 E.MinorRadius ());
1546}
1547
1548//=======================================================================
1549//function : To3d
1550//purpose :
1551//=======================================================================
1552
1553gp_Hypr ElCLib::To3d (const gp_Ax2& Pos, const gp_Hypr2d& H)
1554{
1555 return gp_Hypr (ElCLib::To3d (Pos, H.Axis ()), H.MajorRadius (),
1556 H.MinorRadius ());
1557}
1558
1559//=======================================================================
1560//function : To3d
1561//purpose :
1562//=======================================================================
1563
1564gp_Parab ElCLib::To3d (const gp_Ax2& Pos, const gp_Parab2d& Prb)
1565{
1566 return gp_Parab ( ElCLib::To3d (Pos, Prb.Axis ()), Prb.Focal ());
1567}
1568