1 // Created on: 1993-03-24
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _Geom2d_VectorWithMagnitude_HeaderFile
18 #define _Geom2d_VectorWithMagnitude_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
23 #include <Geom2d_Vector.hxx>
24 #include <Standard_Real.hxx>
25 class Standard_ConstructionError;
30 class Geom2d_Geometry;
33 class Geom2d_VectorWithMagnitude;
34 DEFINE_STANDARD_HANDLE(Geom2d_VectorWithMagnitude, Geom2d_Vector)
37 //! Defines a vector with magnitude.
38 //! A vector with magnitude can have a zero length.
39 class Geom2d_VectorWithMagnitude : public Geom2d_Vector
45 //! Creates a persistent copy of V.
46 Standard_EXPORT Geom2d_VectorWithMagnitude(const gp_Vec2d& V);
48 //! Creates a vector with two cartesian coordinates.
49 Standard_EXPORT Geom2d_VectorWithMagnitude(const Standard_Real X, const Standard_Real Y);
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);
56 //! Set <me> to X, Y coordinates.
57 Standard_EXPORT void SetCoord (const Standard_Real X, const Standard_Real Y);
59 Standard_EXPORT void SetVec2d (const gp_Vec2d& V);
61 //! Changes the X coordinate of <me>.
62 Standard_EXPORT void SetX (const Standard_Real X);
64 //! Changes the Y coordinate of <me>
65 Standard_EXPORT void SetY (const Standard_Real Y);
67 //! Returns the magnitude of <me>.
68 Standard_EXPORT Standard_Real Magnitude() const Standard_OVERRIDE;
70 //! Returns the square magnitude of <me>.
71 Standard_EXPORT Standard_Real SquareMagnitude() const Standard_OVERRIDE;
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)
82 //! Adds the vector Other to <me>.
83 Standard_EXPORT Handle(Geom2d_VectorWithMagnitude) Added (const Handle(Geom2d_Vector)& Other) const;
84 Handle(Geom2d_VectorWithMagnitude) operator + (const Handle(Geom2d_Vector)& Other) const
90 //! Computes the cross product between <me> and Other
91 //! <me> ^ Other. A new vector is returned.
92 Standard_EXPORT Standard_Real Crossed (const Handle(Geom2d_Vector)& Other) const Standard_OVERRIDE;
93 Standard_Real operator ^ (const Handle(Geom2d_Vector)& Other) const
95 return Crossed(Other);
98 //! Divides <me> by a scalar.
99 Standard_EXPORT void Divide (const Standard_Real Scalar);
100 void operator /= (const Standard_Real Scalar)
106 //! Divides <me> by a scalar. A new vector is returned.
107 Standard_EXPORT Handle(Geom2d_VectorWithMagnitude) Divided (const Standard_Real Scalar) const;
108 Handle(Geom2d_VectorWithMagnitude) operator / (const Standard_Real Scalar) const
110 return Divided(Scalar);
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!
119 Standard_EXPORT Handle(Geom2d_VectorWithMagnitude) Multiplied (const Standard_Real Scalar) const;
122 //! Computes the product of the vector <me> by a scalar.
123 Standard_EXPORT void Multiply (const Standard_Real Scalar);
124 void operator *= (const Standard_Real Scalar)
131 //! Raised if the magnitude of the vector is lower or equal to
132 //! Resolution from package gp.
133 Standard_EXPORT void Normalize();
135 //! Returns a copy of <me> Normalized.
137 //! Raised if the magnitude of the vector is lower or equal to
138 //! Resolution from package gp.
139 Standard_EXPORT Handle(Geom2d_VectorWithMagnitude) Normalized() const;
141 //! Subtracts the Vector Other to <me>.
142 Standard_EXPORT void Subtract (const Handle(Geom2d_Vector)& Other);
143 void operator -= (const Handle(Geom2d_Vector)& Other)
149 //! Subtracts the vector Other to <me>. A new vector is returned.
150 Standard_EXPORT Handle(Geom2d_VectorWithMagnitude) Subtracted (const Handle(Geom2d_Vector)& Other) const;
151 Handle(Geom2d_VectorWithMagnitude) operator - (const Handle(Geom2d_Vector)& Other) const
153 return Subtracted(Other);
156 //! Applies the transformation T to this vector.
157 Standard_EXPORT void Transform (const gp_Trsf2d& T) Standard_OVERRIDE;
159 //! Creates a new object which is a copy of this vector.
160 Standard_EXPORT Handle(Geom2d_Geometry) Copy() const Standard_OVERRIDE;
165 DEFINE_STANDARD_RTTIEXT(Geom2d_VectorWithMagnitude,Geom2d_Vector)
185 #endif // _Geom2d_VectorWithMagnitude_HeaderFile