Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-25 09:19:41

0001 // Created on: 1993-03-24
0002 // Created by: JCV
0003 // Copyright (c) 1993-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _Geom2d_VectorWithMagnitude_HeaderFile
0018 #define _Geom2d_VectorWithMagnitude_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_Type.hxx>
0022 
0023 #include <Geom2d_Vector.hxx>
0024 class gp_Vec2d;
0025 class gp_Pnt2d;
0026 class gp_Trsf2d;
0027 class Geom2d_Geometry;
0028 
0029 //! Defines a vector with magnitude.
0030 //! A vector with magnitude can have a zero length.
0031 class Geom2d_VectorWithMagnitude : public Geom2d_Vector
0032 {
0033 
0034 public:
0035   //! Creates a persistent copy of V.
0036   Standard_EXPORT Geom2d_VectorWithMagnitude(const gp_Vec2d& V);
0037 
0038   //! Creates a vector with two cartesian coordinates.
0039   Standard_EXPORT Geom2d_VectorWithMagnitude(const double X, const double Y);
0040 
0041   //! Creates a vector from the point P1 to the point P2.
0042   //! The magnitude of the vector is the distance between P1 and P2
0043   Standard_EXPORT Geom2d_VectorWithMagnitude(const gp_Pnt2d& P1, const gp_Pnt2d& P2);
0044 
0045   //! Set <me> to X, Y coordinates.
0046   Standard_EXPORT void SetCoord(const double X, const double Y);
0047 
0048   Standard_EXPORT void SetVec2d(const gp_Vec2d& V);
0049 
0050   //! Changes the X coordinate of <me>.
0051   Standard_EXPORT void SetX(const double X);
0052 
0053   //! Changes the Y coordinate of <me>
0054   Standard_EXPORT void SetY(const double Y);
0055 
0056   //! Returns the magnitude of <me>.
0057   Standard_EXPORT double Magnitude() const override;
0058 
0059   //! Returns the square magnitude of <me>.
0060   Standard_EXPORT double SquareMagnitude() const override;
0061 
0062   //! Adds the Vector Other to <me>.
0063   Standard_EXPORT void Add(const occ::handle<Geom2d_Vector>& Other);
0064 
0065   void operator+=(const occ::handle<Geom2d_Vector>& Other) { Add(Other); }
0066 
0067   //! Adds the vector Other to <me>.
0068   [[nodiscard]] Standard_EXPORT occ::handle<Geom2d_VectorWithMagnitude> Added(
0069     const occ::handle<Geom2d_Vector>& Other) const;
0070 
0071   [[nodiscard]] occ::handle<Geom2d_VectorWithMagnitude> operator+(
0072     const occ::handle<Geom2d_Vector>& Other) const
0073   {
0074     return Added(Other);
0075   }
0076 
0077   //! Computes the cross product between <me> and Other
0078   //! <me> ^ Other. A new vector is returned.
0079   Standard_EXPORT double Crossed(const occ::handle<Geom2d_Vector>& Other) const override;
0080 
0081   double operator^(const occ::handle<Geom2d_Vector>& Other) const { return Crossed(Other); }
0082 
0083   //! Divides <me> by a scalar.
0084   Standard_EXPORT void Divide(const double Scalar);
0085 
0086   void operator/=(const double Scalar) { Divide(Scalar); }
0087 
0088   //! Divides <me> by a scalar. A new vector is returned.
0089   [[nodiscard]] Standard_EXPORT occ::handle<Geom2d_VectorWithMagnitude> Divided(
0090     const double Scalar) const;
0091 
0092   [[nodiscard]] occ::handle<Geom2d_VectorWithMagnitude> operator/(const double Scalar) const
0093   {
0094     return Divided(Scalar);
0095   }
0096 
0097   //! Computes the product of the vector <me> by a scalar.
0098   //! A new vector is returned.
0099   //!
0100   //! -C++: alias operator *
0101   //! Collision with same operator defined for the class Vector!
0102   [[nodiscard]] Standard_EXPORT occ::handle<Geom2d_VectorWithMagnitude> Multiplied(
0103     const double Scalar) const;
0104 
0105   //! Computes the product of the vector <me> by a scalar.
0106   Standard_EXPORT void Multiply(const double Scalar);
0107 
0108   void operator*=(const double Scalar) { Multiply(Scalar); }
0109 
0110   //! Normalizes <me>.
0111   //!
0112   //! Raised if the magnitude of the vector is lower or equal to
0113   //! Resolution from package gp.
0114   Standard_EXPORT void Normalize();
0115 
0116   //! Returns a copy of <me> Normalized.
0117   //!
0118   //! Raised if the magnitude of the vector is lower or equal to
0119   //! Resolution from package gp.
0120   [[nodiscard]] Standard_EXPORT occ::handle<Geom2d_VectorWithMagnitude> Normalized() const;
0121 
0122   //! Subtracts the Vector Other to <me>.
0123   Standard_EXPORT void Subtract(const occ::handle<Geom2d_Vector>& Other);
0124 
0125   void operator-=(const occ::handle<Geom2d_Vector>& Other) { Subtract(Other); }
0126 
0127   //! Subtracts the vector Other to <me>. A new vector is returned.
0128   [[nodiscard]] Standard_EXPORT occ::handle<Geom2d_VectorWithMagnitude> Subtracted(
0129     const occ::handle<Geom2d_Vector>& Other) const;
0130 
0131   [[nodiscard]] occ::handle<Geom2d_VectorWithMagnitude> operator-(
0132     const occ::handle<Geom2d_Vector>& Other) const
0133   {
0134     return Subtracted(Other);
0135   }
0136 
0137   //! Applies the transformation T to this vector.
0138   Standard_EXPORT void Transform(const gp_Trsf2d& T) override;
0139 
0140   //! Creates a new object which is a copy of this vector.
0141   Standard_EXPORT occ::handle<Geom2d_Geometry> Copy() const override;
0142 
0143   DEFINE_STANDARD_RTTIEXT(Geom2d_VectorWithMagnitude, Geom2d_Vector)
0144 };
0145 
0146 #endif // _Geom2d_VectorWithMagnitude_HeaderFile