0031939: Coding - correction of spelling errors in comments
[occt.git] / src / Geom2d / Geom2d_VectorWithMagnitude.hxx
1 // Created on: 1993-03-24
2 // Created by: JCV
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #ifndef _Geom2d_VectorWithMagnitude_HeaderFile
18 #define _Geom2d_VectorWithMagnitude_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
22
23 #include <Geom2d_Vector.hxx>
24 #include <Standard_Real.hxx>
25 class Standard_ConstructionError;
26 class gp_Vec2d;
27 class gp_Pnt2d;
28 class Geom2d_Vector;
29 class gp_Trsf2d;
30 class Geom2d_Geometry;
31
32
33 class Geom2d_VectorWithMagnitude;
34 DEFINE_STANDARD_HANDLE(Geom2d_VectorWithMagnitude, Geom2d_Vector)
35
36
37 //! Defines a vector with magnitude.
38 //! A vector with magnitude can have a zero length.
39 class Geom2d_VectorWithMagnitude : public Geom2d_Vector
40 {
41
42 public:
43
44   
45   //! Creates a persistent copy of V.
46   Standard_EXPORT Geom2d_VectorWithMagnitude(const gp_Vec2d& V);
47   
48   //! Creates a vector with two cartesian coordinates.
49   Standard_EXPORT Geom2d_VectorWithMagnitude(const Standard_Real X, const Standard_Real Y);
50   
51
52   //! Creates a vector from the point P1 to the point P2.
53   //! The magnitude of the vector is the distance between P1 and P2
54   Standard_EXPORT Geom2d_VectorWithMagnitude(const gp_Pnt2d& P1, const gp_Pnt2d& P2);
55   
56   //! Set <me> to X, Y coordinates.
57   Standard_EXPORT void SetCoord (const Standard_Real X, const Standard_Real Y);
58   
59   Standard_EXPORT void SetVec2d (const gp_Vec2d& V);
60   
61   //! Changes the X coordinate of <me>.
62   Standard_EXPORT void SetX (const Standard_Real X);
63   
64   //! Changes the Y coordinate of <me>
65   Standard_EXPORT void SetY (const Standard_Real Y);
66   
67   //! Returns the magnitude of <me>.
68   Standard_EXPORT Standard_Real Magnitude() const Standard_OVERRIDE;
69   
70   //! Returns the square magnitude of <me>.
71   Standard_EXPORT Standard_Real SquareMagnitude() const Standard_OVERRIDE;
72   
73
74   //! Adds the Vector Other to <me>.
75   Standard_EXPORT void Add (const Handle(Geom2d_Vector)& Other);
76 void operator += (const Handle(Geom2d_Vector)& Other)
77 {
78   Add(Other);
79 }
80   
81
82   //! Adds the vector Other to <me>.
83   Standard_NODISCARD Standard_EXPORT
84   Handle(Geom2d_VectorWithMagnitude) Added (const Handle(Geom2d_Vector)& Other) const;
85 Standard_NODISCARD Handle(Geom2d_VectorWithMagnitude) operator + (const Handle(Geom2d_Vector)& Other) const
86 {
87   return Added(Other);
88 }
89   
90
91   //! Computes the cross product  between <me> and Other
92   //! <me> ^ Other. A new vector is returned.
93   Standard_EXPORT Standard_Real Crossed (const Handle(Geom2d_Vector)& Other) const Standard_OVERRIDE;
94 Standard_Real operator ^ (const Handle(Geom2d_Vector)& Other) const
95 {
96   return Crossed(Other);
97 }
98   
99   //! Divides <me> by a scalar.
100   Standard_EXPORT void Divide (const Standard_Real Scalar);
101 void operator /= (const Standard_Real Scalar)
102 {
103   Divide(Scalar);
104 }
105   
106
107   //! Divides <me> by a scalar. A new vector is returned.
108   Standard_NODISCARD Standard_EXPORT Handle(Geom2d_VectorWithMagnitude) Divided (const Standard_Real Scalar) const;
109 Standard_NODISCARD Handle(Geom2d_VectorWithMagnitude) operator / (const Standard_Real Scalar) const
110 {
111   return Divided(Scalar);
112 }
113   
114
115   //! Computes the product of the vector <me> by a scalar.
116   //! A new vector is returned.
117   //!
118   //! -C++: alias operator *
119   //! Collision with same operator defined for the class Vector!
120   Standard_NODISCARD Standard_EXPORT Handle(Geom2d_VectorWithMagnitude) Multiplied (const Standard_Real Scalar) const;
121   
122
123   //! Computes the product of the vector <me> by a scalar.
124   Standard_EXPORT void Multiply (const Standard_Real Scalar);
125 void operator *= (const Standard_Real Scalar)
126 {
127   Multiply(Scalar);
128 }
129   
130   //! Normalizes <me>.
131   //!
132   //! Raised if the magnitude of the vector is lower or equal to
133   //! Resolution from package gp.
134   Standard_EXPORT void Normalize();
135   
136   //! Returns a copy of <me> Normalized.
137   //!
138   //! Raised if the magnitude of the vector is lower or equal to
139   //! Resolution from package gp.
140   Standard_NODISCARD Standard_EXPORT Handle(Geom2d_VectorWithMagnitude) Normalized() const;
141   
142   //! Subtracts the Vector Other to <me>.
143   Standard_EXPORT void Subtract (const Handle(Geom2d_Vector)& Other);
144 void operator -= (const Handle(Geom2d_Vector)& Other)
145 {
146   Subtract(Other);
147 }
148   
149
150   //! Subtracts the vector Other to <me>. A new vector is returned.
151   Standard_NODISCARD Standard_EXPORT
152   Handle(Geom2d_VectorWithMagnitude) Subtracted (const Handle(Geom2d_Vector)& Other) const;
153 Standard_NODISCARD Handle(Geom2d_VectorWithMagnitude) operator - (const Handle(Geom2d_Vector)& Other) const
154 {
155   return Subtracted(Other);
156 }
157   
158   //! Applies the transformation T to this vector.
159   Standard_EXPORT void Transform (const gp_Trsf2d& T) Standard_OVERRIDE;
160   
161   //! Creates a new object which is a copy of this vector.
162   Standard_EXPORT Handle(Geom2d_Geometry) Copy() const Standard_OVERRIDE;
163
164
165
166
167   DEFINE_STANDARD_RTTIEXT(Geom2d_VectorWithMagnitude,Geom2d_Vector)
168
169 protected:
170
171
172
173
174 private:
175
176
177
178
179 };
180
181
182
183
184
185
186
187 #endif // _Geom2d_VectorWithMagnitude_HeaderFile