b311480e |
1 | // Copyright (c) 1996-1999 Matra Datavision |
973c2be1 |
2 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
3 | // |
973c2be1 |
4 | // This file is part of Open CASCADE Technology software library. |
b311480e |
5 | // |
d5f74e42 |
6 | // This library is free software; you can redistribute it and/or modify it under |
7 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
8 | // by the Free Software Foundation, with special exception defined in the file |
9 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
10 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
11 | // |
973c2be1 |
12 | // Alternatively, this file may be used under the terms of Open CASCADE |
13 | // commercial license or contractual agreement. |
7fd59977 |
14 | |
0bd575a7 |
15 | inline gp_Ax22d::gp_Ax22d() |
16 | : |
17 | vydir(0.,1.) |
18 | // vxdir(1.,0.) use default ctor of gp_Dir2d, as it creates the same dir(1, 0) |
7fd59977 |
19 | {} |
20 | |
21 | inline gp_Ax22d::gp_Ax22d(const gp_Pnt2d& P , |
22 | const gp_Dir2d& Vx, |
23 | const gp_Dir2d& Vy) : |
24 | point(P), |
25 | vydir(Vy), |
26 | vxdir(Vx) |
27 | { |
28 | Standard_Real value = Vx.Crossed(Vy); |
29 | if (value >= 0.0) vydir.SetCoord(-vxdir.Y(), vxdir.X()); |
30 | else vydir.SetCoord( vxdir.Y(),-vxdir.X()); |
31 | } |
32 | |
33 | inline gp_Ax22d::gp_Ax22d(const gp_Pnt2d& P , |
34 | const gp_Dir2d& Vx , |
35 | const Standard_Boolean Sense) : |
36 | point(P), |
37 | vxdir(Vx) |
38 | { |
39 | if (Sense) vydir.SetCoord(-Vx.Y(), Vx.X()); |
40 | else vydir.SetCoord( Vx.Y(),-Vx.X()); |
41 | } |
42 | |
43 | inline gp_Ax22d::gp_Ax22d(const gp_Ax2d& A , |
44 | const Standard_Boolean Sense) : |
45 | point(A.Location()), |
46 | vxdir(A.Direction()) |
47 | { |
48 | if (Sense) vydir.SetCoord(-vxdir.Y(), vxdir.X()); |
49 | else vydir.SetCoord( vxdir.Y(),-vxdir.X()); |
50 | } |
51 | |
52 | inline void gp_Ax22d::SetAxis(const gp_Ax22d& A1) |
53 | { |
54 | point = A1.Location(); |
55 | vxdir = A1.XDirection(); |
56 | vydir = A1.YDirection(); |
57 | } |
58 | |
59 | inline void gp_Ax22d::SetXAxis (const gp_Ax2d& A1) |
60 | { |
61 | Standard_Boolean sign = (vxdir.Crossed(vydir)) >= 0.0; |
62 | point = A1.Location (); |
63 | vxdir = A1.Direction(); |
64 | if (sign) vydir.SetCoord(-vxdir.Y(), vxdir.X()); |
65 | else vydir.SetCoord( vxdir.Y(),-vxdir.X()); |
66 | } |
67 | |
68 | inline void gp_Ax22d::SetYAxis (const gp_Ax2d& A1) |
69 | { |
70 | Standard_Boolean sign = (vxdir.Crossed(vydir)) >= 0.0; |
71 | point = A1.Location (); |
72 | vydir = A1.Direction(); |
73 | if (sign) vxdir.SetCoord( vydir.Y(),-vydir.X()); |
74 | else vxdir.SetCoord(-vydir.Y(), vydir.X()); |
75 | } |
76 | |
77 | inline void gp_Ax22d::SetLocation (const gp_Pnt2d& P) |
78 | { point = P; } |
79 | |
80 | inline void gp_Ax22d::SetXDirection (const gp_Dir2d& Vx) |
81 | { |
82 | Standard_Boolean sign = (vxdir.Crossed(vydir)) >= 0.0; |
83 | vxdir = Vx; |
84 | if (sign) vydir.SetCoord(-Vx.Y(), Vx.X()); |
85 | else vydir.SetCoord( Vx.Y(),-Vx.X()); |
86 | } |
87 | |
88 | inline void gp_Ax22d::SetYDirection (const gp_Dir2d& Vy) |
89 | { |
90 | Standard_Boolean sign = (vxdir.Crossed(vydir)) >= 0.0; |
91 | vydir = Vy; |
92 | if (sign) vxdir.SetCoord( Vy.Y(),-Vy.X()); |
93 | else vxdir.SetCoord(-Vy.Y(), Vy.X()); |
94 | } |
95 | |
96 | inline gp_Ax2d gp_Ax22d::XAxis () const |
97 | { return gp_Ax2d(point, vxdir); } |
98 | |
99 | inline gp_Ax2d gp_Ax22d::YAxis () const |
100 | { return gp_Ax2d(point, vydir); } |
101 | |
102 | inline const gp_Pnt2d& gp_Ax22d::Location () const |
103 | { return point; } |
104 | |
105 | inline const gp_Dir2d& gp_Ax22d::XDirection () const |
106 | { return vxdir; } |
107 | |
108 | inline const gp_Dir2d& gp_Ax22d::YDirection () const |
109 | { return vydir; } |
110 | |
111 | inline void gp_Ax22d::Rotate (const gp_Pnt2d& P, |
112 | const Standard_Real Ang) |
113 | { |
114 | gp_Pnt2d Temp = point; |
115 | Temp.Rotate (P,Ang); |
116 | point = Temp; |
117 | vxdir.Rotate (Ang); |
118 | vydir.Rotate (Ang); |
119 | } |
120 | |
121 | inline gp_Ax22d gp_Ax22d::Rotated(const gp_Pnt2d& P, |
122 | const Standard_Real Ang) const |
123 | { |
124 | gp_Ax22d Temp = *this; |
125 | Temp.Rotate (P,Ang); |
126 | return Temp; |
127 | } |
128 | |
129 | inline void gp_Ax22d::Scale (const gp_Pnt2d& P, |
130 | const Standard_Real S) |
131 | { |
132 | gp_Pnt2d Temp = point; |
133 | Temp.Scale (P, S); |
134 | point = Temp; |
135 | if (S < 0.0) { |
136 | vxdir.Reverse (); |
137 | vydir.Reverse (); |
138 | } |
139 | } |
140 | |
141 | inline gp_Ax22d gp_Ax22d::Scaled(const gp_Pnt2d& P, |
142 | const Standard_Real S) const |
143 | { |
144 | gp_Ax22d Temp = *this; |
145 | Temp.Scale (P, S); |
146 | return Temp; |
147 | } |
148 | |
149 | inline void gp_Ax22d::Transform (const gp_Trsf2d& T) |
150 | { |
151 | gp_Pnt2d Temp = point; |
152 | Temp.Transform (T); |
153 | point = Temp; |
154 | vxdir.Transform (T); |
155 | vydir.Transform (T); |
156 | } |
157 | |
158 | inline gp_Ax22d gp_Ax22d::Transformed(const gp_Trsf2d& T) const |
159 | { |
160 | gp_Ax22d Temp = *this; |
161 | Temp.Transform (T); |
162 | return Temp; |
163 | } |
164 | |
165 | inline void gp_Ax22d::Translate (const gp_Vec2d& V) |
166 | { point.Translate (V); } |
167 | |
168 | inline gp_Ax22d gp_Ax22d::Translated(const gp_Vec2d& V) const |
169 | { |
170 | gp_Ax22d Temp = *this; |
171 | Temp.Translate (V); |
172 | return Temp; |
173 | } |
174 | inline void gp_Ax22d::Translate (const gp_Pnt2d& P1,const gp_Pnt2d& P2) |
175 | { point.Translate (P1, P2); } |
176 | |
177 | inline gp_Ax22d gp_Ax22d::Translated (const gp_Pnt2d& P1, |
178 | const gp_Pnt2d& P2) const |
179 | { |
180 | gp_Ax22d Temp = *this; |
181 | Temp.Translate (P1, P2); |
182 | return Temp; |
183 | } |
184 | |