xc
Public Member Functions | Static Public Member Functions | List of all members
XC::ASDQuaternion< T > Class Template Reference

ASDQuaternion A simple class that implements the main features of quaternion algebra. More...

#include <ASDMath.h>

Public Member Functions

 ASDQuaternion ()
 Creates a Zero ASDQuaternion.
 
 ASDQuaternion (T w, T x, T y, T z)
 Creates a ASDQuaternion from its coefficients. More...
 
 ASDQuaternion (const ASDQuaternion &other)
 Creates a ASDQuaternion from another ASDQuaternion. More...
 
ASDQuaternionoperator= (const ASDQuaternion &other)
 Copies a ASDQuaternion. More...
 
const T x () const
 Returns the X coefficient of this quaternion. More...
 
const T y () const
 Returns the Y coefficient of this quaternion. More...
 
const T z () const
 Returns the Z coefficient of this quaternion. More...
 
const T w () const
 Returns the W coefficient of this quaternion. More...
 
const T squaredNorm () const
 Returns the squared norm of this quaternion. More...
 
const T norm () const
 Returns the norm of this quaternion. More...
 
void normalize ()
 Makes this ASDQuaternion a Unit ASDQuaternion. More...
 
ASDQuaternion conjugate () const
 Returns the Conjugate of this ASDQuaternion, which represents the opposite rotation. More...
 
template<class TMatrix3x3 >
void toRotationMatrix (TMatrix3x3 &R) const
 Constructs a Rotation Matrix from this ASDQuaternion. More...
 
void toRotationVector (T &rx, T &ry, T &rz) const
 Extracts the Rotation Vector from this ASDQuaternion. More...
 
template<class TVector3 >
void toRotationVector (TVector3 &v) const
 Extracts the Rotation Vector from this ASDQuaternion The vector type is the template parameter. More...
 
template<class TVector3_A , class TVector3_B >
void rotateVector (const TVector3_A &a, TVector3_B &b) const
 Rotates a vector using this quaternion. More...
 
template<class TVector3 >
void rotateVector (TVector3 &a) const
 Rotates a vector using this quaternion. More...
 

Static Public Member Functions

static ASDQuaternion Identity ()
 Returns the Identity ASDQuaternion (i.e. More...
 
static ASDQuaternion FromAxisAngle (T x, T y, T z, T radians)
 Returns a ASDQuaternion that represents a rotation of an angle 'radians' around the axis (x, y, z) More...
 
static ASDQuaternion FromRotationVector (T rx, T ry, T rz)
 Returns a ASDQuaternion from a rotation vector. More...
 
template<class TVector3 >
static ASDQuaternion FromRotationVector (const TVector3 &v)
 Returns a ASDQuaternion from a rotation vector. More...
 
template<class TMatrix3x3 >
static ASDQuaternion FromRotationMatrix (const TMatrix3x3 &m)
 Returns a ASDQuaternion from a Rotation Matrix. More...
 

Detailed Description

template<class T>
class XC::ASDQuaternion< T >

ASDQuaternion A simple class that implements the main features of quaternion algebra.

Constructor & Destructor Documentation

◆ ASDQuaternion() [1/2]

template<class T>
XC::ASDQuaternion< T >::ASDQuaternion ( w,
x,
y,
z 
)
inline

Creates a ASDQuaternion from its coefficients.

Parameters
ww coefficient
xx coefficient
yy coefficient
zz coefficient

◆ ASDQuaternion() [2/2]

template<class T>
XC::ASDQuaternion< T >::ASDQuaternion ( const ASDQuaternion< T > &  other)
inline

Creates a ASDQuaternion from another ASDQuaternion.

Parameters
otherthe other ASDQuaternion

Member Function Documentation

◆ conjugate()

template<class T>
ASDQuaternion XC::ASDQuaternion< T >::conjugate ( ) const
inline

Returns the Conjugate of this ASDQuaternion, which represents the opposite rotation.

Returns
the Conjugate of this ASDQuaternion

◆ FromAxisAngle()

template<class T>
static ASDQuaternion XC::ASDQuaternion< T >::FromAxisAngle ( x,
y,
z,
radians 
)
inlinestatic

Returns a ASDQuaternion that represents a rotation of an angle 'radians' around the axis (x, y, z)

Parameters
xthe x component of the rotation axis
ythe y component of the rotation axis
zthe z component of the rotation axis
radiansthe rotation angle in radians
Returns
a ASDQuaternion that represents a rotation of an angle 'radians' around the axis (x, y, z)

◆ FromRotationMatrix()

template<class T>
template<class TMatrix3x3 >
static ASDQuaternion XC::ASDQuaternion< T >::FromRotationMatrix ( const TMatrix3x3 &  m)
inlinestatic

Returns a ASDQuaternion from a Rotation Matrix.

The rotation matrix type is the template argument, no check is made on the type of this matrix. These assumptions are made: The matrix should provide an indexed access like m(i, j) where i and j are indices from 0 to 2. This means that the input matrix is a C-Style 3x3 Matrix.

Parameters
mthe source rotation matrix
Returns
a ASDQuaternion from a Rotation Matrix

◆ FromRotationVector() [1/2]

template<class T>
static ASDQuaternion XC::ASDQuaternion< T >::FromRotationVector ( rx,
ry,
rz 
)
inlinestatic

Returns a ASDQuaternion from a rotation vector.

Parameters
rxthe x component of the source rotation vector
rythe y component of the source rotation vector
rzthe z component of the source rotation vector
Returns
a ASDQuaternion from a rotation vector

◆ FromRotationVector() [2/2]

template<class T>
template<class TVector3 >
static ASDQuaternion XC::ASDQuaternion< T >::FromRotationVector ( const TVector3 &  v)
inlinestatic

Returns a ASDQuaternion from a rotation vector.

The vector type is the template parameter. No check is made on this type. The following assumptions are made: The vector type should provide indexing like vector(i) where i goes from 0 to 2. (i.e. a C-Style vector of size 3)

Parameters
vthe source rotation vector
Returns
a ASDQuaternion from a rotation vector

◆ Identity()

template<class T>
static ASDQuaternion XC::ASDQuaternion< T >::Identity ( )
inlinestatic

Returns the Identity ASDQuaternion (i.e.

a ASDQuaternion that represents a Zero rotation)

Returns
the Identity ASDQuaternion

◆ norm()

template<class T>
const T XC::ASDQuaternion< T >::norm ( ) const
inline

Returns the norm of this quaternion.

sqrt(x*x + y*y + z*z + w*w)

Returns
the norm of this quaternion.

◆ normalize()

template<class T>
void XC::ASDQuaternion< T >::normalize ( )
inline

Makes this ASDQuaternion a Unit ASDQuaternion.

If this ASDQuaternion is already normalized this is a no-op

◆ operator=()

template<class T>
ASDQuaternion& XC::ASDQuaternion< T >::operator= ( const ASDQuaternion< T > &  other)
inline

Copies a ASDQuaternion.

Parameters
otherthe other ASDQuaternion

◆ rotateVector() [1/2]

template<class T>
template<class TVector3_A , class TVector3_B >
void XC::ASDQuaternion< T >::rotateVector ( const TVector3_A &  a,
TVector3_B &  b 
) const
inline

Rotates a vector using this quaternion.

Note: this is faster than constructing the rotation matrix and perform the matrix multiplication for a single vector. The vector type is the template parameter. No check is made on this type. The following assumptions are made: The vector type should provide indexing like vector(i) where i goes from 0 to 2. (i.e. a C-Style vector of size 3)

Parameters
athe input source vector
bthe output rotated vector

◆ rotateVector() [2/2]

template<class T>
template<class TVector3 >
void XC::ASDQuaternion< T >::rotateVector ( TVector3 &  a) const
inline

Rotates a vector using this quaternion.

Note: this is faster than constructing the rotation matrix and perform the matrix multiplication for a single vector. The vector type is the template parameter. No check is made on this type. The following assumptions are made: The vector type should provide indexing like vector(i) where i goes from 0 to 2. (i.e. a C-Style vector of size 3)

Parameters
athe input source vector - rotated on exit

◆ squaredNorm()

template<class T>
const T XC::ASDQuaternion< T >::squaredNorm ( ) const
inline

Returns the squared norm of this quaternion.

x*x + y*y + z*z + w*w

Returns
the squared norm of this quaternion.

◆ toRotationMatrix()

template<class T>
template<class TMatrix3x3 >
void XC::ASDQuaternion< T >::toRotationMatrix ( TMatrix3x3 &  R) const
inline

Constructs a Rotation Matrix from this ASDQuaternion.

The rotation matrix type is the template argument, no check is made on the type of this matrix. These assumptions are made: The matrix should provide an indexed access like m(i, j) where i and j are indices from 0 to 2. This means that the input matrix is a C-Style 3x3 Matrix. All the 9 coefficients are properly set so there's no need to set the matrix to Zero before calling this function.

Parameters
Rthe output rotation matrix

◆ toRotationVector() [1/2]

template<class T>
void XC::ASDQuaternion< T >::toRotationVector ( T &  rx,
T &  ry,
T &  rz 
) const
inline

Extracts the Rotation Vector from this ASDQuaternion.

Parameters
rxthe output x component if the rotation vector
rythe output y component if the rotation vector
rzthe output z component if the rotation vector

◆ toRotationVector() [2/2]

template<class T>
template<class TVector3 >
void XC::ASDQuaternion< T >::toRotationVector ( TVector3 &  v) const
inline

Extracts the Rotation Vector from this ASDQuaternion The vector type is the template parameter.

No check is made on this type. The following assumptions are made: The vector type should provide indexing like vector(i) where i goes from 0 to 2. (i.e. a C-Style vector of size 3)

Parameters
vthe output rotation vector

◆ w()

template<class T>
const T XC::ASDQuaternion< T >::w ( ) const
inline

Returns the W coefficient of this quaternion.

Returns
the W coefficient of this quaternion.

◆ x()

template<class T>
const T XC::ASDQuaternion< T >::x ( ) const
inline

Returns the X coefficient of this quaternion.

Returns
the X coefficient of this quaternion.

◆ y()

template<class T>
const T XC::ASDQuaternion< T >::y ( ) const
inline

Returns the Y coefficient of this quaternion.

Returns
the Y coefficient of this quaternion.

◆ z()

template<class T>
const T XC::ASDQuaternion< T >::z ( ) const
inline

Returns the Z coefficient of this quaternion.

Returns
the Z coefficient of this quaternion.

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