QSDK 1.1 Documentation
Main Page | Modules | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members | Related Pages

Maths::Quat4f Struct Reference
[QMaths]

#include <Q/maths.h>

List of all members.

Public Member Functions

 Quat4f ()
 Quat4f (float v)
 Quat4f (const Quat4f &q)
 Quat4f (const Vec4f &v)
 Quat4f (float x1, float y1, float z1, float w1)
 Quat4f (const Vec3f &axis, float angle)
 Quat4f (const Vec3f &)
 Quat4f (const Matrix3f &m)
 Quat4f (const Vec3f &dir, const Vec3f &up)
 Quat4f (const Matrix4f &m, bool normalise=false)
 Quat4f (const Affine4f &m, bool normalise=false)
void setIdentity ()
void setRotation (const Vec3f &axis, float angle)
void setRotation (const Vec3f &direction, const Vec3f &up)
void setMatrix (const Matrix3f &m, bool normalise=false)
void addRotation (const Vec3f &axis, float angle)
bool isIdentity () const
void mult (float)
void mult (const Quat4f &q)
void imult (const Quat4f &q)
void mult (const Quat4f &a, const Quat4f &b)
void getDirection (Vec3f &dir) const
void getUpVector (Vec3f &up) const
void getAxis (Vec3f &axis) const
Quat4foperator *= (const Quat4f &q)
Quat4foperator *= (float v)
Vec3f up () const
Vec3f direction () const
Quat4f invert () const
Vec3f axis () const
float angle () const
bool equal (const Quat4f &v, float e=Epsilon) const

Protected Member Functions

Vec3fvec3 ()
const Vec3fvec3 () const

Friends

Quat4f operator * (const Quat4f &a, const Quat4f &b)
Quat4f interpolate (float t, const Quat4f &a, const Quat4f &b)
Quat4f sInterpolate (float t, const Quat4f &a, const Quat4f &b)


Detailed Description

Quaternion algebra representation. Although it is not enforced, all quaternions should be of unit length for them to work as expected.


Constructor & Destructor Documentation

Maths::Quat4f::Quat4f  )  [inline]
 

Build an uninitialised quaternion.

Maths::Quat4f::Quat4f float  v  )  [inline, explicit]
 

Initialise all elements of the quaternion to v.

Maths::Quat4f::Quat4f const Quat4f q  )  [inline]
 

Copy the value of q into this quaternion.

Maths::Quat4f::Quat4f const Vec4f v  )  [inline]
 

Copy the values held in v into this quaterion.

Maths::Quat4f::Quat4f float  x1,
float  y1,
float  z1,
float  w1
[inline]
 

Write the values of the quaternion directly.

Maths::Quat4f::Quat4f const Vec3f axis,
float  angle
[inline]
 

Build a quaternion from a unit direction vector and a rotation angle about that vector.

Maths::Quat4f::Quat4f const Vec3f  )  [explicit]
 

Build a quaternion from a unit direction vector and a rotation angle specified by the modulus of the vector.

Maths::Quat4f::Quat4f const Matrix3f m  )  [inline]
 

Build a quaternion from a rotation matrix. The matrix should be orthonormal and not contain any scale.

Maths::Quat4f::Quat4f const Vec3f dir,
const Vec3f up
[inline]
 

Build a quaternion from a direction vector and an up vector.

The vectors do not need to be normalized or orthogonal. The up vector will be adjusted within the plane of the two vectors to be orthogonal to the direction vector.

The result is undefined if the two vectors are parallel.

Maths::Quat4f::Quat4f const Matrix4f m,
bool  normalise = false
 

Build a quaternion from a matrix. If the matrix contains scale then normalise should be set to true.

Maths::Quat4f::Quat4f const Affine4f m,
bool  normalise = false
[explicit]
 

Build a quaternion from a matrix. If the matrix contains scale then normalise should be set to true.


Member Function Documentation

void Maths::Quat4f::addRotation const Vec3f axis,
float  angle
 

Create a temporary quaternion from an axis and an angle and multiply the quaternion by it.

float Maths::Quat4f::angle  )  const [inline]
 

Return the angle part of the quaternion.

Vec3f Maths::Quat4f::axis  )  const [inline]
 

Return the axis part of the quaternion.

Vec3f Maths::Quat4f::direction  )  const [inline]
 

Return the direction vector represented by the vector.

bool Maths::Quat4f::equal const Quat4f v,
float  e = Epsilon
const
 

Return true if v represents the same rotation as this quaternion, with an error of e. This method expects unit quaternions.

void Maths::Quat4f::getAxis Vec3f axis  )  const [inline]
 

Get the axis part of the quaternion.

void Maths::Quat4f::getDirection Vec3f dir  )  const [inline]
 

Get the direction vector represented by the quaternion.

void Maths::Quat4f::getUpVector Vec3f up  )  const [inline]
 

Get the up vector represented by the quaternion.

void Maths::Quat4f::imult const Quat4f q  ) 
 

Set the quaternion to be q rotated by the quaternion.

Quat4f Maths::Quat4f::invert  )  const
 

Return the inverse quaternion. This does not modify the existing quaternion. This method expects unit quaternions.

bool Maths::Quat4f::isIdentity  )  const [inline]
 

Return true if the quaternion is the identity quaternion.

void Maths::Quat4f::mult const Quat4f a,
const Quat4f b
 

Set the quaternion to be a rotated by b

void Maths::Quat4f::mult const Quat4f q  ) 
 

Rotate the quaternion by the quaternion q

void Maths::Quat4f::mult float   ) 
 

Scale the quaternion by the value.

Quat4f& Maths::Quat4f::operator *= float  v  )  [inline]
 

Scale the quaternion by and return the answer.

Quat4f& Maths::Quat4f::operator *= const Quat4f q  )  [inline]
 

Rotate the quaternion by q and return the answer.

void Maths::Quat4f::setIdentity  ) 
 

Set the quaternion to the identity quaternion.

void Maths::Quat4f::setMatrix const Matrix3f m,
bool  normalise = false
 

Set the quaternion to the value represented by a matrix. If the matrix contains scale then normalise should be set to true.

void Maths::Quat4f::setRotation const Vec3f direction,
const Vec3f up
 

Set the quaternion to the value represented by a direction vector and an up vector.

The vectors do not need to be normalized or orthogonal. The up vector will be adjusted within the plane of the two vectors to be orthogonal to the direction vector.

The result is undefined if the two vectors are parallel.

void Maths::Quat4f::setRotation const Vec3f axis,
float  angle
 

Set the quaternion to the value represented by a unit direction vector and a rotation angle about that vector.

Vec3f Maths::Quat4f::up  )  const [inline]
 

Return the up vector represented by the vector.


Friends And Related Function Documentation

Quat4f interpolate float  t,
const Quat4f a,
const Quat4f b
[friend]
 

Linearly interpolate between a and b. This method is faster than sInterpolate, but less accurate and does not conserve the normality of the quaternions. For reasonable accuracy, the quaternions should not be too dissimilar. In particular, interpolation between a quaternion and its inverse should be avoided. t should be in the range [0, 1]. If t is 0 then a is returned and if t is 1 then b is returned. This method expects unit quaternions.

Quat4f operator * const Quat4f a,
const Quat4f b
[friend]
 

Return the rotation of a by b.

Quat4f sInterpolate float  t,
const Quat4f a,
const Quat4f b
[friend]
 

Spherical linear interpolate between a and b. t should be in the range [0, 1]. If t is 0 then a is returned and if t is 1 then b is returned. Interpolation between a quaternion and its inverse is handled without singularity. This method expects unit quaternions.

Return to QSDK documentation Contents page. Contact details for support, information and fault-reporting.
Qube Software Limited © 2000-2004