1 -- Copyright (c) 1991-1999 Matra Datavision
2 -- Copyright (c) 1999-2012 OPEN CASCADE SAS
4 -- The content of this file is subject to the Open CASCADE Technology Public
5 -- License Version 6.5 (the "License"). You may not use the content of this file
6 -- except in compliance with the License. Please obtain a copy of the License
7 -- at http://www.opencascade.org and read it completely before using this file.
9 -- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
10 -- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 -- The Original Code and all software distributed under the License is
13 -- distributed on an "AS IS" basis, without warranty of any kind, and the
14 -- Initial Developer hereby disclaims all such warranties, including without
15 -- limitation, any warranties of merchantability, fitness for a particular
16 -- purpose or non-infringement. Please see the License for the specific terms
17 -- and conditions governing the rights and limitations under the License.
20 class Vec from gp inherits Storable
23 -- Defines a non-persistent vector in 3D space.
33 raises ConstructionError from Standard,
34 DomainError from Standard,
35 OutOfRange from Standard,
36 VectorWithNullMagnitude from gp
42 --- Purpose : Creates a zero vector.
45 Create (V : Dir) returns Vec;
47 --- Purpose : Creates a unitary vector from a direction V.
49 Create (Coord : XYZ) returns Vec;
51 --- Purpose : Creates a vector with a triplet of coordinates.
53 Create (Xv, Yv, Zv : Real) returns Vec;
55 --- Purpose : Creates a point with its three cartesian coordinates.
57 Create (P1, P2 : Pnt) returns Vec;
60 -- Creates a vector from two points. The length of the vector
61 -- is the distance between P1 and P2
63 SetCoord(me: in out; Index : Integer; Xi : Real)
65 --- Purpose : Changes the coordinate of range Index
66 -- Index = 1 => X is modified
67 -- Index = 2 => Y is modified
68 -- Index = 3 => Z is modified
70 --- Purpose : Raised if Index != {1, 2, 3}.
73 SetCoord (me : in out; Xv, Yv, Zv : Real) is static;
75 ---Purpose: For this vector, assigns
76 -- - the values Xv, Yv and Zv to its three coordinates.
78 SetX (me: in out; X : Real) is static;
79 ---Purpose: Assigns the given value to the X coordinate of this vector.
82 SetY (me: in out; Y : Real) is static;
83 ---Purpose: Assigns the given value to the X coordinate of this vector.
86 SetZ (me: in out; Z : Real) is static;
87 ---Purpose: Assigns the given value to the X coordinate of this vector.
90 SetXYZ (me: in out; Coord : XYZ) is static;
91 ---Purpose: Assigns the three coordinates of Coord to this vector.
94 Coord (me; Index : Integer) returns Real
97 -- Returns the coordinate of range Index :
98 -- Index = 1 => X is returned
99 -- Index = 2 => Y is returned
100 -- Index = 3 => Z is returned
102 --- Purpose : Raised if Index != {1, 2, 3}.
105 Coord (me; Xv, Yv, Zv : out Real) is static;
106 ---Purpose: For this vector returns its three coordinates Xv, Yv, and Zvinline
109 X (me) returns Real is static;
110 ---Purpose: For this vector, returns its X coordinate.
113 Y (me) returns Real is static;
114 ---Purpose: For this vector, returns its Y coordinate.
117 Z (me) returns Real is static;
118 ---Purpose: For this vector, returns its Z coordinate.
121 XYZ (me) returns XYZ is static;
122 ---Purpose: For this vector, returns
123 -- - its three coordinates as a number triple
125 ---C++: return const&
127 IsEqual (me; Other : Vec; LinearTolerance, AngularTolerance : Real)
130 -- Returns True if the two vectors have the same magnitude value
131 -- and the same direction. The precision values are LinearTolerance
132 -- for the magnitude and AngularTolerance for the direction.
135 IsNormal (me; Other : Vec; AngularTolerance : Real) returns Boolean
137 -- Returns True if abs(<me>.Angle(Other) - PI/2.) <= AngularTolerance
138 -- Raises VectorWithNullMagnitude if <me>.Magnitude() <= Resolution or
139 -- Other.Magnitude() <= Resolution from gp
141 raises VectorWithNullMagnitude
145 IsOpposite (me; Other : Vec; AngularTolerance : Real) returns Boolean
147 -- Returns True if PI - <me>.Angle(Other) <= AngularTolerance
148 -- Raises VectorWithNullMagnitude if <me>.Magnitude() <= Resolution or
149 -- Other.Magnitude() <= Resolution from gp
151 raises VectorWithNullMagnitude
155 IsParallel (me; Other : Vec; AngularTolerance : Real) returns Boolean
157 -- Returns True if Angle(<me>, Other) <= AngularTolerance or
158 -- PI - Angle(<me>, Other) <= AngularTolerance
159 -- This definition means that two parallel vectors cannot define
160 -- a plane but two vectors with opposite directions are considered
161 -- as parallel. Raises VectorWithNullMagnitude if <me>.Magnitude() <= Resolution or
162 -- Other.Magnitude() <= Resolution from gp
164 raises VectorWithNullMagnitude
168 Angle (me; Other : Vec) returns Real
170 -- Computes the angular value between <me> and <Other>
171 -- Returns the angle value between 0 and PI in radian.
172 -- Raises VectorWithNullMagnitude if <me>.Magnitude() <= Resolution from gp or
173 -- Other.Magnitude() <= Resolution because the angular value is
174 -- indefinite if one of the vectors has a null magnitude.
176 raises VectorWithNullMagnitude
181 AngleWithRef (me; Other , VRef : Vec) returns Real
183 --- Purpose : Computes the angle, in radians, between this vector and
184 -- vector Other. The result is a value between -Pi and Pi.
185 -- For this, VRef defines the positive sense of rotation: the
186 -- angular value is positive, if the cross product this ^ Other
187 -- has the same orientation as VRef relative to the plane
188 -- defined by the vectors this and Other. Otherwise, the
189 -- angular value is negative.
191 -- gp_VectorWithNullMagnitude if the magnitude of this
192 -- vector, the vector Other, or the vector VRef is less than or
193 -- equal to gp::Resolution().
194 -- Standard_DomainError if this vector, the vector Other,
195 -- and the vector VRef are coplanar, unless this vector and
196 -- the vector Other are parallel.
198 raises VectorWithNullMagnitude,
204 Magnitude (me) returns Real is static;
205 ---Purpose: Computes the magnitude of this vector.
208 SquareMagnitude (me) returns Real is static;
209 ---Purpose: Computes the square magnitude of this vector.
212 --- Purpose : Adds two vectors
214 Add (me : in out; Other : Vec) is static;
216 ---C++: alias operator +=
218 Added (me; Other : Vec) returns Vec is static;
220 ---C++: alias operator +
221 --- Purpose : Adds two vectors
222 --- Purpose : Subtracts two vectors
224 Subtract (me : in out; Right : Vec) is static;
226 ---C++: alias operator -=
228 Subtracted (me; Right : Vec) returns Vec is static;
230 ---C++: alias operator -
231 --- Purpose : Subtracts two vectors
232 --- Purpose : Multiplies a vector by a scalar
234 Multiply (me : in out; Scalar : Real) is static;
236 ---C++: alias operator *=
238 Multiplied (me; Scalar : Real) returns Vec is static;
240 ---C++: alias operator *
241 --- Purpose : Multiplies a vector by a scalar
242 --- Purpose : Divides a vector by a scalar
244 Divide (me : in out; Scalar : Real) is static;
246 ---C++: alias operator /=
248 Divided (me; Scalar : Real) returns Vec is static;
250 ---C++: alias operator /
251 --- Purpose : Divides a vector by a scalar
253 --- Purpose : computes the cross product between two vectors
255 Cross (me : in out; Right : Vec) is static;
257 ---C++: alias operator ^=
259 Crossed (me; Right : Vec) returns Vec is static;
260 --- Purpose : computes the cross product between two vectors
262 ---C++: alias operator ^
264 CrossMagnitude (me; Right : Vec) returns Real is static;
266 -- Computes the magnitude of the cross
267 -- product between <me> and Right.
268 -- Returns || <me> ^ Right ||
271 CrossSquareMagnitude (me; Right : Vec) returns Real is static;
273 -- Computes the square magnitude of
274 -- the cross product between <me> and Right.
275 -- Returns || <me> ^ Right ||**2
278 --- Purpose : Computes the triple vector product.
281 CrossCross (me : in out; V1, V2 : Vec) is static;
284 CrossCrossed (me; V1, V2 : Vec) returns Vec is static;
287 --- Purpose : Computes the triple vector product.
290 Dot (me; Other : Vec) returns Real is static;
292 ---C++: alias operator *
293 --- Purpose : computes the scalar product
295 DotCross (me; V1, V2 : Vec) returns Real is static;
297 --- Purpose : Computes the triple scalar product <me> * (V1 ^ V2).
300 --- Purpose : normalizes a vector
301 -- Raises an exception if the magnitude of the vector is
302 -- lower or equal to Resolution from gp.
304 Normalize (me : in out) raises ConstructionError is static;
307 Normalized (me) returns Vec raises ConstructionError is static;
308 --- Purpose : normalizes a vector
309 -- Raises an exception if the magnitude of the vector is
310 -- lower or equal to Resolution from gp.
313 --- Purpose : Reverses the direction of a vector
315 Reverse (me : in out) is static;
318 Reversed (me) returns Vec is static;
319 --- Purpose : Reverses the direction of a vector
321 ---C++: alias operator -
323 SetLinearForm (me : in out;
324 A1 : Real; V1 : Vec; A2 : Real; V2 : Vec;
325 A3 : Real; V3 : Vec; V4 : Vec)
328 -- <me> is setted to the following linear form :
329 -- A1 * V1 + A2 * V2 + A3 * V3 + V4
332 SetLinearForm (me : in out;
333 A1 : Real; V1 : Vec; A2 : Real; V2 : Vec; A3 : Real; V3 : Vec)
336 -- <me> is setted to the following linear form :
337 -- A1 * V1 + A2 * V2 + A3 * V3
340 SetLinearForm (me : in out;
341 A1 : Real; V1 : Vec; A2 : Real; V2 : Vec; V3 : Vec)
344 -- <me> is setted to the following linear form :
345 -- A1 * V1 + A2 * V2 + V3
348 SetLinearForm (me : in out; A1 : Real; V1 : Vec; A2 : Real; V2 : Vec)
351 -- <me> is setted to the following linear form :
355 SetLinearForm (me : in out; A1 : Real; V1, V2 : Vec)
358 -- <me> is setted to the following linear form : A1 * V1 + V2
361 SetLinearForm (me : in out; V1, V2 : Vec)
364 -- <me> is setted to the following linear form : V1 + V2
367 Mirror (me : in out; V : Vec) is static;
369 Mirrored (me; V : Vec) returns Vec is static;
371 -- Performs the symmetrical transformation of a vector
372 -- with respect to the vector V which is the center of
375 Mirror (me : in out; A1 : Ax1) is static;
377 Mirrored (me; A1 : Ax1) returns Vec is static;
379 -- Performs the symmetrical transformation of a vector
380 -- with respect to an axis placement which is the axis
383 Mirror (me : in out; A2 : Ax2) is static;
385 Mirrored (me; A2 : Ax2) returns Vec is static;
387 -- Performs the symmetrical transformation of a vector
388 -- with respect to a plane. The axis placement A2 locates
389 -- the plane of the symmetry : (Location, XDirection, YDirection).
392 Rotate (me : in out; A1 : Ax1; Ang : Real) is static;
395 Rotated (me; A1 : Ax1; Ang : Real) returns Vec is static;
397 -- Rotates a vector. A1 is the axis of the rotation.
398 -- Ang is the angular value of the rotation in radians.
401 Scale (me : in out; S : Real) is static;
404 Scaled (me; S : Real) returns Vec is static;
405 --- Purpose : Scales a vector. S is the scaling value.
407 --- Purpose : Transforms a vector with the transformation T.
409 Transform (me : in out; T : Trsf) is static;
411 Transformed (me; T : Trsf) returns Vec is static;
413 --- Purpose : Transforms a vector with the transformation T.