Om  1.0.0
A universal framework for multimedia simulation
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
om::math::Quaternion4D< T > Class Template Reference

A templatized math class representing a 4-component quaternion. More...

#include <omQuaternion.h>

Public Member Functions

 Quaternion4D ()
 Create a new identity quaternion corresponding to no rotation. More...
 
 Quaternion4D (T newW, T newX, T newY, T newZ)
 Create a new quaternion by specifying it's 4 component values. More...
 
 Quaternion4D (const T array[4])
 Create a new quaternion from a pointer to a 4 element array specifying its components. More...
 
 Quaternion4D (T angle, const VectorND< T, 3 > &axis)
 Create a new unit quaternion from a normalized axis and angle representation. More...
 
 Quaternion4D (const MatrixND< T, 3, 3 > &m)
 Create a new quaternion from a 3x3 orthonormal rotation matrix. More...
 
template<typename U >
 Quaternion4D (const Quaternion4D< U > &quaternion)
 Create a new quaternion from an existing quaternion with different template type. More...
 
getMagnitude () const
 Return the magnitude (norm) of this quaternion. More...
 
getNorm () const
 Return the magnitude (norm) of this quaternion. More...
 
getMagnitudeSquared () const
 Return the squared magnitude (norm) of this quaternion. More...
 
Quaternion4D< T > normalize () const
 Return a normalized version of this quaternion. More...
 
Quaternion4D< T > normalize (T &magnitude) const
 Return a normalized version of this quaternion, placing the quaternion's magnitude in the output parameter. More...
 
Quaternion4D< T > invert () const
 Return the inverse of this quaternion. More...
 
Quaternion4D< T > invertNormalized () const
 Return the inverse of this normalized quaternion. More...
 
MatrixND< T, 3, 3 > toMatrix () const
 Return the inverse of this quaternion. More...
 
MatrixND< T, 3, 3 > toMatrixNormalized () const
 Return the inverse of this normalized quaternion. More...
 
const T * toArray () const
 Return a shallow array representation of this quaternion. More...
 
getW () const
 Return the W coordinate (real part) of this quaternion. More...
 
getX () const
 Return the X coordinate of this quaternion. More...
 
getY () const
 Return the Y coordinate of this quaternion. More...
 
getZ () const
 Return the Z coordinate of this quaternion. More...
 
getXYZ () const
 Return the XYZ vector of this quaternion. More...
 
getAngle () const
 Return the rotation angle in radians that this quaternion describes. More...
 
VectorND< T, 3 > getAxis () const
 Return the normalized axis of rotation for this quaternion. More...
 
Bool operator== (const Quaternion4D< T > &q) const
 Compare two quaternions component-wise for equality. More...
 
Bool operator!= (const Quaternion4D< T > &q) const
 Compare two quaternions component-wise for inequality. More...
 
Quaternion4D< T > operator+ (const Quaternion4D< T > &q) const
 Add this quaternion to another and return the result. More...
 
Quaternion4D< T > operator- (const Quaternion4D< T > &q) const
 Subtract a quaternion from this quaternion component-wise and return the result. More...
 
Quaternion4D< T > operator* (const Quaternion4D< T > &q) const
 Multiply this quaternion and another quaternion. More...
 
Quaternion4D< T > operator* (const T &value) const
 Multiply every component of this quaternion by a value and return the result. More...
 
Quaternion4D< T > operator/ (const T &value) const
 Divide every component of this quaternion by a value and return the result. More...
 
Quaternion4D< T > & operator+= (const Quaternion4D< T > &q)
 Add a quaternion to this quaternion, modifying this original quaternion. More...
 
Quaternion4D< T > & operator-= (const Quaternion4D< T > &q)
 Subtract a quaternion from this quaternion, modifying this original quaternion. More...
 
Quaternion4D< T > & operator*= (const Quaternion4D< T > &q)
 Multiply component-wise this quaternion and another quaternion and modify this quaternion. More...
 
Quaternion4D< T > & operator*= (const T &value)
 Multiply a value with each component of this quaternion, modifying it. More...
 
Quaternion4D< T > & operator/= (const T &value)
 Divide each component of this quaternion by a value, modifying it. More...
 
data::String toString () const
 Convert this quaternion into a human-readable string representation. More...
 
 operator data::String () const
 Convert this quaternion into a human-readable string representation. More...
 

Public Attributes

w
 The W coordinate of a quaternion, the real coordinate. More...
 
x
 The X coordinate of a quaternion, the first imaginary coordinate. More...
 
y
 The Y coordinate of a quaternion, the second imaginary coordinate. More...
 
z
 The Z coordinate of a quaternion, the third imaginary coordinate. More...
 

Static Public Attributes

static const Quaternion4D< T > ZERO
 A constant quaternion with all elements equal to zero. More...
 
static const Quaternion4D< T > IDENTITY
 A constant quaternion representing no rotation. More...
 

Detailed Description

template<typename T>
class om::math::Quaternion4D< T >

A templatized math class representing a 4-component quaternion.

Constructor & Destructor Documentation

template<typename T >
om::math::Quaternion4D< T >::Quaternion4D ( )
inline

Create a new identity quaternion corresponding to no rotation.

template<typename T >
om::math::Quaternion4D< T >::Quaternion4D ( newW,
newX,
newY,
newZ 
)
inline

Create a new quaternion by specifying it's 4 component values.

template<typename T >
om::math::Quaternion4D< T >::Quaternion4D ( const T  array[4])
inline

Create a new quaternion from a pointer to a 4 element array specifying its components.

template<typename T >
om::math::Quaternion4D< T >::Quaternion4D ( angle,
const VectorND< T, 3 > &  axis 
)
inline

Create a new unit quaternion from a normalized axis and angle representation.

template<typename T >
om::math::Quaternion4D< T >::Quaternion4D ( const MatrixND< T, 3, 3 > &  m)
inline

Create a new quaternion from a 3x3 orthonormal rotation matrix.

template<typename T >
template<typename U >
om::math::Quaternion4D< T >::Quaternion4D ( const Quaternion4D< U > &  quaternion)
inline

Create a new quaternion from an existing quaternion with different template type.

This constructor takes the x, y, z, and w values of the quaternion parameter and sets the coordinates of this quaternion to be the same. This is a templatized version of the copy constructor.

Parameters
quaternion- The quaternion to be copied.

Member Function Documentation

template<typename T >
T om::math::Quaternion4D< T >::getMagnitude ( ) const
inline

Return the magnitude (norm) of this quaternion.

template<typename T >
T om::math::Quaternion4D< T >::getNorm ( ) const
inline

Return the magnitude (norm) of this quaternion.

template<typename T >
T om::math::Quaternion4D< T >::getMagnitudeSquared ( ) const
inline

Return the squared magnitude (norm) of this quaternion.

template<typename T >
Quaternion4D<T> om::math::Quaternion4D< T >::normalize ( ) const
inline

Return a normalized version of this quaternion.

This method normalizes this quaternion by dividing each component by the quaternion's magnitude and returning the result. This method does not modify the original quaternion.

Returns
a normalized version of this quaternion.
template<typename T >
Quaternion4D<T> om::math::Quaternion4D< T >::normalize ( T &  magnitude) const
inline

Return a normalized version of this quaternion, placing the quaternion's magnitude in the output parameter.

This method normalizes this quaternion by dividing each component by the quaternion's magnitude and returning the result. This method does not modify the original quaternion. The magnitude of the original quaternion is returned in the output parameter.

Returns
a normalized version of this quaternion.
template<typename T >
Quaternion4D<T> om::math::Quaternion4D< T >::invert ( ) const
inline

Return the inverse of this quaternion.

This method makes no assumptions about the quaternion's magnitude. If inverting a unit-length quaternion, use invertNormalized() instead because it is significantly fast.

template<typename T >
Quaternion4D<T> om::math::Quaternion4D< T >::invertNormalized ( ) const
inline

Return the inverse of this normalized quaternion.

This method assumes that the quaternion is of unit length. This greatly simplifies the calculations needed to invert the quaternion.

template<typename T >
MatrixND<T,3,3> om::math::Quaternion4D< T >::toMatrix ( ) const
inline

Return the inverse of this quaternion.

This method makes no assumptions about the quaternion's magnitude. If converting a unit-length quaternion, use toMatrixNormalized() instead because it is significantly faster.

template<typename T >
MatrixND<T,3,3> om::math::Quaternion4D< T >::toMatrixNormalized ( ) const
inline

Return the inverse of this normalized quaternion.

This method assumes that the quaternion is of unit length. This greatly simplifies the calculations needed to convert the quaternion to a matrix.

template<typename T >
const T* om::math::Quaternion4D< T >::toArray ( ) const
inline

Return a shallow array representation of this quaternion.

This method returns a pointer to the address of the X coordinate of the quaternion and does not do any copying of the elements. Therefore, this method should only be used where one needs an array representation of a quaternion without having to allocate more memory and copy the quaternion.

Returns
A pointer to a shallow array copy of this quaternion.
template<typename T >
T om::math::Quaternion4D< T >::getW ( ) const
inline

Return the W coordinate (real part) of this quaternion.

template<typename T >
T om::math::Quaternion4D< T >::getX ( ) const
inline

Return the X coordinate of this quaternion.

template<typename T >
T om::math::Quaternion4D< T >::getY ( ) const
inline

Return the Y coordinate of this quaternion.

template<typename T >
T om::math::Quaternion4D< T >::getZ ( ) const
inline

Return the Z coordinate of this quaternion.

template<typename T >
T om::math::Quaternion4D< T >::getXYZ ( ) const
inline

Return the XYZ vector of this quaternion.

template<typename T >
T om::math::Quaternion4D< T >::getAngle ( ) const
inline

Return the rotation angle in radians that this quaternion describes.

template<typename T >
VectorND<T,3> om::math::Quaternion4D< T >::getAxis ( ) const
inline

Return the normalized axis of rotation for this quaternion.

template<typename T >
Bool om::math::Quaternion4D< T >::operator== ( const Quaternion4D< T > &  q) const
inline

Compare two quaternions component-wise for equality.

template<typename T >
Bool om::math::Quaternion4D< T >::operator!= ( const Quaternion4D< T > &  q) const
inline

Compare two quaternions component-wise for inequality.

template<typename T >
Quaternion4D<T> om::math::Quaternion4D< T >::operator+ ( const Quaternion4D< T > &  q) const
inline

Add this quaternion to another and return the result.

This method adds another quaternion to this one, component-wise, and returns this addition. It does not modify either of the original quaternions.

Parameters
q- The quaternion to add to this one.
Returns
The addition of this quaternion and the parameter.
template<typename T >
Quaternion4D<T> om::math::Quaternion4D< T >::operator- ( const Quaternion4D< T > &  q) const
inline

Subtract a quaternion from this quaternion component-wise and return the result.

This method subtracts another quaternion from this one, component-wise, and returns this subtraction. It does not modify either of the original quaternions.

Parameters
q- The quaternion to subtract from this one.
Returns
The subtraction of the the parameter from this quaternion.
template<typename T >
Quaternion4D<T> om::math::Quaternion4D< T >::operator* ( const Quaternion4D< T > &  q) const
inline

Multiply this quaternion and another quaternion.

This operation, like matrix multiplication, is not commutative.

template<typename T >
Quaternion4D<T> om::math::Quaternion4D< T >::operator* ( const T &  value) const
inline

Multiply every component of this quaternion by a value and return the result.

This method multiplies the value parameter with every component of the quaternion, and returns a quaternion representing this result. It does not modifiy the original quaternion.

Parameters
value- The value to multiplly with all components of this quaternion.
Returns
The resulting quaternion of this multiplication.
template<typename T >
Quaternion4D<T> om::math::Quaternion4D< T >::operator/ ( const T &  value) const
inline

Divide every component of this quaternion by a value and return the result.

This method divides every component of the quaternion by the value parameter, and returns a quaternion representing this result. It does not modifiy the original quaternion.

Parameters
value- The value to divide all components of this quaternion by.
Returns
The resulting quaternion of this division.
template<typename T >
Quaternion4D<T>& om::math::Quaternion4D< T >::operator+= ( const Quaternion4D< T > &  q)
inline

Add a quaternion to this quaternion, modifying this original quaternion.

This method adds another quaternion to this quaternion, component-wise, and sets this quaternion to have the result of this addition.

Parameters
q- The quaternion to add to this quaternion.
Returns
A reference to this modified quaternion.
template<typename T >
Quaternion4D<T>& om::math::Quaternion4D< T >::operator-= ( const Quaternion4D< T > &  q)
inline

Subtract a quaternion from this quaternion, modifying this original quaternion.

This method subtracts another quaternion from this quaternion, component-wise, and sets this quaternion to have the result of this subtraction.

Parameters
q- The quaternion to subtract from this quaternion.
Returns
A reference to this modified quaternion.
template<typename T >
Quaternion4D<T>& om::math::Quaternion4D< T >::operator*= ( const Quaternion4D< T > &  q)
inline

Multiply component-wise this quaternion and another quaternion and modify this quaternion.

This operator multiplies each component of this quaternion by the corresponding component of the other quaternion and modifies this quaternion to contain the result.

Parameters
q- The quaternion to multiply this quaternion by.
Returns
A reference to this modified quaternion.
template<typename T >
Quaternion4D<T>& om::math::Quaternion4D< T >::operator*= ( const T &  value)
inline

Multiply a value with each component of this quaternion, modifying it.

This operator multiplies a value with each component of this quaternion and modifies this quaternion to store the result.

Parameters
value- The value to multiply with every component of this quaternion.
Returns
A reference to this modified quaternion.
template<typename T >
Quaternion4D<T>& om::math::Quaternion4D< T >::operator/= ( const T &  value)
inline

Divide each component of this quaternion by a value, modifying it.

This operator Divides each component of this quaternion by value and modifies this quaternion to store the result.

Parameters
value- The value to multiply with every component of this quaternion.
Returns
A reference to this modified quaternion.
template<typename T >
data::String om::math::Quaternion4D< T >::toString ( ) const
inline

Convert this quaternion into a human-readable string representation.

template<typename T >
om::math::Quaternion4D< T >::operator data::String ( ) const
inline

Convert this quaternion into a human-readable string representation.

Member Data Documentation

template<typename T >
T om::math::Quaternion4D< T >::w

The W coordinate of a quaternion, the real coordinate.

template<typename T >
T om::math::Quaternion4D< T >::x

The X coordinate of a quaternion, the first imaginary coordinate.

template<typename T >
T om::math::Quaternion4D< T >::y

The Y coordinate of a quaternion, the second imaginary coordinate.

template<typename T >
T om::math::Quaternion4D< T >::z

The Z coordinate of a quaternion, the third imaginary coordinate.

template<typename T >
const Quaternion4D< T > om::math::Quaternion4D< T >::ZERO
static

A constant quaternion with all elements equal to zero.

template<typename T >
const Quaternion4D< T > om::math::Quaternion4D< T >::IDENTITY
static

A constant quaternion representing no rotation.


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