Integration of OCCT 6.5.0 from SVN
[occt.git] / src / gp / gp_Parab2d.cxx
1 //File gp_Parab2d.cxx JCV 10/01/91
2
3 #define No_Standard_OutOfRange
4
5 #include <gp_Parab2d.ixx>
6
7 gp_Parab2d::gp_Parab2d (const gp_Ax22d& D, 
8                         const gp_Pnt2d& F)
9 {
10   gp_XY DCoord = D.XDirection().XY();
11   gp_XY GCoord = D.YDirection().XY();
12   gp_XY PCoord = D.Location().XY();
13   gp_XY MCoord = F.XY();
14   focalLength = DCoord.Dot ( MCoord.Subtracted (PCoord));
15   if (focalLength < 0) focalLength = - focalLength;
16   gp_XY N = GCoord;
17   N.Multiply (focalLength);
18   MCoord.Add (N);
19   N.Reverse();
20   pos = gp_Ax22d (gp_Pnt2d (MCoord), gp_Dir2d (N));
21   focalLength = focalLength / 2.0;
22 }
23
24 gp_Parab2d::gp_Parab2d (const gp_Ax2d& D, 
25                         const gp_Pnt2d& F,
26                         const Standard_Boolean Sense)
27 {
28   gp_XY DCoord = D.Direction().XY();
29   gp_XY PCoord = D.Location().XY();
30   gp_XY MCoord = F.XY();
31   focalLength = DCoord.Dot ( MCoord.Subtracted (PCoord));
32   if (focalLength < 0) focalLength = - focalLength;
33   gp_XY N;
34   if (Sense) N.SetCoord(DCoord.Y(), -DCoord.X());
35   else  N.SetCoord(-DCoord.Y(), DCoord.X());
36   N.Multiply (focalLength);
37   MCoord.Add (N);
38   N.Reverse();
39   pos = gp_Ax22d (gp_Pnt2d (MCoord), gp_Dir2d (N),Sense);
40   focalLength = focalLength / 2.0;
41 }
42
43 void gp_Parab2d::Coefficients
44 (Standard_Real& A, Standard_Real& B, Standard_Real& C,
45  Standard_Real& D, Standard_Real& E, Standard_Real& F) const
46 {
47   Standard_Real P = 2.0 * focalLength;
48   gp_Trsf2d T;
49   T.SetTransformation (pos.XAxis());
50   Standard_Real T11 = T.Value (1, 1);
51   Standard_Real T12 = T.Value (1, 2);
52   Standard_Real T13 = T.Value (1, 3);
53   Standard_Real T21 = T.Value (2, 1);
54   Standard_Real T22 = T.Value (2, 2);
55   Standard_Real T23 = T.Value (2, 3);
56   A = T21 * T21;
57   B = T22 * T22;
58   C = T21 * T22;
59   D = (T21 * T23) - (P * T11);
60   E = (T22 * T23) - (P * T12);
61   F = (T23 * T23) - (2.0 * P * T13);
62 }
63
64 void gp_Parab2d::Mirror (const gp_Pnt2d& P)
65 { pos.Mirror (P); }
66
67 gp_Parab2d gp_Parab2d::Mirrored (const gp_Pnt2d& P) const
68 {
69   gp_Parab2d Prb = *this;
70   Prb.pos.Mirror (P);
71   return Prb;     
72 }
73
74 void gp_Parab2d::Mirror (const gp_Ax2d& A)
75 { pos.Mirror (A); }
76
77 gp_Parab2d gp_Parab2d::Mirrored (const gp_Ax2d& A) const
78 {
79   gp_Parab2d Prb = *this;
80   Prb.pos.Mirror (A);
81   return Prb;     
82 }
83