1 -- Created on: 1993-03-24
3 -- Copyright (c) 1993-1999 Matra Datavision
4 -- Copyright (c) 1999-2012 OPEN CASCADE SAS
6 -- The content of this file is subject to the Open CASCADE Technology Public
7 -- License Version 6.5 (the "License"). You may not use the content of this file
8 -- except in compliance with the License. Please obtain a copy of the License
9 -- at http://www.opencascade.org and read it completely before using this file.
11 -- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 -- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 -- The Original Code and all software distributed under the License is
15 -- distributed on an "AS IS" basis, without warranty of any kind, and the
16 -- Initial Developer hereby disclaims all such warranties, including without
17 -- limitation, any warranties of merchantability, fitness for a particular
18 -- purpose or non-infringement. Please see the License for the specific terms
19 -- and conditions governing the rights and limitations under the License.
25 class VectorWithMagnitude from Geom2d inherits Vector from Geom2d
28 -- Defines a vector with magnitude.
29 -- A vector with magnitude can have a zero length.
36 raises ConstructionError from Standard
41 Create (V : Vec2d) returns mutable VectorWithMagnitude;
42 --- Purpose : Creates a persistent copy of V.
45 Create (X, Y : Real) returns mutable VectorWithMagnitude;
46 --- Purpose : Creates a vector with two cartesian coordinates.
49 Create (P1, P2 : Pnt2d) returns mutable VectorWithMagnitude;
51 -- Creates a vector from the point P1 to the point P2.
52 -- The magnitude of the vector is the distance between P1 and P2
56 SetCoord (me : mutable; X, Y : Real);
57 --- Purpose : Set <me> to X, Y coordinates.
60 SetVec2d (me : mutable; V : Vec2d);
61 -- Purpose : Set <me> to V.X(), V.Y() coordinates.
64 SetX (me : mutable; X : Real);
65 --- Purpose : Changes the X coordinate of <me>.
68 SetY (me : mutable; Y : Real);
69 --- Purpose : Changes the Y coordinate of <me>
72 Magnitude (me) returns Real;
73 --- Purpose : Returns the magnitude of <me>.
76 SquareMagnitude (me) returns Real;
77 --- Purpose : Returns the square magnitude of <me>.
80 Add (me : mutable; Other : Vector);
82 -- Adds the Vector Other to <me>.
83 ---C++: alias operator +=
86 Added (me; Other : Vector) returns mutable VectorWithMagnitude
88 -- Adds the vector Other to <me>.
89 ---C++: alias operator +
93 Crossed (me; Other : Vector) returns Real;
95 -- Computes the cross product between <me> and Other
96 -- <me> ^ Other. A new vector is returned.
97 ---C++: alias operator ^
100 Divide (me : mutable; Scalar : Real);
101 --- Purpose : Divides <me> by a scalar.
102 ---C++: alias operator /=
105 Divided (me; Scalar : Real) returns mutable VectorWithMagnitude
107 -- Divides <me> by a scalar. A new vector is returned.
108 ---C++: alias operator /
112 Multiplied (me; Scalar : Real) returns mutable VectorWithMagnitude
114 -- Computes the product of the vector <me> by a scalar.
115 -- A new vector is returned.
117 -- -C++: alias operator *
118 -- Collision with same operator defined for the class Vector!
122 Multiply (me : mutable; Scalar : Real);
124 -- Computes the product of the vector <me> by a scalar.
125 ---C++: alias operator *=
128 Normalize (me : mutable)
129 --- Purpose : Normalizes <me>.
130 raises ConstructionError;
132 -- Raised if the magnitude of the vector is lower or equal to
133 -- Resolution from package gp.
136 Normalized (me) returns mutable VectorWithMagnitude
137 --- Purpose : Returns a copy of <me> Normalized.
138 raises ConstructionError
140 -- Raised if the magnitude of the vector is lower or equal to
141 -- Resolution from package gp.
145 Subtract (me : mutable; Other : Vector);
146 --- Purpose : Subtracts the Vector Other to <me>.
147 ---C++: alias operator -=
150 Subtracted (me; Other : Vector) returns mutable VectorWithMagnitude
152 -- Subtracts the vector Other to <me>. A new vector is returned.
153 ---C++: alias operator -
158 Transform (me: mutable; T : Trsf2d);
159 ---Purpose: Applies the transformation T to this vector.
162 Copy (me) returns mutable like me;
163 --- Purpose: Creates a new object which is a copy of this vector.