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 Vec2d from gp inherits Storable
23 -- Defines a non-persistent vector in 2D space.
31 raises ConstructionError from Standard,
32 OutOfRange from Standard,
33 VectorWithNullMagnitude from gp
39 --- Purpose : Creates a zero vector.
41 Create (V : Dir2d) returns Vec2d;
43 --- Purpose : Creates a unitary vector from a direction V.
45 Create (Coord : XY) returns Vec2d;
47 --- Purpose : Creates a vector with a doublet of coordinates.
49 Create (Xv, Yv : Real) returns Vec2d;
51 --- Purpose : Creates a point with its two cartesian coordinates.
53 Create (P1, P2 : Pnt2d) returns Vec2d;
56 -- Creates a vector from two points. The length of the vector
57 -- is the distance between P1 and P2
59 SetCoord(me: in out; Index : Integer; Xi : Real)
61 --- Purpose : Changes the coordinate of range Index
62 -- Index = 1 => X is modified
63 -- Index = 2 => Y is modified
64 -- Raises OutOfRange if Index != {1, 2}.
68 SetCoord (me : in out; Xv, Yv : Real) is static;
69 ---Purpose: For this vector, assigns
70 -- the values Xv and Yv to its two coordinates
72 SetX (me: in out; X : Real) is static;
73 ---Purpose : Assigns the given value to the X coordinate of this vector.
75 SetY (me: in out; Y : Real) is static;
76 ---Purpose : Assigns the given value to the Y coordinate of this vector.
78 SetXY (me: in out; Coord : XY) is static;
79 ---Purpose: Assigns the two coordinates of Coord to this vector.
81 Coord (me; Index : Integer) returns Real
84 -- Returns the coordinate of range Index :
85 -- Index = 1 => X is returned
86 -- Index = 2 => Y is returned
88 --- Purpose : Raised if Index != {1, 2}.
92 Coord (me; Xv, Yv : out Real) is static;
93 ---Purpose: For this vector, returns its two coordinates Xv and Yv
96 X (me) returns Real is static;
97 ---Purpose: For this vector, returns its X coordinate.
100 Y (me) returns Real is static;
101 ---Purpose: For this vector, returns its Y coordinate.
104 XY (me) returns XY is static;
105 ---Purpose: For this vector, returns its two coordinates as a number pair
107 ---C++: return const&
109 IsEqual (me; Other : Vec2d; LinearTolerance, AngularTolerance : Real)
113 -- Returns True if the two vectors have the same magnitude value
114 -- and the same direction. The precision values are LinearTolerance
115 -- for the magnitude and AngularTolerance for the direction.
117 IsNormal (me; Other : Vec2d; AngularTolerance : Real)
121 -- Returns True if abs(Abs(<me>.Angle(Other)) - PI/2.)
122 -- <= AngularTolerance
123 -- Raises VectorWithNullMagnitude if <me>.Magnitude() <= Resolution or
124 -- Other.Magnitude() <= Resolution from gp.
125 raises VectorWithNullMagnitude
129 IsOpposite (me; Other : Vec2d; AngularTolerance : Real)
133 -- Returns True if PI - Abs(<me>.Angle(Other)) <= AngularTolerance
134 -- Raises VectorWithNullMagnitude if <me>.Magnitude() <= Resolution or
135 -- Other.Magnitude() <= Resolution from gp.
136 raises VectorWithNullMagnitude
140 IsParallel (me; Other : Vec2d; AngularTolerance : Real)
144 -- Returns true if Abs(Angle(<me>, Other)) <= AngularTolerance or
145 -- PI - Abs(Angle(<me>, Other)) <= AngularTolerance
146 -- Two vectors with opposite directions are considered as parallel.
147 -- Raises VectorWithNullMagnitude if <me>.Magnitude() <= Resolution or
148 -- Other.Magnitude() <= Resolution from gp
149 raises VectorWithNullMagnitude
153 Angle (me; Other : Vec2d) returns Real
155 -- Computes the angular value between <me> and <Other>
156 -- returns the angle value between -PI and PI in radian.
157 -- The orientation is from <me> to Other. The positive sense is the
158 -- trigonometric sense.
159 -- Raises VectorWithNullMagnitude if <me>.Magnitude() <= Resolution from gp or
160 -- Other.Magnitude() <= Resolution because the angular value is
161 -- indefinite if one of the vectors has a null magnitude.
162 raises VectorWithNullMagnitude
166 Magnitude (me) returns Real is static;
167 ---Purpose: Computes the magnitude of this vector.
170 SquareMagnitude (me) returns Real is static;
171 ---Purpose: Computes the square magnitude of this vector.
174 Add (me : in out; Other : Vec2d) is static;
176 ---C++: alias operator +=
178 Added (me; Other : Vec2d) returns Vec2d is static;
180 ---C++: alias operator +
181 --- Purpose : Adds two vectors
183 Crossed (me; Right : Vec2d) returns Real is static;
185 --- Purpose : Computes the crossing product between two vectors
186 ---C++: alias operator ^
188 CrossMagnitude (me; Right : Vec2d) returns Real is static;
191 -- Computes the magnitude of the cross product between <me> and
192 -- Right. Returns || <me> ^ Right ||
194 CrossSquareMagnitude (me; Right : Vec2d) returns Real is static;
197 -- Computes the square magnitude of the cross product between <me> and
198 -- Right. Returns || <me> ^ Right ||**2
200 Divide (me : in out; Scalar : Real) is static;
202 ---C++: alias operator /=
204 Divided (me; Scalar : Real) returns Vec2d is static;
206 ---C++: alias operator /
208 --- Purpose : divides a vector by a scalar
210 Dot (me; Other : Vec2d) returns Real is static;
212 --- Purpose : Computes the scalar product
213 ---C++: alias operator *
215 Multiply (me : in out; Scalar : Real) is static;
217 ---C++: alias operator *=
219 Multiplied (me; Scalar : Real) returns Vec2d is static;
221 ---C++: alias operator *
222 --- Purpose : Normalizes a vector
223 -- Raises an exception if the magnitude of the vector is
224 -- lower or equal to Resolution from package gp.
226 Normalize (me : in out) raises ConstructionError is static;
229 Normalized (me) returns Vec2d raises ConstructionError is static;
231 --- Purpose : Normalizes a vector
232 -- Raises an exception if the magnitude of the vector is
233 -- lower or equal to Resolution from package gp.
235 --- Purpose : Reverses the direction of a vector
237 Reverse (me : in out) is static;
240 Reversed (me) returns Vec2d is static;
242 ---C++: alias operator -
243 --- Purpose : Reverses the direction of a vector
245 --- Purpose : Subtracts two vectors
247 Subtract (me : in out; Right : Vec2d) is static;
249 ---C++: alias operator -=
251 Subtracted (me; Right : Vec2d) returns Vec2d is static;
253 ---C++: alias operator -
254 --- Purpose : Subtracts two vectors
256 SetLinearForm (me : in out;
257 A1 : Real; V1 : Vec2d; A2 : Real; V2 : Vec2d; V3 : Vec2d)
260 -- <me> is setted to the following linear form :
261 -- A1 * V1 + A2 * V2 + V3
264 SetLinearForm (me : in out; A1 : Real; V1 : Vec2d; A2 : Real; V2 : Vec2d)
267 -- <me> is setted to the following linear form : A1 * V1 + A2 * V2
270 SetLinearForm (me : in out; A1 : Real; V1, V2 : Vec2d) is static;
272 -- <me> is setted to the following linear form : A1 * V1 + V2
275 SetLinearForm (me : in out; Left, Right : Vec2d) is static;
277 -- <me> is setted to the following linear form : Left + Right
282 -- Performs the symmetrical transformation of a vector
283 -- with respect to the vector V which is the center of
286 Mirror (me : in out; V : Vec2d) is static;
288 Mirrored (me; V : Vec2d) returns Vec2d is static;
291 -- Performs the symmetrical transformation of a vector
292 -- with respect to the vector V which is the center of
295 -- Performs the symmetrical transformation of a vector
296 -- with respect to an axis placement which is the axis
299 Mirror (me : in out; A1 : Ax2d) is static;
301 Mirrored (me; A1 : Ax2d) returns Vec2d is static;
303 -- Performs the symmetrical transformation of a vector
304 -- with respect to an axis placement which is the axis
307 Rotate (me : in out; Ang : Real) is static;
310 Rotated (me; Ang : Real) returns Vec2d is static;
313 -- Rotates a vector. Ang is the angular value of the
314 -- rotation in radians.
316 Scale (me : in out; S : Real) is static;
319 Scaled (me; S : Real) returns Vec2d is static;
321 --- Purpose : Scales a vector. S is the scaling value.
324 Transform (me : in out; T : Trsf2d) is static;
326 Transformed (me; T : Trsf2d) returns Vec2d is static;
328 --- Purpose : Transforms a vector with a Trsf from gp.