Quaternion< T > Class Template Reference

#include <vmath.h>

List of all members.

Public Member Functions

 Quaternion ()
 Quaternion (const Quaternion< T > &q)
 Quaternion (T w_, const Vector3< T > &v_)
 Quaternion (T w_, T x, T y, T z)
Quaternion< T > & operator= (const Quaternion< T > &rhs)
Quaternion< T > operator+ (const Quaternion< T > &rhs) const
Quaternion< T > operator * (const Quaternion< T > &rhs) const
Quaternion< T > operator * (T rhs) const
Quaternion< T > operator- (const Quaternion< T > &rhs) const
Quaternion< T > & operator+= (const Quaternion< T > &rhs)
Quaternion< T > & operator-= (const Quaternion< T > &rhs)
Quaternion< T > & operator *= (const Quaternion< T > &rhs)
Quaternion< T > & operator *= (T rhs)
bool operator== (const Quaternion< T > &rhs) const
bool operator!= (const Quaternion< T > &rhs) const
length ()
lengthSq ()
void normalize ()
Matrix3< T > rotMatrix ()
Matrix4< T > transform ()
Quaternion< T > lerp (T fact, const Quaternion< T > &rhs) const
Quaternion< T > slerp (T r, const Quaternion< T > &q2) const

Static Public Member Functions

static Quaternion< T > fromEulerAngles (T x, T y, T z)
static Quaternion< T > fromAxisRot (Vector3< T > axis, float angleDeg)
static Quaternion< T > fromMatrix (const Matrix4< T > &m)
static Quaternion< T > fromMatrix (const Matrix3< T > &m)

Public Attributes

w
Vector3< T > v

Friends

std::ostream & operator<< (std::ostream &oss, const Quaternion< T > &q)


Detailed Description

template<class T>
class Quaternion< T >

Quaternion class implementing some quaternion algebra operations. Quaternion is kind of complex number it consists of its real part (w) and its complex part v. This complex part has three elements, so we can express it as xi + yj + zk . Note that coordinates of (x,y,z) are hold inside v field.


Constructor & Destructor Documentation

template<class T>
Quaternion< T >::Quaternion (  )  [inline]

Quaternion constructor, sets quaternion to (0 + 0i + 0j + 0k).

template<class T>
Quaternion< T >::Quaternion ( const Quaternion< T > &  q  )  [inline]

Copy constructor.

template<class T>
Quaternion< T >::Quaternion ( w_,
const Vector3< T > &  v_ 
) [inline]

Creates quaternion object from real part w_ and complex part v_.

Parameters:
w_ Real part of quaternion.
v_ Complex part of quaternion (xi + yj + zk).

template<class T>
Quaternion< T >::Quaternion ( w_,
x,
y,
z 
) [inline]

Creates quaternion object from value (w_ + xi + yj + zk).

Parameters:
w_ Real part of quaternion.
x Complex cooeficinet for i complex constant.
y Complex cooeficinet for j complex constant.
z Complex cooeficinet for k complex constant.


Member Function Documentation

template<class T>
Quaternion<T>& Quaternion< T >::operator= ( const Quaternion< T > &  rhs  )  [inline]

Copy operator

Parameters:
rhs Right hand side argument of binary operator.

template<class T>
Quaternion<T> Quaternion< T >::operator+ ( const Quaternion< T > &  rhs  )  const [inline]

Addition operator

Parameters:
rhs Right hand side argument of binary operator.

template<class T>
Quaternion<T> Quaternion< T >::operator * ( const Quaternion< T > &  rhs  )  const [inline]

Multiplication operator

Parameters:
rhs Right hand side argument of binary operator.

template<class T>
Quaternion<T> Quaternion< T >::operator * ( rhs  )  const [inline]

Multiplication operator

Parameters:
rhs Right hand side argument of binary operator.

template<class T>
Quaternion<T> Quaternion< T >::operator- ( const Quaternion< T > &  rhs  )  const [inline]

Substraction operator

Parameters:
rhs Right hand side argument of binary operator.

template<class T>
Quaternion<T>& Quaternion< T >::operator+= ( const Quaternion< T > &  rhs  )  [inline]

Addition operator

Parameters:
rhs Right hand side argument of binary operator.

template<class T>
Quaternion<T>& Quaternion< T >::operator-= ( const Quaternion< T > &  rhs  )  [inline]

Substraction operator

Parameters:
rhs Right hand side argument of binary operator.

template<class T>
Quaternion<T>& Quaternion< T >::operator *= ( const Quaternion< T > &  rhs  )  [inline]

Multiplication operator

Parameters:
rhs Right hand side argument of binary operator.

template<class T>
Quaternion<T>& Quaternion< T >::operator *= ( rhs  )  [inline]

Multiplication operator

Parameters:
rhs Right hand side argument of binary operator.

template<class T>
bool Quaternion< T >::operator== ( const Quaternion< T > &  rhs  )  const [inline]

Equality test operator

Parameters:
rhs Right hand side argument of binary operator.
Note:
Test of equality is based of threshold EPSILON value. To be two values equal, must satisfy this condition | lws - rhs | < EPSILON, for all quaternion coordinates.

template<class T>
bool Quaternion< T >::operator!= ( const Quaternion< T > &  rhs  )  const [inline]

Inequality test operator

Parameters:
rhs Right hand side argument of binary operator.
Returns:
not (lhs == rhs) :-P

template<class T>
T Quaternion< T >::length (  )  [inline]

Get lenght of quaternion.

Returns:
Length of quaternion.

template<class T>
T Quaternion< T >::lengthSq (  )  [inline]

Return square of length.

Returns:
lenght ^ 2
Note:
This method is faster then length(). For comparsion of length of two quaternion can be used just this value, instead of computionaly more expensive length() method.

template<class T>
void Quaternion< T >::normalize (  )  [inline]

Normalize quaternion

template<class T>
static Quaternion<T> Quaternion< T >::fromEulerAngles ( x,
y,
z 
) [inline, static]

Creates quaternion for eulers angles.

Parameters:
x Rotation around x axis (in degrees).
y Rotation around y axis (in degrees).
z Rotation around z axis (in degrees).
Returns:
Quaternion object representing transoformation.

template<class T>
static Quaternion<T> Quaternion< T >::fromAxisRot ( Vector3< T >  axis,
float  angleDeg 
) [inline, static]

Creates quaternion as rotation around axis.

Parameters:
axis Unit vector expressing axis of rotation.
angleDeg Angle of rotation around axis (in degrees).

template<class T>
Matrix3<T> Quaternion< T >::rotMatrix (  )  [inline]

Converts quaternion into rotation matrix.

Returns:
Rotation matrix expresing this quaternion.

template<class T>
Matrix4<T> Quaternion< T >::transform (  )  [inline]

Converts quaternion into transformation matrix.

Note:
This method performs same operation as rotMatrix() conversion method. But returns Matrix of 4x4 elements.
Returns:
Transformation matrix expressing this quaternion.

template<class T>
Quaternion<T> Quaternion< T >::lerp ( fact,
const Quaternion< T > &  rhs 
) const [inline]

Linear interpolation of two quaternions

Parameters:
fact Factor of interpolation. For translation from positon of this vector to quaternion rhs, values of factor goes from 0.0 to 1.0.
rhs Second Quaternion for interpolation
Note:
Hovewer values of fact parameter are reasonable only in interval [0.0 , 1.0], you can pass also values outside of this interval and you can get result (extrapolation?)

template<class T>
static Quaternion<T> Quaternion< T >::fromMatrix ( const Matrix4< T > &  m  )  [inline, static]

Creates quaternion from transform matrix.

Parameters:
m Transfrom matrix used to compute quaternion.
Returns:
Quaternion representing rotation of matrix m.

template<class T>
static Quaternion<T> Quaternion< T >::fromMatrix ( const Matrix3< T > &  m  )  [inline, static]

Creates quaternion from rotation matrix.

Parameters:
m Rotation matrix used to compute quaternion.
Returns:
Quaternion representing rotation of matrix m.

template<class T>
Quaternion<T> Quaternion< T >::slerp ( r,
const Quaternion< T > &  q2 
) const [inline]

Computes spherical interpolation between quaternions (this, q2) using coeficient of interpolation r (in [0, 1]).

Parameters:
r The ratio of interpolation form this (r = 0) to q2 (r = 1).
q2 Second quaternion for interpolation.
Returns:
Result of interpolation.


Friends And Related Function Documentation

template<class T>
std::ostream& operator<< ( std::ostream &  oss,
const Quaternion< T > &  q 
) [friend]

Provides output to standard output stream.


Member Data Documentation

template<class T>
T Quaternion< T >::w

Real part of quaternion.

template<class T>
Vector3<T> Quaternion< T >::v

Complex part of quaternion.


The documentation for this class was generated from the following file:
Generated on Wed Jan 17 14:53:45 2007 for iTunesIslands by  doxygen 1.5.1-p1