CFx SDK Documentation 2024 SP0
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
OdGeQuaternion Class Reference

#include <GeQuaternion.h>

Public Member Functions

 OdGeQuaternion ()
 
 OdGeQuaternion (double ww, double xx, double yy, double zz)
 
OdGeQuaternionset (double ww, double xx, double yy, double zz)
 
OdGeQuaternionset (const OdGeMatrix3d &matrix)
 
OdGeMatrix3d getMatrix () const
 
OdGePoint3d rotate (OdGePoint3d &sourcePoint) const
 
OdGeVector3d rotate (OdGeVector3d &vector) const
 
OdGePoint3d rotateOpposite (OdGePoint3d &sourcePoint) const
 
OdGeVector3d rotateOpposite (OdGeVector3d &vector) const
 
bool isEqualTo (const OdGeQuaternion &quat, const OdGeTol &tol=OdGeContext::gTol) const
 
bool operator== (const OdGeQuaternion &quat) const
 
bool operator!= (const OdGeQuaternion &quat) const
 
OdGeQuaternion operator* (double scale) const
 
OdGeQuaternionoperator*= (double scale)
 
OdGeQuaternion operator/ (double scale) const
 
OdGeQuaternionoperator/= (double scale)
 
OdGeQuaternion operator+ (const OdGeQuaternion &quat) const
 
OdGeQuaternionoperator+= (const OdGeQuaternion &quat)
 
OdGeQuaternion operator- (const OdGeQuaternion &quat) const
 
OdGeQuaternionoperator-= (const OdGeQuaternion &quat)
 
OdGeQuaternion operator- () const
 
double normSqrd () const
 
double norm () const
 
OdGeQuaternionnormalize (const OdGeTol &tol=OdGeContext::gTol)
 
double dotProduct (const OdGeQuaternion &quat) const
 
OdGeQuaternion slerp (OdGeQuaternion &q, double t, bool bUseShortestPath)
 

Public Attributes

double w
 
double x
 
double y
 
double z
 

Static Public Attributes

static GE_STATIC_EXPORT const OdGeQuaternion kIdentity
 

Detailed Description

This class represents a rotation quaternion in 3D space. Quaternions provide a convenient mathematical notation for representing orientations and rotations of objects in three dimensions. Quaternions resolve the problem of "gimbal locks".

The quaternion consists of 2 components:

  1. Component of rotation (WW)
  2. Components of rotation axis (XX, YY, ZZ)

To define quaternion components, use following formulas:

 WW = cos(angle/2)
 XX = x*sin(angle/2)
 YY = y*sin(angle/2)
 ZZ = z*sin(angle/2)
 

where angle is an angle of desired counter clockwise rotation specified in radians, x, y, z - components of a 3D unit vector that represents axis of rotation. For example, a quaternion that rotates 1.5 radian CCW by the x axis (unit vector(1,0,0)), looks the following way:

     WW            XX             YY             ZZ
 cos(1.5/2)   1*sin(1.5/2)   0*sin(1.5/2)   0*sin(1.5/2)
 

Quaternions can be converted to rotation matrix (OdGeMatrix3d) or vice versa. Note, that there can be an ambiguity in rotation matrix representation. We use Hamilton multiplication convention for OdGeQuaternion.

Corresponding C++ library: TD_Ge

<group OdGe_Classes>

Definition at line 69 of file GeQuaternion.h.

Constructor & Destructor Documentation

◆ OdGeQuaternion() [1/2]

OdGeQuaternion::OdGeQuaternion ( )
inline

Default constructor for the OdGeQuaternion class.

Remarks
The default constructor constructs an identity quaternion (1., 0., 0., 0.).

Definition at line 79 of file GeQuaternion.h.

◆ OdGeQuaternion() [2/2]

OdGeQuaternion::OdGeQuaternion ( double  ww,
double  xx,
double  yy,
double  zz 
)
inline

Constructor for the OdGeQuaternion class.

Parameters
ww[in] The W-component of this quaternion object.
xx[in] The X-component of this quaternion object.
yy[in] The Y-component of this quaternion object.
zz[in] The Z-component of this quaternion object.
Remarks
Constructs a quaternion with specified components.

Definition at line 94 of file GeQuaternion.h.

Member Function Documentation

◆ dotProduct()

double OdGeQuaternion::dotProduct ( const OdGeQuaternion quat) const
inline

Returns the dot product of this quaternion and the specified quaternion.

Parameters
quat[in] Any quaternion to be multiplied with this quaternion.

Definition at line 418 of file GeQuaternion.h.

◆ getMatrix()

OdGeMatrix3d OdGeQuaternion::getMatrix ( ) const
inline

Calculates 3D rotation matrix that represents this quaternion.

Remarks
This quaternion should be normalized, i.e. norm() should be equal to one.
Returns
OdGeMatrix3d object representing this quaternion.

Definition at line 135 of file GeQuaternion.h.

◆ isEqualTo()

bool OdGeQuaternion::isEqualTo ( const OdGeQuaternion quat,
const OdGeTol tol = OdGeContext::gTol 
) const
inline

Returns true if and only if quat is identical to this quaternion, within the specified tolerance.

Parameters
quat[in] Quaternion to be compared to this quaternion.
tol[in] Geometric tolerance.

Definition at line 223 of file GeQuaternion.h.

◆ norm()

double OdGeQuaternion::norm ( ) const

Returns the norm of this quaternion.

◆ normalize()

OdGeQuaternion & OdGeQuaternion::normalize ( const OdGeTol tol = OdGeContext::gTol)

Sets this quaternion to the unit quaternion and returns a reference to this quaternion

Parameters
tol[in] Geometric tolerance.
Remarks
If this.norm() <= tol, this quaternion is unchanged.

◆ normSqrd()

double OdGeQuaternion::normSqrd ( ) const
inline

Returns the square of the norm of this quaternion.

Definition at line 396 of file GeQuaternion.h.

◆ operator!=()

bool OdGeQuaternion::operator!= ( const OdGeQuaternion quat) const
inline

Inequality operator. Returns true if this quaternion is not equal to the input quaternion.

Parameters
quat[in] Input quaternion that is checked for inequality.

Definition at line 248 of file GeQuaternion.h.

◆ operator*()

OdGeQuaternion OdGeQuaternion::operator* ( double  scale) const
inline

Multiplication operator for the OdGeQuaternion class.

Parameters
scale[in] Input scale factor.
Returns
A new scaled quaternion.

Definition at line 261 of file GeQuaternion.h.

◆ operator*=()

OdGeQuaternion & OdGeQuaternion::operator*= ( double  scale)
inline

Multiplication operator for the OdGeQuaternion class.

Parameters
scale[in] Input scale factor.
Returns
Reference to this OdGeQuaternion object.
Remarks
Scales this quaternion by scale factor.

Definition at line 277 of file GeQuaternion.h.

◆ operator+()

OdGeQuaternion OdGeQuaternion::operator+ ( const OdGeQuaternion quat) const
inline

Addition operator for the OdGeQuaternion class.

Parameters
quat[in] Input quaternion, component values of which are added to component values of this quaternion.
Returns
A quaternion with summed components.

Definition at line 327 of file GeQuaternion.h.

◆ operator+=()

OdGeQuaternion & OdGeQuaternion::operator+= ( const OdGeQuaternion quat)
inline

Addition operator for the OdGeQuaternion class.

Parameters
quat[in] A reference to a quaternion, component values of which are added to component values of this quaternion.
Returns
Reference to a quaternion with summed components.

Definition at line 341 of file GeQuaternion.h.

◆ operator-() [1/2]

OdGeQuaternion OdGeQuaternion::operator- ( ) const
inline

Inverse operator.

Remarks
Returns a quaternion with inverse component values according to this quaternion.

Definition at line 391 of file GeQuaternion.h.

◆ operator-() [2/2]

OdGeQuaternion OdGeQuaternion::operator- ( const OdGeQuaternion quat) const
inline

Subtraction operator for the OdGeQuaternion class.

Parameters
quat[in] Input quaternion, component values of which are subtracted from component values of this quaternion.
Returns
A quaternion with subtracted components.

Definition at line 359 of file GeQuaternion.h.

◆ operator-=()

OdGeQuaternion & OdGeQuaternion::operator-= ( const OdGeQuaternion quat)
inline

Subtraction operator for the OdGeQuaternion class.

Parameters
quat[in] A reference to a quaternion, component values of which are subtracted from component values of this quaternion.
Returns
Reference to a quaternion with subtracted components.

Definition at line 373 of file GeQuaternion.h.

◆ operator/()

OdGeQuaternion OdGeQuaternion::operator/ ( double  scale) const
inline

Division operator for the OdGeQuaternion class.

Parameters
scale[in] Input scale factor.
Returns
Quaternion equal to this quaternion divided by the scale factor.

Definition at line 295 of file GeQuaternion.h.

◆ operator/=()

OdGeQuaternion & OdGeQuaternion::operator/= ( double  scale)
inline

Division operator for the OdGeQuaternion class.

Parameters
scale[in] Input scale factor.
Returns
Reference to a quaternion that is divided by the scale factor.

Definition at line 309 of file GeQuaternion.h.

◆ operator==()

bool OdGeQuaternion::operator== ( const OdGeQuaternion quat) const
inline

Equality operator. Returns true if this quaternion is equal to the input quaternion.

Parameters
quat[in] Input quaternion that is checked for equality.

Definition at line 238 of file GeQuaternion.h.

◆ rotate() [1/2]

OdGePoint3d OdGeQuaternion::rotate ( OdGePoint3d sourcePoint) const
inline

Rotates specified 3D point using this quaternion.

Parameters
sourcePoint[out] A 3D point that is rotated.
Returns
rotated 3D point.

Definition at line 161 of file GeQuaternion.h.

◆ rotate() [2/2]

OdGeVector3d OdGeQuaternion::rotate ( OdGeVector3d vector) const
inline

Rotates specified 3D vector using this quaternion.

Parameters
vector[out] A 3D vector that is rotated.
Returns
rotated 3D vector.

Definition at line 175 of file GeQuaternion.h.

◆ rotateOpposite() [1/2]

OdGePoint3d OdGeQuaternion::rotateOpposite ( OdGePoint3d sourcePoint) const
inline

Rotates specified 3D point using this quaternion but in the opposite direction.

Parameters
sourcePoint[out] A 3D point that is rotated.
Returns
rotated 3D point.

Definition at line 193 of file GeQuaternion.h.

◆ rotateOpposite() [2/2]

OdGeVector3d OdGeQuaternion::rotateOpposite ( OdGeVector3d vector) const
inline

Rotates specified 3D vector using this quaternion but in the opposite direction.

Parameters
vector[out] A 3D vector that is rotated.
Returns
rotated 3D vector.

Definition at line 207 of file GeQuaternion.h.

◆ set() [1/2]

OdGeQuaternion & OdGeQuaternion::set ( const OdGeMatrix3d matrix)

Converts passed rotation matrix into the quaternion.

Parameters
matrix[in] A 3D matrix that defines components of this quaternion.
Remarks
Input matrix A must be a rotation matrix, i.e. A^T = A^-1 and det(A) = 1.
Returns
reference to this OdGeQuaternion object.

◆ set() [2/2]

OdGeQuaternion & OdGeQuaternion::set ( double  ww,
double  xx,
double  yy,
double  zz 
)
inline

Set components for the quaternion and returns a reference to it.

Parameters
ww[in] The W-component of this quaternion object.
xx[in] The X-component of this quaternion object.
yy[in] The Y-component of this quaternion object.
zz[in] The Z-component of this quaternion object.

Definition at line 106 of file GeQuaternion.h.

◆ slerp()

OdGeQuaternion OdGeQuaternion::slerp ( OdGeQuaternion q,
double  t,
bool  bUseShortestPath 
)

Performs spherical linear interpolation, introduced by Ken Shoemake in the context of quaternion interpolation. It refers to constant-speed motion along a unit-radius great circle arc, given the ends and an interpolation parameter between 0 and 1

Parameters
q[in] second quaternion to be interpolated between (first is this quaternion)
t[in] a scalar between 0.0 (at p) and 1.0 (at q)
bUseShortestPath[in] boolean that indicates whether to compute quaternions that constitute the shortest possible arc on a four-dimensional unit sphere.

Member Data Documentation

◆ kIdentity

GE_STATIC_EXPORT const OdGeQuaternion OdGeQuaternion::kIdentity
static

Identity quaternion (1, 0, 0, 0), i.e. a quaternion that doesn't cause any rotation.

Definition at line 453 of file GeQuaternion.h.

◆ w

double OdGeQuaternion::w

Scalar part.

Definition at line 436 of file GeQuaternion.h.

◆ x

double OdGeQuaternion::x

First vector part.

Definition at line 440 of file GeQuaternion.h.

◆ y

double OdGeQuaternion::y

Second vector part.

Definition at line 444 of file GeQuaternion.h.

◆ z

double OdGeQuaternion::z

Third vector part.

Definition at line 448 of file GeQuaternion.h.


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