Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-17 09:20:22

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_Direction_HeaderFile
0018 #define _Geom2d_Direction_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 
0022 #include <Geom2d_Vector.hxx>
0023 #include <Standard_Real.hxx>
0024 class gp_Dir2d;
0025 class gp_Trsf2d;
0026 class Geom2d_Geometry;
0027 
0028 //! The class Direction specifies a vector that is never null.
0029 //! It is a unit vector.
0030 class Geom2d_Direction : public Geom2d_Vector
0031 {
0032 
0033 public:
0034   //! Creates a unit vector with it 2 cartesian coordinates.
0035   //!
0036   //! Raised if std::sqrt( X*X + Y*Y) <= Resolution from gp.
0037   Standard_EXPORT Geom2d_Direction(const double X, const double Y);
0038 
0039   //! Creates a persistent copy of <me>.
0040   Standard_EXPORT Geom2d_Direction(const gp_Dir2d& V);
0041 
0042   //! Assigns the coordinates X and Y to this unit vector,
0043   //! then normalizes it.
0044   //! Exceptions
0045   //! Standard_ConstructionError if std::sqrt(X*X + Y*Y) is less than or equal to gp::Resolution().
0046   Standard_EXPORT void SetCoord(const double X, const double Y);
0047 
0048   //! Converts the gp_Dir2d unit vector V into this unit vector.
0049   Standard_EXPORT void SetDir2d(const gp_Dir2d& V);
0050 
0051   //! Assigns a value to the X coordinate of this unit vector, then normalizes it.
0052   //! Exceptions
0053   //! Standard_ConstructionError if the value assigned
0054   //! causes the magnitude of the vector to become less
0055   //! than or equal to gp::Resolution().
0056   Standard_EXPORT void SetX(const double X);
0057 
0058   //! Assigns a value to the Y coordinate of this unit vector, then normalizes it.
0059   //! Exceptions
0060   //! Standard_ConstructionError if the value assigned
0061   //! causes the magnitude of the vector to become less
0062   //! than or equal to gp::Resolution().
0063   Standard_EXPORT void SetY(const double Y);
0064 
0065   //! Converts this unit vector into a gp_Dir2d unit vector.
0066   Standard_EXPORT gp_Dir2d Dir2d() const;
0067 
0068   //! returns 1.0
0069   Standard_EXPORT double Magnitude() const override;
0070 
0071   //! returns 1.0
0072   Standard_EXPORT double SquareMagnitude() const override;
0073 
0074   //! Computes the cross product between <me> and <Other>.
0075   Standard_EXPORT double Crossed(const occ::handle<Geom2d_Vector>& Other) const override;
0076 
0077   double operator^(const occ::handle<Geom2d_Vector>& Other) const { return Crossed(Other); }
0078 
0079   //! Applies the transformation T to this unit vector, then normalizes it.
0080   Standard_EXPORT void Transform(const gp_Trsf2d& T) override;
0081 
0082   //! Creates a new object which is a copy of this unit vector.
0083   Standard_EXPORT occ::handle<Geom2d_Geometry> Copy() const override;
0084 
0085   DEFINE_STANDARD_RTTIEXT(Geom2d_Direction, Geom2d_Vector)
0086 };
0087 
0088 #endif // _Geom2d_Direction_HeaderFile