chai3d::cQuaternion Struct Reference

This class implements a quaternion. More...

#include <CQuaternion.h>

Public Member Functions

 cQuaternion ()
 Constructor of cQuaternion. More...
 
 cQuaternion (double a_w, double a_x, double a_y, double a_z)
 Constructor of cQuaternion. More...
 
 cQuaternion (double const *in)
 Constructor of cQuaternion. More...
 
 operator double * ()
 Cast quaternion to a double*. More...
 
 operator double const * () const
 Cast quaternion to a double const*. More...
 
cQuaternionoperator*= (cQuaternion const &a_quaternion)
  *= operator (Grassman product). More...
 
cQuaternionoperator*= (double a_scale)
  *= operator. More...
 
cQuaternionoperator+= (cQuaternion const &a_quaternion)
  += operator. More...
 
cQuaternionoperator-= (cQuaternion const &a_quaternion)
  -= operator. More...
 
bool operator== (cQuaternion const &a_quaternion) const
  == operator. More...
 
void zero ()
 This method clears this quaternion with zeros. More...
 
void negate ()
 This method negates this quaternion. More...
 
double magsq () const
 This method returns the squared value of the quaternion magnitude. More...
 
double lengthsq () const
 This method returns the squared value of the quaternion magnitude. More...
 
double mag () const
 This method returns the quaternion magnitude. More...
 
double length () const
 This method returns the quaternion magnitude. More...
 
void normalize ()
 This method normalizes this quaternion. More...
 
void toRotMat (cMatrix3d &a_matrix) const
 This method convert this quaternion into a rotation matrix. More...
 
void fromRotMat (cMatrix3d const &a_matrix)
 This method converts a rotation matrix into a quaternion. More...
 
void fromAxisAngle (cVector3d a_axis, double a_angleRad)
 This method converts an axis-angle representation into a quaternion. More...
 
void toAxisAngle (cVector3d &a_axis, double &a_angleRad) const
 This method converts a quaternion representation into an axis-angle representation. More...
 
void conj ()
 This method computes the conjugate of this quaternion. More...
 
void invert ()
 This method inverts this quaternion. More...
 
void mul (cQuaternion const &a_quaternion)
 This method computes the multiplication of this quaternion with another quaternion. More...
 
void mul (double a_scale)
 This method multiplies this quaternion by a scalar. More...
 
double dot (cQuaternion const &a_quaternion) const
 This method computes the dot product between this quaternion and another quaternion. More...
 
void add (cQuaternion const &a_quaternion)
 This method computes the addition between this quaternion and another passed as argument. More...
 
void sub (cQuaternion const &a_quaternion)
 This method computes the subtraction between this quaternion and another passed as argument. More...
 
void slerp (double a_level, cQuaternion const &a_quaternion0, cQuaternion a_quaternion1)
 This method computes a spherical linear interpolation between two quaternions (SLERP). More...
 
std::string str (const unsigned int a_precision=2) const
 This method converts this quaternion into a string. More...
 

Public Attributes

double w
 Component w of quaternion. More...
 
double x
 Component x of quaternion. More...
 
double y
 Component y of quaternion. More...
 
double z
 Component z of quaternion. More...
 

Detailed Description

cQuaternion is a class that models quaternions and provides some basic operations.
Unit quaternions provide a convenient mathematical notation for representing orientations and rotations of objects in three dimensions. Compared to Euler angles they are simpler to compose and avoid the problem of gimbal lock.

Constructor & Destructor Documentation

chai3d::cQuaternion::cQuaternion ( )
inline
chai3d::cQuaternion::cQuaternion ( double  a_w,
double  a_x,
double  a_y,
double  a_z 
)
inline
chai3d::cQuaternion::cQuaternion ( double const *  in)
inline

Member Function Documentation

chai3d::cQuaternion::operator double * ( )
inline
chai3d::cQuaternion::operator double const * ( ) const
inline
cQuaternion& chai3d::cQuaternion::operator*= ( cQuaternion const &  a_quaternion)
inline
cQuaternion& chai3d::cQuaternion::operator*= ( double  a_scale)
inline
cQuaternion& chai3d::cQuaternion::operator+= ( cQuaternion const &  a_quaternion)
inline
cQuaternion& chai3d::cQuaternion::operator-= ( cQuaternion const &  a_quaternion)
inline
bool chai3d::cQuaternion::operator== ( cQuaternion const &  a_quaternion) const
inline
void chai3d::cQuaternion::zero ( )
inline
void chai3d::cQuaternion::negate ( )
inline
double chai3d::cQuaternion::magsq ( ) const
inline
double chai3d::cQuaternion::lengthsq ( ) const
inline
double chai3d::cQuaternion::mag ( ) const
inline
double chai3d::cQuaternion::length ( ) const
inline
void chai3d::cQuaternion::normalize ( )
inline
void chai3d::cQuaternion::toRotMat ( cMatrix3d a_matrix) const
inline

This method convert this quaternion into a rotation matrix passed as argument a_matrix.
The result is stored in matrix a_matrix past as argument.

Parameters
a_matrixResult of operation.
void chai3d::cQuaternion::fromRotMat ( cMatrix3d const &  a_matrix)
inline

This method converts a rotation matrix into a quaternion.
The result of this operation is stored in this quaternion.

Parameters
a_matrixInput rotation matrix.
void chai3d::cQuaternion::fromAxisAngle ( cVector3d  a_axis,
double  a_angleRad 
)
inline

This method converts an axis-angle representation into a quaternion.
The result of this operation is stored in current quaternion.

Parameters
a_axisAxis vector.
a_angleRadAngle in radians.
void chai3d::cQuaternion::toAxisAngle ( cVector3d a_axis,
double &  a_angleRad 
) const
inline

This method converts a quaternion representation into an axis-angle representation
. The result of this operation is stored in both arguments a_axis and a_angleRad.

Parameters
a_axisOutput result axis vector.
a_angleRadOutput result angle in radians.
void chai3d::cQuaternion::conj ( )
inline

This method computes the conjugate of this quaternion.
The result of this operation is stored in this quaternion.

void chai3d::cQuaternion::invert ( )
inline

This method inverts this quaternion. The inverse of a quaternion is equal to conjugate/magsq .
The result of this operation is stored in this quaternion.

void chai3d::cQuaternion::mul ( cQuaternion const &  a_quaternion)
inline

This method computes the multiplication of this quaternion with another quaternion passed as argument a_quaternion.
The result of this operation is stored in this quaternion.

Parameters
a_quaternionInput quaternion.
void chai3d::cQuaternion::mul ( double  a_scale)
inline

This method scales this quaternion by a scalar a_scale passed as argument.
The result of this operation is stored in this quaternion.

Parameters
a_scaleScale factor.
double chai3d::cQuaternion::dot ( cQuaternion const &  a_quaternion) const
inline

This method computes and returns the dot product between this quaternion and another quaternion a_quaternion passed as argument.

Parameters
a_quaternionInput quaternion.
Returns
Dot product between both quaternions.
void chai3d::cQuaternion::add ( cQuaternion const &  a_quaternion)
inline

This method computes the addition between this quaternion and another a_quaternion passed as argument.
The result of this operation is stored in this quaternion.

Parameters
a_quaternionInput quaternion.
void chai3d::cQuaternion::sub ( cQuaternion const &  a_quaternion)
inline

This method computes the subtraction between this quaternion and another a_quaternion passed as argument.
The result of this operation is stored in this quaternion.

Parameters
a_quaternionInput quaternion.
void chai3d::cQuaternion::slerp ( double  a_level,
cQuaternion const &  a_quaternion0,
cQuaternion  a_quaternion1 
)
inline

This method computes a spherical linear interpolation between two quaternions (SLERP) passed by argument as _a_quaternion0 and a_quaternion1.
The interpolation value a_level is set between 0.0 (fully at a_quaternion0) and 1.0 (fully at a_quaternion1)
The result of this operation is stored in this quaternion.

Parameters
a_levelInterpolation value.
a_quaternion0Starting quaternion.
a_quaternion1Ending quaternion.
std::string chai3d::cQuaternion::str ( const unsigned int  a_precision = 2) const
inline

This method converts this quaternion into a string. The number of digits after the decimal point are set by argument a_precision.

Parameters
a_precisionNumber of digits.
Returns
Converted quaternion in string format.

Member Data Documentation

double chai3d::cQuaternion::w
double chai3d::cQuaternion::x
double chai3d::cQuaternion::y
double chai3d::cQuaternion::z

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