b311480e |
1 | // Created on: 1993-03-10 |
2 | // Created by: JCV |
3 | // Copyright (c) 1993-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. |
7fd59977 |
16 | |
17 | #include <Geom_VectorWithMagnitude.ixx> |
18 | |
19 | typedef Geom_VectorWithMagnitude VectorWithMagnitude; |
7fd59977 |
20 | typedef Geom_Vector Vector; |
7fd59977 |
21 | typedef gp_Ax1 Ax1; |
22 | typedef gp_Ax2 Ax2; |
23 | typedef gp_Pnt Pnt; |
24 | typedef gp_Trsf Trsf; |
25 | |
7fd59977 |
26 | //======================================================================= |
27 | //function : Geom_VectorWithMagnitude |
28 | //purpose : |
29 | //======================================================================= |
30 | |
31 | Geom_VectorWithMagnitude::Geom_VectorWithMagnitude (const gp_Vec& V) |
32 | { gpVec = V; } |
33 | |
34 | |
35 | //======================================================================= |
36 | //function : Geom_VectorWithMagnitude |
37 | //purpose : |
38 | //======================================================================= |
39 | |
40 | Geom_VectorWithMagnitude::Geom_VectorWithMagnitude ( |
41 | const Standard_Real X, const Standard_Real Y, const Standard_Real Z) { gpVec = gp_Vec (X, Y, Z); } |
42 | |
43 | |
44 | //======================================================================= |
45 | //function : Geom_VectorWithMagnitude |
46 | //purpose : |
47 | //======================================================================= |
48 | |
49 | Geom_VectorWithMagnitude::Geom_VectorWithMagnitude ( |
50 | const Pnt& P1, const Pnt& P2) { gpVec = gp_Vec (P1, P2); } |
51 | |
52 | |
53 | //======================================================================= |
54 | //function : Copy |
55 | //purpose : |
56 | //======================================================================= |
57 | |
58 | Handle(Geom_Geometry) Geom_VectorWithMagnitude::Copy() const { |
59 | |
c04c30b3 |
60 | Handle(Geom_VectorWithMagnitude) V; |
7fd59977 |
61 | V = new VectorWithMagnitude (gpVec); |
62 | return V; |
63 | } |
64 | |
65 | |
66 | //======================================================================= |
67 | //function : SetCoord |
68 | //purpose : |
69 | //======================================================================= |
70 | |
71 | void Geom_VectorWithMagnitude::SetCoord ( |
72 | const Standard_Real X, const Standard_Real Y, const Standard_Real Z) { gpVec = gp_Vec (X, Y ,Z); } |
73 | |
74 | //======================================================================= |
75 | //function : SetVec |
76 | //purpose : |
77 | //======================================================================= |
78 | |
79 | void Geom_VectorWithMagnitude::SetVec (const gp_Vec& V) { gpVec = V; } |
80 | |
81 | //======================================================================= |
82 | //function : SetX |
83 | //purpose : |
84 | //======================================================================= |
85 | |
86 | void Geom_VectorWithMagnitude::SetX (const Standard_Real X) { gpVec.SetX (X); } |
87 | |
88 | //======================================================================= |
89 | //function : SetY |
90 | //purpose : |
91 | //======================================================================= |
92 | |
93 | void Geom_VectorWithMagnitude::SetY (const Standard_Real Y) { gpVec.SetY (Y); } |
94 | |
95 | //======================================================================= |
96 | //function : SetZ |
97 | //purpose : |
98 | //======================================================================= |
99 | |
100 | void Geom_VectorWithMagnitude::SetZ (const Standard_Real Z) { gpVec.SetZ (Z); } |
101 | |
102 | //======================================================================= |
103 | //function : Magnitude |
104 | //purpose : |
105 | //======================================================================= |
106 | |
107 | Standard_Real Geom_VectorWithMagnitude::Magnitude () const {return gpVec.Magnitude ();} |
108 | |
109 | //======================================================================= |
110 | //function : SquareMagnitude |
111 | //purpose : |
112 | //======================================================================= |
113 | |
114 | Standard_Real Geom_VectorWithMagnitude::SquareMagnitude () const { |
115 | |
116 | return gpVec.SquareMagnitude (); |
117 | } |
118 | |
119 | |
120 | //======================================================================= |
121 | //function : Add |
122 | //purpose : |
123 | //======================================================================= |
124 | |
c04c30b3 |
125 | void Geom_VectorWithMagnitude::Add (const Handle(Geom_Vector)& Other) { |
7fd59977 |
126 | |
127 | gpVec.Add (Other->Vec()); |
128 | } |
129 | |
130 | |
131 | //======================================================================= |
132 | //function : Added |
133 | //purpose : |
134 | //======================================================================= |
135 | |
c04c30b3 |
136 | Handle(Geom_VectorWithMagnitude) Geom_VectorWithMagnitude::Added ( |
137 | const Handle(Geom_Vector)& Other) const { |
7fd59977 |
138 | |
139 | gp_Vec V1 = gpVec; |
140 | V1.Add (Other->Vec()); |
141 | return new VectorWithMagnitude (V1); |
142 | } |
143 | |
144 | |
145 | //======================================================================= |
146 | //function : Cross |
147 | //purpose : |
148 | //======================================================================= |
149 | |
c04c30b3 |
150 | void Geom_VectorWithMagnitude::Cross (const Handle(Geom_Vector)& Other) { |
7fd59977 |
151 | |
152 | gpVec.Cross (Other->Vec()); |
153 | } |
154 | |
155 | |
156 | |
157 | //======================================================================= |
158 | //function : Crossed |
159 | //purpose : |
160 | //======================================================================= |
161 | |
c04c30b3 |
162 | Handle(Geom_Vector) Geom_VectorWithMagnitude::Crossed ( |
163 | const Handle(Geom_Vector)& Other) const { |
7fd59977 |
164 | |
165 | gp_Vec V (gpVec); |
166 | V.Cross (Other->Vec()); |
167 | return new VectorWithMagnitude (V); |
168 | } |
169 | |
170 | |
171 | //======================================================================= |
172 | //function : CrossCross |
173 | //purpose : |
174 | //======================================================================= |
175 | |
176 | void Geom_VectorWithMagnitude::CrossCross ( |
c04c30b3 |
177 | const Handle(Geom_Vector)& V1, const Handle(Geom_Vector)& V2) { |
7fd59977 |
178 | |
179 | gpVec.CrossCross (V1->Vec(), V2->Vec()); |
180 | } |
181 | |
182 | |
183 | //======================================================================= |
184 | //function : CrossCrossed |
185 | //purpose : |
186 | //======================================================================= |
187 | |
c04c30b3 |
188 | Handle(Geom_Vector) Geom_VectorWithMagnitude::CrossCrossed ( |
189 | const Handle(Geom_Vector)& V1, const Handle(Geom_Vector)& V2) const { |
7fd59977 |
190 | |
191 | gp_Vec V (gpVec); |
192 | V.CrossCross (V1->Vec(), V2->Vec()); |
193 | return new VectorWithMagnitude (V); |
194 | } |
195 | |
196 | |
197 | //======================================================================= |
198 | //function : Divide |
199 | //purpose : |
200 | //======================================================================= |
201 | |
202 | void Geom_VectorWithMagnitude::Divide (const Standard_Real Scalar) { |
203 | |
204 | gpVec.Divide (Scalar); |
205 | } |
206 | |
207 | |
208 | //======================================================================= |
209 | //function : Divided |
210 | //purpose : |
211 | //======================================================================= |
212 | |
c04c30b3 |
213 | Handle(Geom_VectorWithMagnitude) Geom_VectorWithMagnitude::Divided ( |
7fd59977 |
214 | const Standard_Real Scalar) const { |
215 | |
216 | gp_Vec V (gpVec); |
217 | V.Divide (Scalar); |
218 | return new VectorWithMagnitude (V); |
219 | } |
220 | |
221 | |
222 | //======================================================================= |
223 | //function : Multiplied |
224 | //purpose : |
225 | //======================================================================= |
226 | |
c04c30b3 |
227 | Handle(Geom_VectorWithMagnitude) Geom_VectorWithMagnitude::Multiplied ( |
7fd59977 |
228 | const Standard_Real Scalar) const { |
229 | |
230 | gp_Vec V (gpVec); |
231 | V.Multiply (Scalar); |
232 | return new VectorWithMagnitude (V); |
233 | } |
234 | |
235 | |
236 | //======================================================================= |
237 | //function : Multiply |
238 | //purpose : |
239 | //======================================================================= |
240 | |
241 | void Geom_VectorWithMagnitude::Multiply (const Standard_Real Scalar) { |
242 | |
243 | gpVec.Multiply (Scalar); |
244 | } |
245 | |
246 | |
247 | //======================================================================= |
248 | //function : Normalize |
249 | //purpose : |
250 | //======================================================================= |
251 | |
252 | void Geom_VectorWithMagnitude::Normalize () { gpVec.Normalize (); } |
253 | |
254 | |
255 | //======================================================================= |
256 | //function : Normalized |
257 | //purpose : |
258 | //======================================================================= |
259 | |
c04c30b3 |
260 | Handle(Geom_VectorWithMagnitude) Geom_VectorWithMagnitude::Normalized () const { |
7fd59977 |
261 | |
262 | gp_Vec V (gpVec); |
263 | V.Normalize (); |
264 | return new VectorWithMagnitude (V); |
265 | } |
266 | |
267 | |
268 | //======================================================================= |
269 | //function : Subtract |
270 | //purpose : |
271 | //======================================================================= |
272 | |
c04c30b3 |
273 | void Geom_VectorWithMagnitude::Subtract (const Handle(Geom_Vector)& Other) { |
7fd59977 |
274 | |
275 | gpVec.Subtract (Other->Vec()); |
276 | } |
277 | |
278 | |
279 | //======================================================================= |
280 | //function : Subtracted |
281 | //purpose : |
282 | //======================================================================= |
283 | |
c04c30b3 |
284 | Handle(Geom_VectorWithMagnitude) Geom_VectorWithMagnitude::Subtracted ( |
285 | const Handle(Geom_Vector)& Other) const { |
7fd59977 |
286 | |
287 | gp_Vec V (gpVec); |
288 | V.Subtract (Other->Vec()); |
289 | return new VectorWithMagnitude (V); |
290 | } |
291 | |
292 | |
293 | |
294 | //======================================================================= |
295 | //function : Transform |
296 | //purpose : |
297 | //======================================================================= |
298 | |
299 | void Geom_VectorWithMagnitude::Transform (const Trsf& T) { |
300 | |
301 | gpVec.Transform (T); |
302 | } |