OCCT3D OCCT 8.0.1
OCCT documentation

Search guides and API reference

Enter at least two characters.

    Open CASCADE Technology Reference Manual 8.0.1
    gp_Dir2d Class Reference

    Describes a unit vector in the plane (2D space). This unit vector is also called "Direction". See Also gce_MakeDir2d which provides functions for more complex unit vector constructions Geom2d_Direction which provides additional functions for constructing unit vectors and works, in particular, with the parametric equations of unit vectors. More...

    #include <gp_Dir2d.hxx>

    Public Types

    enum class  D { X , Y , NX , NY }
     Standard directions in 2D space for optimized constexpr construction. More...

    Public Member Functions

    constexpr gp_Dir2d () noexcept
     Creates a direction corresponding to X axis.
    constexpr gp_Dir2d (const D theDir) noexcept
     Creates a direction from a standard direction enumeration.
    constexpr gp_Dir2d (const gp_Vec2d &theV)
     Normalizes the vector theV and creates a Direction. Raises ConstructionError if theV.Magnitude() <= Resolution from gp.
    constexpr gp_Dir2d (const gp_XY &theCoord)
     Creates a Direction from a doublet of coordinates. Raises ConstructionError if theCoord.Modulus() <= Resolution from gp.
    constexpr gp_Dir2d (const double theXv, const double theYv)
     Creates a Direction with its 2 cartesian coordinates. Raises ConstructionError if std::sqrt(theXv*theXv + theYv*theYv) <= Resolution from gp.
    constexpr void SetCoord (const int theIndex, const double theXi)
     For this unit vector, assigns: the value theXi to:
    constexpr void SetCoord (const double theXv, const double theYv)
     For this unit vector, assigns:
    constexpr void SetX (const double theX)
     Assigns the given value to the X coordinate of this unit vector, and then normalizes it. Warning Remember that all the coordinates of a unit vector are implicitly modified when any single one is changed directly. Exceptions Standard_ConstructionError if either of the following is less than or equal to gp::Resolution():
    constexpr void SetY (const double theY)
     Assigns the given value to the Y coordinate of this unit vector, and then normalizes it. Warning Remember that all the coordinates of a unit vector are implicitly modified when any single one is changed directly. Exceptions Standard_ConstructionError if either of the following is less than or equal to gp::Resolution():
    constexpr void SetXY (const gp_XY &theCoord)
     Assigns:
    constexpr double Coord (const int theIndex) const
     For this unit vector returns the coordinate of range theIndex : theIndex = 1 => X is returned theIndex = 2 => Y is returned Raises OutOfRange if theIndex != {1, 2}.
    constexpr void Coord (double &theXv, double &theYv) const noexcept
     For this unit vector returns its two coordinates theXv and theYv. Raises OutOfRange if theIndex != {1, 2}.
    constexpr double X () const noexcept
     For this unit vector, returns its X coordinate.
    constexpr double Y () const noexcept
     For this unit vector, returns its Y coordinate.
    constexpr const gp_XYXY () const noexcept
     For this unit vector, returns its two coordinates as a number pair. Comparison between Directions The precision value is an input data.
    bool IsEqual (const gp_Dir2d &theOther, const double theAngularTolerance) const
     Returns True if the two vectors have the same direction i.e. the angle between this unit vector and the unit vector theOther is less than or equal to theAngularTolerance.
    bool IsNormal (const gp_Dir2d &theOther, const double theAngularTolerance) const
     Returns True if the angle between this unit vector and the unit vector theOther is equal to Pi/2 or -Pi/2 (normal) i.e. std::abs(std::abs(<me>.Angle(theOther)) - PI/2.) <= theAngularTolerance.
    bool IsOpposite (const gp_Dir2d &theOther, const double theAngularTolerance) const
     Returns True if the angle between this unit vector and the unit vector theOther is equal to Pi or -Pi (opposite). i.e. PI - std::abs(<me>.Angle(theOther)) <= theAngularTolerance.
    bool IsParallel (const gp_Dir2d &theOther, const double theAngularTolerance) const
     Returns True if the angle between this unit vector and unit vector theOther is equal to 0, Pi or -Pi. i.e. std::abs(Angle(<me>, theOther)) <= theAngularTolerance or PI - std::abs(Angle(<me>, theOther)) <= theAngularTolerance.
    double Angle (const gp_Dir2d &theOther) const
     Computes the angular value in radians between <me> and <theOther>. Returns the angle in the range [-PI, PI].
    constexpr double Crossed (const gp_Dir2d &theRight) const noexcept
     Computes the cross product between two directions.
    constexpr double operator^ (const gp_Dir2d &theRight) const noexcept
    constexpr double Dot (const gp_Dir2d &theOther) const noexcept
     Computes the scalar product.
    constexpr double operator* (const gp_Dir2d &theOther) const noexcept
    constexpr void Reverse () noexcept
    constexpr gp_Dir2d Reversed () const noexcept
     Reverses the orientation of a direction.
    constexpr gp_Dir2d operator- () const noexcept
    void Mirror (const gp_Dir2d &theV) noexcept
    gp_Dir2d Mirrored (const gp_Dir2d &theV) const noexcept
     Performs the symmetrical transformation of a direction with respect to the direction theV which is the center of the symmetry.
    void Mirror (const gp_Ax2d &theA) noexcept
    gp_Dir2d Mirrored (const gp_Ax2d &theA) const noexcept
     Performs the symmetrical transformation of a direction with respect to an axis placement which is the axis of the symmetry.
    void Rotate (const double Ang)
    gp_Dir2d Rotated (const double theAng) const
     Rotates a direction. theAng is the angular value of the rotation in radians.
    void Transform (const gp_Trsf2d &theT) noexcept
    gp_Dir2d Transformed (const gp_Trsf2d &theT) const
     Transforms a direction with the "Trsf" theT. Warnings : If the scale factor of the "Trsf" theT is negative then the direction <me> is reversed.
    void DumpJson (Standard_OStream &theOStream, int theDepth=-1) const
     Dumps the content of me into the stream.

    Detailed Description

    Describes a unit vector in the plane (2D space). This unit vector is also called "Direction". See Also gce_MakeDir2d which provides functions for more complex unit vector constructions Geom2d_Direction which provides additional functions for constructing unit vectors and works, in particular, with the parametric equations of unit vectors.

    Member Enumeration Documentation

    ◆ D

    enum class gp_Dir2d::D
    strong

    Standard directions in 2D space for optimized constexpr construction.

    Enumerator

    Direction along positive X axis (1, 0).

    Direction along positive Y axis (0, 1).

    NX 

    Direction along negative X axis (-1, 0).

    NY 

    Direction along negative Y axis (0, -1).

    Constructor & Destructor Documentation

    ◆ gp_Dir2d() [1/5]

    gp_Dir2d::gp_Dir2d ( )
    inlineconstexprnoexcept

    Creates a direction corresponding to X axis.

    ◆ gp_Dir2d() [2/5]

    gp_Dir2d::gp_Dir2d ( const D theDir)
    inlineexplicitconstexprnoexcept

    Creates a direction from a standard direction enumeration.

    ◆ gp_Dir2d() [3/5]

    gp_Dir2d::gp_Dir2d ( const gp_Vec2d & theV)
    inlineconstexpr

    Normalizes the vector theV and creates a Direction. Raises ConstructionError if theV.Magnitude() <= Resolution from gp.

    Note
    Constexpr-compatible when input is already normalized.

    ◆ gp_Dir2d() [4/5]

    gp_Dir2d::gp_Dir2d ( const gp_XY & theCoord)
    inlineconstexpr

    Creates a Direction from a doublet of coordinates. Raises ConstructionError if theCoord.Modulus() <= Resolution from gp.

    Note
    Constexpr-compatible when input is already normalized.

    ◆ gp_Dir2d() [5/5]

    gp_Dir2d::gp_Dir2d ( const double theXv,
    const double theYv )
    inlineconstexpr

    Creates a Direction with its 2 cartesian coordinates. Raises ConstructionError if std::sqrt(theXv*theXv + theYv*theYv) <= Resolution from gp.

    Note
    Constexpr-compatible when input is already normalized.

    Member Function Documentation

    ◆ Angle()

    double gp_Dir2d::Angle ( const gp_Dir2d & theOther) const

    Computes the angular value in radians between <me> and <theOther>. Returns the angle in the range [-PI, PI].

    ◆ Coord() [1/2]

    double gp_Dir2d::Coord ( const int theIndex) const
    inlineconstexpr

    For this unit vector returns the coordinate of range theIndex : theIndex = 1 => X is returned theIndex = 2 => Y is returned Raises OutOfRange if theIndex != {1, 2}.

    ◆ Coord() [2/2]

    void gp_Dir2d::Coord ( double & theXv,
    double & theYv ) const
    inlineconstexprnoexcept

    For this unit vector returns its two coordinates theXv and theYv. Raises OutOfRange if theIndex != {1, 2}.

    ◆ Crossed()

    double gp_Dir2d::Crossed ( const gp_Dir2d & theRight) const
    inlinenodiscardconstexprnoexcept

    Computes the cross product between two directions.

    ◆ Dot()

    double gp_Dir2d::Dot ( const gp_Dir2d & theOther) const
    inlineconstexprnoexcept

    Computes the scalar product.

    ◆ DumpJson()

    void gp_Dir2d::DumpJson ( Standard_OStream & theOStream,
    int theDepth = -1 ) const

    Dumps the content of me into the stream.

    ◆ IsEqual()

    bool gp_Dir2d::IsEqual ( const gp_Dir2d & theOther,
    const double theAngularTolerance ) const
    inline

    Returns True if the two vectors have the same direction i.e. the angle between this unit vector and the unit vector theOther is less than or equal to theAngularTolerance.

    ◆ IsNormal()

    bool gp_Dir2d::IsNormal ( const gp_Dir2d & theOther,
    const double theAngularTolerance ) const
    inline

    Returns True if the angle between this unit vector and the unit vector theOther is equal to Pi/2 or -Pi/2 (normal) i.e. std::abs(std::abs(<me>.Angle(theOther)) - PI/2.) <= theAngularTolerance.

    ◆ IsOpposite()

    bool gp_Dir2d::IsOpposite ( const gp_Dir2d & theOther,
    const double theAngularTolerance ) const
    inline

    Returns True if the angle between this unit vector and the unit vector theOther is equal to Pi or -Pi (opposite). i.e. PI - std::abs(<me>.Angle(theOther)) <= theAngularTolerance.

    ◆ IsParallel()

    bool gp_Dir2d::IsParallel ( const gp_Dir2d & theOther,
    const double theAngularTolerance ) const
    inline

    Returns True if the angle between this unit vector and unit vector theOther is equal to 0, Pi or -Pi. i.e. std::abs(Angle(<me>, theOther)) <= theAngularTolerance or PI - std::abs(Angle(<me>, theOther)) <= theAngularTolerance.

    ◆ Mirror() [1/2]

    void gp_Dir2d::Mirror ( const gp_Ax2d & theA)
    noexcept

    ◆ Mirror() [2/2]

    void gp_Dir2d::Mirror ( const gp_Dir2d & theV)
    noexcept

    ◆ Mirrored() [1/2]

    gp_Dir2d gp_Dir2d::Mirrored ( const gp_Ax2d & theA) const
    nodiscardnoexcept

    Performs the symmetrical transformation of a direction with respect to an axis placement which is the axis of the symmetry.

    ◆ Mirrored() [2/2]

    gp_Dir2d gp_Dir2d::Mirrored ( const gp_Dir2d & theV) const
    nodiscardnoexcept

    Performs the symmetrical transformation of a direction with respect to the direction theV which is the center of the symmetry.

    ◆ operator*()

    double gp_Dir2d::operator* ( const gp_Dir2d & theOther) const
    inlineconstexprnoexcept

    ◆ operator-()

    gp_Dir2d gp_Dir2d::operator- ( ) const
    inlinenodiscardconstexprnoexcept

    ◆ operator^()

    double gp_Dir2d::operator^ ( const gp_Dir2d & theRight) const
    inlinenodiscardconstexprnoexcept

    ◆ Reverse()

    void gp_Dir2d::Reverse ( )
    inlineconstexprnoexcept

    ◆ Reversed()

    gp_Dir2d gp_Dir2d::Reversed ( ) const
    inlinenodiscardconstexprnoexcept

    Reverses the orientation of a direction.

    ◆ Rotate()

    void gp_Dir2d::Rotate ( const double Ang)
    inline

    ◆ Rotated()

    gp_Dir2d gp_Dir2d::Rotated ( const double theAng) const
    inlinenodiscard

    Rotates a direction. theAng is the angular value of the rotation in radians.

    ◆ SetCoord() [1/2]

    void gp_Dir2d::SetCoord ( const double theXv,
    const double theYv )
    inlineconstexpr

    For this unit vector, assigns:

    • the values theXv and theYv to its two coordinates, Warning Remember that all the coordinates of a unit vector are implicitly modified when any single one is changed directly. Exceptions Standard_OutOfRange if theIndex is not 1 or 2. Standard_ConstructionError if either of the following is less than or equal to gp::Resolution():
    • std::sqrt(theXv*theXv + theYv*theYv), or
    • the modulus of the number pair formed by the new value Xi and the other coordinate of this vector that was not directly modified. Raises OutOfRange if theIndex != {1, 2}.
      Note
      Constexpr-compatible when input is already normalized.

    ◆ SetCoord() [2/2]

    void gp_Dir2d::SetCoord ( const int theIndex,
    const double theXi )
    inlineconstexpr

    For this unit vector, assigns: the value theXi to:

    • the X coordinate if theIndex is 1, or
    • the Y coordinate if theIndex is 2, and then normalizes it. Warning Remember that all the coordinates of a unit vector are implicitly modified when any single one is changed directly. Exceptions Standard_OutOfRange if theIndex is not 1 or 2. Standard_ConstructionError if either of the following is less than or equal to gp::Resolution():
    • std::sqrt(theXv*theXv + theYv*theYv), or
    • the modulus of the number pair formed by the new value theXi and the other coordinate of this vector that was not directly modified. Raises OutOfRange if theIndex != {1, 2}.
      Note
      Constexpr-compatible when result is already normalized.

    ◆ SetX()

    void gp_Dir2d::SetX ( const double theX)
    inlineconstexpr

    Assigns the given value to the X coordinate of this unit vector, and then normalizes it. Warning Remember that all the coordinates of a unit vector are implicitly modified when any single one is changed directly. Exceptions Standard_ConstructionError if either of the following is less than or equal to gp::Resolution():

    • the modulus of Coord, or
    • the modulus of the number pair formed from the new X or Y coordinate and the other coordinate of this vector that was not directly modified.
      Note
      Constexpr-compatible when result is already normalized.

    ◆ SetXY()

    void gp_Dir2d::SetXY ( const gp_XY & theCoord)
    inlineconstexpr

    Assigns:

    • the two coordinates of theCoord to this unit vector, and then normalizes it. Warning Remember that all the coordinates of a unit vector are implicitly modified when any single one is changed directly. Exceptions Standard_ConstructionError if either of the following is less than or equal to gp::Resolution():
    • the modulus of theCoord, or
    • the modulus of the number pair formed from the new X or Y coordinate and the other coordinate of this vector that was not directly modified.
      Note
      Constexpr-compatible when input is already normalized.

    ◆ SetY()

    void gp_Dir2d::SetY ( const double theY)
    inlineconstexpr

    Assigns the given value to the Y coordinate of this unit vector, and then normalizes it. Warning Remember that all the coordinates of a unit vector are implicitly modified when any single one is changed directly. Exceptions Standard_ConstructionError if either of the following is less than or equal to gp::Resolution():

    • the modulus of Coord, or
    • the modulus of the number pair formed from the new X or Y coordinate and the other coordinate of this vector that was not directly modified.
      Note
      Constexpr-compatible when result is already normalized.

    ◆ Transform()

    void gp_Dir2d::Transform ( const gp_Trsf2d & theT)
    noexcept

    ◆ Transformed()

    gp_Dir2d gp_Dir2d::Transformed ( const gp_Trsf2d & theT) const
    inlinenodiscard

    Transforms a direction with the "Trsf" theT. Warnings : If the scale factor of the "Trsf" theT is negative then the direction <me> is reversed.

    ◆ X()

    double gp_Dir2d::X ( ) const
    inlineconstexprnoexcept

    For this unit vector, returns its X coordinate.

    ◆ XY()

    const gp_XY & gp_Dir2d::XY ( ) const
    inlineconstexprnoexcept

    For this unit vector, returns its two coordinates as a number pair. Comparison between Directions The precision value is an input data.

    ◆ Y()

    double gp_Dir2d::Y ( ) const
    inlineconstexprnoexcept

    For this unit vector, returns its Y coordinate.


    The documentation for this class was generated from the following file: