Clarisse 5.0 SP8 SDK  5.0.5.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Static Public Member Functions | List of all members
GMathQuaternion< T > Class Template Reference
Inheritance diagram for GMathQuaternion< T >:
CoreBaseType

Public Member Functions

 GMathQuaternion (void)
 Default constructor. Creates an identity quaternion.
 
IX_TMPLT GMathQuaternion (const U &s, const GMathVec3< U > &v)
 Construct from a real and imaginary parts.
 
IX_TMPLT GMathQuaternion (const GMathQuaternion< U > &q)
 Copy constructor.
 
T & operator[] (unsigned int index)
 
const T & operator[] (unsigned int index) const
 
GMathQuaternionoperator= (const GMathQuaternion &q)=default
 
GMathQuaternion operator* (const GMathQuaternion &q) const
 
GMathQuaternion operator+ (const GMathQuaternion &q) const
 
GMathQuaternion operator- (const GMathQuaternion &q) const
 
GMathQuaternion operator- () const
 
GMathQuaternion operator* (const double &d) const
 
GMathQuaternionoperator*= (const double &d)
 
GMathQuaternionoperator/= (const double &d)
 
bool is_equal_to (const GMathQuaternion &q, const double &epsilon=gmath_epsilon) const
 Check equality with another quaternion q within an epsilon.
 
bool operator== (const GMathQuaternion &q) const
 Equality operator.
 
bool operator!= (const GMathQuaternion &q) const
 Inequality operator.
 
double get_w (void) const
 
GMathVec3d get_xyz (void) const
 
double get_sqr_norm (void) const
 
double get_length (void) const
 
IX_TMPLT GMathQuaternionset_rotation (const U &m)
 
GMathQuaternionset_rotation (const double &angle, const GMathVec3d &axis)
 Set the quaternion from an angle/axis rotation.
 
GMathQuaternionset_rotation (const GMathVec3d &a, const GMathVec3d &b)
 
void get_rotation (double &angle, GMathVec3d &axis) const
 Extract the rotation as an angle/axis rotation.
 
IX_TMPLT void get_rotation (GMathMatrix3x3< U > &m) const
 Computes the rotation matrix represented by a unit quaternion.
 
IX_TMPLT void get_rotation (GMathMatrix4x4< U > &m) const
 Computes the rotation matrix represented by a unit quaternion.
 
void conjugate (void)
 
GMathQuaternion conjugated (void) const
 
void invert (void)
 Computes the inverse of this quaternion.
 
GMathQuaternion inverse (void) const
 
void normalize (void)
 
GMathQuaternion normalized (void) const
 
double dot (const GMathQuaternion &q) const
 
void rotate (GMathVec3d &v)
 Rotates the vector by this quaternion.
 
void swing_twist_decomposition (const GMathVec3d &direction, GMathQuaternion &swing, GMathQuaternion &twist)
 Decompose the rotation on to 2 parts. The rotation can be composed back as q = twist * swing.
 
void slerp (const GMathQuaternion &q0, const GMathQuaternion &q1, const double &t)
 
void slerp (const GMathQuaternion &q, const double &t)
 
const CoreClassInfoget_class_info (void) const
 
- Public Member Functions inherited from CoreBaseType
bool is_kindof (const CoreClassInfo &cinfo) const
 

Static Public Member Functions

static const GMathQuaternionget_identity (void)
 Get the identity quaternion.
 
static const CoreClassInfoclass_info (void)
 
- Static Public Member Functions inherited from CoreBaseType
static const CoreClassInfoclass_info ()
 Get the type descriptor of this instance.
 

Detailed Description

template<typename T>
class GMathQuaternion< T >

Quaternion rotation class. Use the specialized classes GMathQuath, GMathQuatf and GMathQuatd.

Template Parameters
TThe underlying data type.

Member Function Documentation

template<typename T>
void GMathQuaternion< T >::get_rotation ( GMathMatrix3x3< U > &  m) const
inline

Computes the rotation matrix represented by a unit quaternion.

Note
This does not check that this quaternion is normalized. The returned matrix will not be a rotation if the quaternion is non-unit.
template<typename T>
void GMathQuaternion< T >::get_rotation ( GMathMatrix4x4< U > &  m) const
inline

Computes the rotation matrix represented by a unit quaternion.

Note
This does not check that this quaternion is normalized. The returned matrix will not be a rotation if the quaternion is non-unit.
template<typename T >
void GMathQuaternion< T >::invert ( void  )
inline

Computes the inverse of this quaternion.

Note
If you know a priori that you're using a unit quaternion, it will be significantly faster to use conjugate() instead.
template<typename T >
T & GMathQuaternion< T >::operator[] ( unsigned int  index)
inline

Get the index'th element of the quaternion (0 is the real part, 1 to 3 is the imaginary part) as a modifiable reference. Contrary to get_w and get_xyz, there are no casts here.

template<typename T >
const T & GMathQuaternion< T >::operator[] ( unsigned int  index) const
inline

Get the index'th element of the quaternion (0 is the real part, 1 to 3 is the imaginary part) as a read-only reference. Contrary to get_w and get_xyz, there are no casts here.

template<typename T >
void GMathQuaternion< T >::rotate ( GMathVec3d &  v)
inline

Rotates the vector by this quaternion.

Warning
conjugated() is used instead of inverse() for better performance, thus this quaternion must be normalized.
template<typename T>
GMathQuaternion< T > & GMathQuaternion< T >::set_rotation ( const U &  m)
inline

Set the quaternion from the rotation part of a matrix.

Template Parameters
UThe type of the input matrix. It's automatically deduced, and works with 3x3 and 4x4 matrices.
Parameters
mThe matrix.
template<typename T >
void GMathQuaternion< T >::swing_twist_decomposition ( const GMathVec3d &  direction,
GMathQuaternion< T > &  swing,
GMathQuaternion< T > &  twist 
)
inline

Decompose the rotation on to 2 parts. The rotation can be composed back as q = twist * swing.

Parameters
directiontwist axis, normalized
swingrotation around axis that is perpendicular to "direction" vector
twistrotation around the "direction" vector
Note
Singularity in case of swing_rotation close to 180 degrees rotation is handled. If quaternion is of non-unit length, the outputs are non-unit as well, otherwise outputs are both unit