Open CASCADE Technology Reference Manual 8.0.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions
gp_Dir Class Reference

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

#include <gp_Dir.hxx>

Public Types

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

Public Member Functions

constexpr gp_Dir () noexcept
 Creates a direction corresponding to X axis.
 
constexpr gp_Dir (const D theDir) noexcept
 Creates a direction from a standard direction enumeration.
 
constexpr gp_Dir (const gp_Vec &theV)
 Normalizes the vector theV and creates a direction. Raises ConstructionError if theV.Magnitude() <= Resolution.
 
constexpr gp_Dir (const gp_XYZ &theCoord)
 Creates a direction from a triplet of coordinates. Raises ConstructionError if theCoord.Modulus() <= Resolution from gp.
 
constexpr gp_Dir (const double theXv, const double theYv, const double theZv)
 Creates a direction with its 3 cartesian coordinates. Raises ConstructionError if std::sqrt(theXv*theXv + theYv*theYv + theZv*theZv) <= Resolution Modification of the direction's coordinates If std::sqrt (theXv*theXv + theYv*theYv + theZv*theZv) <= Resolution from gp where theXv, theYv ,theZv are the new coordinates it is not possible to construct the direction and the method raises the exception ConstructionError.
 
constexpr gp_Dir (const gp_Dir &) noexcept=default
 
constexpr gp_Dir (gp_Dir &&) noexcept=default
 
constexpr gp_Diroperator= (const gp_Dir &) noexcept=default
 
constexpr gp_Diroperator= (gp_Dir &&) noexcept=default
 
constexpr void SetCoord (const int theIndex, const double theXi)
 For this unit vector, assigns the value Xi to:
 
constexpr void SetCoord (const double theXv, const double theYv, const double theZv)
 For this unit vector, assigns the values theXv, theYv and theZv to its three coordinates. Remember that all the coordinates of a unit vector are implicitly modified when any single one is changed directly.
 
constexpr void SetX (const double theX)
 Assigns the given value to the X coordinate of this unit vector.
 
constexpr void SetY (const double theY)
 Assigns the given value to the Y coordinate of this unit vector.
 
constexpr void SetZ (const double theZ)
 Assigns the given value to the Z coordinate of this unit vector.
 
constexpr void SetXYZ (const gp_XYZ &theCoord)
 Assigns the three coordinates of theCoord to this unit vector.
 
constexpr double Coord (const int theIndex) const
 Returns the coordinate of range theIndex : theIndex = 1 => X is returned theIndex = 2 => Y is returned theIndex = 3 => Z is returned Exceptions Standard_OutOfRange if theIndex is not 1, 2, or 3.
 
constexpr void Coord (double &theXv, double &theYv, double &theZv) const noexcept
 Returns for the unit vector its three coordinates theXv, theYv, and theZv.
 
constexpr double X () const noexcept
 Returns the X coordinate for a unit vector.
 
constexpr double Y () const noexcept
 Returns the Y coordinate for a unit vector.
 
constexpr double Z () const noexcept
 Returns the Z coordinate for a unit vector.
 
constexpr const gp_XYZXYZ () const noexcept
 for this unit vector, returns its three coordinates as a number triple.
 
bool IsEqual (const gp_Dir &theOther, const double theAngularTolerance) const
 Returns True if the angle between the two directions is lower or equal to theAngularTolerance.
 
bool IsNormal (const gp_Dir &theOther, const double theAngularTolerance) const
 Returns True if the angle between this unit vector and the unit vector theOther is equal to Pi/2 (normal).
 
bool IsOpposite (const gp_Dir &theOther, const double theAngularTolerance) const
 Returns True if the angle between this unit vector and the unit vector theOther is equal to Pi (opposite).
 
bool IsParallel (const gp_Dir &theOther, const double theAngularTolerance) const
 Returns true if the angle between this unit vector and the unit vector theOther is equal to 0 or to Pi. Note: the tolerance criterion is given by theAngularTolerance.
 
double Angle (const gp_Dir &theOther) const
 Computes the angular value in radians between <me> and <theOther>. This value is always positive in 3D space. Returns the angle in the range [0, PI].
 
double AngleWithRef (const gp_Dir &theOther, const gp_Dir &theVRef) const
 Computes the angular value between <me> and <theOther>. <theVRef> is the direction of reference normal to <me> and <theOther> and its orientation gives the positive sense of rotation. If the cross product <me> ^ <theOther> has the same orientation as <theVRef> the angular value is positive else negative. Returns the angular value in the range -PI and PI (in radians). Raises DomainError if <me> and <theOther> are not parallel this exception is raised when <theVRef> is in the same plane as <me> and <theOther> The tolerance criterion is Resolution from package gp.
 
constexpr void Cross (const gp_Dir &theRight)
 Computes the cross product between two directions Raises the exception ConstructionError if the two directions are parallel because the computed vector cannot be normalized to create a direction.
 
constexpr void operator^= (const gp_Dir &theRight)
 
constexpr gp_Dir Crossed (const gp_Dir &theRight) const
 Computes the triple vector product. <me> ^ (V1 ^ V2) Raises the exception ConstructionError if V1 and V2 are parallel or <me> and (V1^V2) are parallel because the computed vector can't be normalized to create a direction.
 
constexpr gp_Dir operator^ (const gp_Dir &theRight) const
 
constexpr void CrossCross (const gp_Dir &theV1, const gp_Dir &theV2)
 
constexpr gp_Dir CrossCrossed (const gp_Dir &theV1, const gp_Dir &theV2) const
 Computes the double vector product this ^ (theV1 ^ theV2).
 
constexpr double Dot (const gp_Dir &theOther) const noexcept
 Computes the scalar product.
 
constexpr double operator* (const gp_Dir &theOther) const noexcept
 
constexpr double DotCross (const gp_Dir &theV1, const gp_Dir &theV2) const noexcept
 Computes the triple scalar product <me> * (theV1 ^ theV2). Warnings : The computed vector theV1' = theV1 ^ theV2 is not normalized to create a unitary vector. So this method never raises an exception even if theV1 and theV2 are parallel.
 
constexpr void Reverse () noexcept
 
constexpr gp_Dir Reversed () const noexcept
 Reverses the orientation of a direction geometric transformations Performs the symmetrical transformation of a direction with respect to the direction V which is the center of the symmetry.
 
constexpr gp_Dir operator- () const noexcept
 
void Mirror (const gp_Dir &theV) noexcept
 
gp_Dir Mirrored (const gp_Dir &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_Ax1 &theA1) noexcept
 
gp_Dir Mirrored (const gp_Ax1 &theA1) const noexcept
 Performs the symmetrical transformation of a direction with respect to an axis placement which is the axis of the symmetry.
 
void Mirror (const gp_Ax2 &theA2) noexcept
 
gp_Dir Mirrored (const gp_Ax2 &theA2) const noexcept
 Performs the symmetrical transformation of a direction with respect to a plane. The axis placement theA2 locates the plane of the symmetry : (Location, XDirection, YDirection).
 
void Rotate (const gp_Ax1 &theA1, const double theAng)
 
gp_Dir Rotated (const gp_Ax1 &theA1, const double theAng) const
 Rotates a direction. theA1 is the axis of the rotation. theAng is the angular value of the rotation in radians.
 
void Transform (const gp_Trsf &theT)
 
gp_Dir Transformed (const gp_Trsf &theT) const
 Transforms a direction with a "Trsf" from gp. 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.
 
bool InitFromJson (const Standard_SStream &theSStream, int &theStreamPos)
 Inits the content of me from the stream.
 

Detailed Description

Describes a unit vector in 3D space. This unit vector is also called "Direction". See Also gce_MakeDir which provides functions for more complex unit vector constructions Geom_Direction which provides additional functions for constructing unit vectors and works, in particular, with the parametric equations of unit vectors.

Member Enumeration Documentation

◆ D

Standard directions in 3D space for optimized constexpr construction.

Enumerator

Direction along positive X axis (1, 0, 0)

Direction along positive Y axis (0, 1, 0)

Direction along positive Z axis (0, 0, 1)

NX 

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

NY 

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

NZ 

Direction along negative Z axis (0, 0, -1)

Constructor & Destructor Documentation

◆ gp_Dir() [1/7]

constexpr gp_Dir::gp_Dir ( )
inlineconstexprnoexcept

Creates a direction corresponding to X axis.

◆ gp_Dir() [2/7]

constexpr gp_Dir::gp_Dir ( const D theDir)
inlineexplicitconstexprnoexcept

Creates a direction from a standard direction enumeration.

◆ gp_Dir() [3/7]

constexpr gp_Dir::gp_Dir ( const gp_Vec & theV)
inlineconstexpr

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

Note
Constexpr-compatible when input is already normalized.

◆ gp_Dir() [4/7]

constexpr gp_Dir::gp_Dir ( const gp_XYZ & theCoord)
inlineconstexpr

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

Note
Constexpr-compatible when input is already normalized.

◆ gp_Dir() [5/7]

constexpr gp_Dir::gp_Dir ( const double theXv,
const double theYv,
const double theZv )
inlineconstexpr

Creates a direction with its 3 cartesian coordinates. Raises ConstructionError if std::sqrt(theXv*theXv + theYv*theYv + theZv*theZv) <= Resolution Modification of the direction's coordinates If std::sqrt (theXv*theXv + theYv*theYv + theZv*theZv) <= Resolution from gp where theXv, theYv ,theZv are the new coordinates it is not possible to construct the direction and the method raises the exception ConstructionError.

Note
Constexpr-compatible when input is already normalized.

◆ gp_Dir() [6/7]

constexpr gp_Dir::gp_Dir ( const gp_Dir & )
constexprdefaultnoexcept

◆ gp_Dir() [7/7]

constexpr gp_Dir::gp_Dir ( gp_Dir && )
constexprdefaultnoexcept

Member Function Documentation

◆ Angle()

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

Computes the angular value in radians between <me> and <theOther>. This value is always positive in 3D space. Returns the angle in the range [0, PI].

◆ AngleWithRef()

double gp_Dir::AngleWithRef ( const gp_Dir & theOther,
const gp_Dir & theVRef ) const

Computes the angular value between <me> and <theOther>. <theVRef> is the direction of reference normal to <me> and <theOther> and its orientation gives the positive sense of rotation. If the cross product <me> ^ <theOther> has the same orientation as <theVRef> the angular value is positive else negative. Returns the angular value in the range -PI and PI (in radians). Raises DomainError if <me> and <theOther> are not parallel this exception is raised when <theVRef> is in the same plane as <me> and <theOther> The tolerance criterion is Resolution from package gp.

◆ Coord() [1/2]

constexpr double gp_Dir::Coord ( const int theIndex) const
inlineconstexpr

Returns the coordinate of range theIndex : theIndex = 1 => X is returned theIndex = 2 => Y is returned theIndex = 3 => Z is returned Exceptions Standard_OutOfRange if theIndex is not 1, 2, or 3.

◆ Coord() [2/2]

constexpr void gp_Dir::Coord ( double & theXv,
double & theYv,
double & theZv ) const
inlineconstexprnoexcept

Returns for the unit vector its three coordinates theXv, theYv, and theZv.

◆ Cross()

constexpr void gp_Dir::Cross ( const gp_Dir & theRight)
inlineconstexpr

Computes the cross product between two directions Raises the exception ConstructionError if the two directions are parallel because the computed vector cannot be normalized to create a direction.

Note
Constexpr-compatible when result is already normalized.

◆ CrossCross()

constexpr void gp_Dir::CrossCross ( const gp_Dir & theV1,
const gp_Dir & theV2 )
inlineconstexpr
Note
Constexpr-compatible when result is already normalized.

◆ CrossCrossed()

constexpr gp_Dir gp_Dir::CrossCrossed ( const gp_Dir & theV1,
const gp_Dir & theV2 ) const
inlineconstexpr

Computes the double vector product this ^ (theV1 ^ theV2).

  • CrossCrossed creates a new unit vector. Exceptions Standard_ConstructionError if:
  • theV1 and theV2 are parallel, or
  • this unit vector and (theV1 ^ theV2) are parallel. This is because, in these conditions, the computed vector is null and cannot be normalized.
    Note
    Constexpr-compatible when result is already normalized.

◆ Crossed()

constexpr gp_Dir gp_Dir::Crossed ( const gp_Dir & theRight) const
inlineconstexpr

Computes the triple vector product. <me> ^ (V1 ^ V2) Raises the exception ConstructionError if V1 and V2 are parallel or <me> and (V1^V2) are parallel because the computed vector can't be normalized to create a direction.

Note
Constexpr-compatible when result is already normalized.

◆ Dot()

constexpr double gp_Dir::Dot ( const gp_Dir & theOther) const
inlineconstexprnoexcept

Computes the scalar product.

◆ DotCross()

constexpr double gp_Dir::DotCross ( const gp_Dir & theV1,
const gp_Dir & theV2 ) const
inlineconstexprnoexcept

Computes the triple scalar product <me> * (theV1 ^ theV2). Warnings : The computed vector theV1' = theV1 ^ theV2 is not normalized to create a unitary vector. So this method never raises an exception even if theV1 and theV2 are parallel.

◆ DumpJson()

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

Dumps the content of me into the stream.

◆ InitFromJson()

bool gp_Dir::InitFromJson ( const Standard_SStream & theSStream,
int & theStreamPos )

Inits the content of me from the stream.

◆ IsEqual()

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

Returns True if the angle between the two directions is lower or equal to theAngularTolerance.

◆ IsNormal()

bool gp_Dir::IsNormal ( const gp_Dir & 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 (normal).

◆ IsOpposite()

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

Returns True if the angle between this unit vector and the unit vector theOther is equal to Pi (opposite).

◆ IsParallel()

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

Returns true if the angle between this unit vector and the unit vector theOther is equal to 0 or to Pi. Note: the tolerance criterion is given by theAngularTolerance.

◆ Mirror() [1/3]

void gp_Dir::Mirror ( const gp_Ax1 & theA1)
noexcept

◆ Mirror() [2/3]

void gp_Dir::Mirror ( const gp_Ax2 & theA2)
noexcept

◆ Mirror() [3/3]

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

◆ Mirrored() [1/3]

gp_Dir gp_Dir::Mirrored ( const gp_Ax1 & theA1) const
noexcept

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

◆ Mirrored() [2/3]

gp_Dir gp_Dir::Mirrored ( const gp_Ax2 & theA2) const
noexcept

Performs the symmetrical transformation of a direction with respect to a plane. The axis placement theA2 locates the plane of the symmetry : (Location, XDirection, YDirection).

◆ Mirrored() [3/3]

gp_Dir gp_Dir::Mirrored ( const gp_Dir & theV) const
noexcept

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

◆ operator*()

constexpr double gp_Dir::operator* ( const gp_Dir & theOther) const
inlineconstexprnoexcept

◆ operator-()

constexpr gp_Dir gp_Dir::operator- ( ) const
inlineconstexprnoexcept

◆ operator=() [1/2]

constexpr gp_Dir & gp_Dir::operator= ( const gp_Dir & )
constexprdefaultnoexcept

◆ operator=() [2/2]

constexpr gp_Dir & gp_Dir::operator= ( gp_Dir && )
constexprdefaultnoexcept

◆ operator^()

constexpr gp_Dir gp_Dir::operator^ ( const gp_Dir & theRight) const
inlineconstexpr

◆ operator^=()

constexpr void gp_Dir::operator^= ( const gp_Dir & theRight)
inlineconstexpr

◆ Reverse()

constexpr void gp_Dir::Reverse ( )
inlineconstexprnoexcept

◆ Reversed()

constexpr gp_Dir gp_Dir::Reversed ( ) const
inlineconstexprnoexcept

Reverses the orientation of a direction geometric transformations Performs the symmetrical transformation of a direction with respect to the direction V which is the center of the symmetry.

◆ Rotate()

void gp_Dir::Rotate ( const gp_Ax1 & theA1,
const double theAng )
inline

◆ Rotated()

gp_Dir gp_Dir::Rotated ( const gp_Ax1 & theA1,
const double theAng ) const
inline

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

◆ SetCoord() [1/2]

constexpr void gp_Dir::SetCoord ( const double theXv,
const double theYv,
const double theZv )
inlineconstexpr

For this unit vector, assigns the values theXv, theYv and theZv to its three coordinates. Remember that all the coordinates of a unit vector are implicitly modified when any single one is changed directly.

Note
Constexpr-compatible when input is already normalized.

◆ SetCoord() [2/2]

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

For this unit vector, assigns the value Xi to:

  • the X coordinate if theIndex is 1, or
  • the Y coordinate if theIndex is 2, or
  • the Z coordinate if theIndex is 3, 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, 2, or 3. Standard_ConstructionError if either of the following is less than or equal to gp::Resolution():
  • std::sqrt(Xv*Xv + Yv*Yv + Zv*Zv), or
  • the modulus of the number triple formed by the new value theXi and the two other coordinates of this vector that were not directly modified.
    Note
    Constexpr-compatible when result is already normalized.

◆ SetX()

constexpr void gp_Dir::SetX ( const double theX)
inlineconstexpr

Assigns the given value to the X coordinate of this unit vector.

Note
Constexpr-compatible when result is already normalized.

◆ SetXYZ()

constexpr void gp_Dir::SetXYZ ( const gp_XYZ & theCoord)
inlineconstexpr

Assigns the three coordinates of theCoord to this unit vector.

Note
Constexpr-compatible when input is already normalized.

◆ SetY()

constexpr void gp_Dir::SetY ( const double theY)
inlineconstexpr

Assigns the given value to the Y coordinate of this unit vector.

Note
Constexpr-compatible when result is already normalized.

◆ SetZ()

constexpr void gp_Dir::SetZ ( const double theZ)
inlineconstexpr

Assigns the given value to the Z coordinate of this unit vector.

Note
Constexpr-compatible when result is already normalized.

◆ Transform()

void gp_Dir::Transform ( const gp_Trsf & theT)

◆ Transformed()

gp_Dir gp_Dir::Transformed ( const gp_Trsf & theT) const
inline

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

◆ X()

constexpr double gp_Dir::X ( ) const
inlineconstexprnoexcept

Returns the X coordinate for a unit vector.

◆ XYZ()

constexpr const gp_XYZ & gp_Dir::XYZ ( ) const
inlineconstexprnoexcept

for this unit vector, returns its three coordinates as a number triple.

◆ Y()

constexpr double gp_Dir::Y ( ) const
inlineconstexprnoexcept

Returns the Y coordinate for a unit vector.

◆ Z()

constexpr double gp_Dir::Z ( ) const
inlineconstexprnoexcept

Returns the Z coordinate for a unit vector.


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