Integration of OCCT 6.5.0 from SVN
[occt.git] / src / gp / gp_Ax2.cxx
1 // File vgeom_Ax2.cxx , JCV 30/08/90
2 // JCV 1/10/90 Changement de nom du package vgeom -> gp
3 // JCV 12/12/90 Modif mineur suite a la premiere revue de projet
4 // LPA, JCV  07/92 passage sur C1.
5 // JCV 07/92 Introduction de la method Dump 
6
7 #define No_Standard_OutOfRange
8
9 #include <gp_Ax2.ixx>
10 #include <gp.hxx>
11
12 gp_Ax2::gp_Ax2 (const gp_Pnt& P, const gp_Dir& V) :
13 axis(P,V)
14 {
15   Standard_Real A = V.X();
16   Standard_Real B = V.Y();
17   Standard_Real C = V.Z();
18   Standard_Real Aabs = A;
19   if (Aabs < 0) Aabs = - Aabs;
20   Standard_Real Babs = B;
21   if (Babs < 0) Babs = - Babs;
22   Standard_Real Cabs = C;
23   if (Cabs < 0) Cabs = - Cabs;
24   gp_Dir D;
25   
26   //  pour determiner l axe X :
27   //  on dit que le produit scalaire Vx.V = 0. 
28   //  et on recherche le max(A,B,C) pour faire la division.
29   //  l'une des coordonnees du vecteur est nulle. 
30   
31   if      ( Babs <= Aabs && Babs <= Cabs) {
32     if (Aabs > Cabs) D.SetCoord(-C,0., A);
33     else             D.SetCoord( C,0.,-A);
34   }
35   else if ( Aabs <= Babs && Aabs <= Cabs) {
36     if (Babs > Cabs) D.SetCoord(0.,-C, B);
37     else             D.SetCoord(0., C,-B);
38   }
39   else {
40     if (Aabs > Babs) D.SetCoord(-B, A,0.);
41     else             D.SetCoord( B,-A,0.);
42   }
43   SetXDirection(D);
44 }
45
46 void gp_Ax2::Mirror (const gp_Pnt& P)
47 {
48   gp_Pnt Temp = axis.Location();
49   Temp.Mirror (P);
50   axis.SetLocation (Temp);
51   vxdir.Reverse ();
52   vydir.Reverse ();
53 }
54
55 gp_Ax2 gp_Ax2::Mirrored(const gp_Pnt& P) const
56 {
57   gp_Ax2 Temp = *this;
58   Temp.Mirror (P);
59   return Temp;
60 }
61
62 void gp_Ax2::Mirror (const gp_Ax1& A1)
63 {
64   vydir.Mirror (A1);
65   vxdir.Mirror (A1);
66   gp_Pnt Temp = axis.Location();
67   Temp.Mirror (A1);
68   axis.SetLocation (Temp);
69   axis.SetDirection (vxdir.Crossed (vydir));
70 }
71
72 gp_Ax2 gp_Ax2::Mirrored(const gp_Ax1& A1) const
73 {
74   gp_Ax2 Temp = *this;
75   Temp.Mirror (A1);
76   return Temp;
77 }
78
79 void gp_Ax2::Mirror (const gp_Ax2& A2)
80 {
81   vydir.Mirror (A2);
82   vxdir.Mirror (A2);
83   gp_Pnt Temp = axis.Location();
84   Temp.Mirror (A2);
85   axis.SetLocation (Temp);
86   axis.SetDirection (vxdir.Crossed (vydir));
87 }
88
89 gp_Ax2 gp_Ax2::Mirrored(const gp_Ax2& A2) const 
90 {
91   gp_Ax2 Temp = *this;
92   Temp.Mirror (A2);
93   return Temp;
94 }
95