Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

math::quaternion Class Reference

A quaternion. More...

#include <quaternion.h>

Collaboration diagram for math::quaternion:

Collaboration graph
[legend]
List of all members.

Public Methods

 quaternion (void)
 Default Constructor. More...

 quaternion (const math::vector3 &v_, real_t w_)
 Constructor to set x y z w. More...

 quaternion (real_t x_, real_t y_, real_t z_, real_t w_)
 Constructor to set a x y z w. More...

 quaternion (const math::quaternion &p)
 Copy Constructor.

math::quaternion & operator= (const math::quaternion &p)
 Assignment Operator.

real_t w (void) const
 Returns a copy of w.

real_t x (void) const
 Returns a copy of x.

real_t y (void) const
 Returns a copy of y.

real_t z (void) const
 Returns a copy of z.

math::vector3 v (void) const
 Returns a copy of x y z. More...

math::vector3 vec (void) const
 Returns a copy of x y z. More...

real_t scalar (void) const
 Returns a copy of w. More...

void set (real_t x_, real_t y_, real_t z_, real_t w_)
 Sets the quaternion. More...

void set (const math::vector3 &v_, real_t w_)
 Sets the quaternion. More...

math::quaternion conjugate (void) const
 Returns the conjugate of the quaternion. More...

math::quaternion operator! (void) const
 Returns the inverse of the quaternion. More...

double magnitude (void) const
 Returns the magnitude of the quaternion. More...

void normalize (void)
 Normalizes the quaternion. More...

void set_identity (void)
 Sets the quaternion to the identity quaternion. More...

math::matrix4 get_rotation_matrix (void) const
 Returns the rotation matrix that describes this quaternion. More...

void get_rotation_matrix (math::matrix4 &m) const
 Sets a rotation matrix that describes this quaternion. More...

math::matrix4 get_transposed_rotation_matrix (void) const
 Returns the transposed rotation matrix that describes this quaternion. More...

void get_transposed_rotation_matrix (math::matrix4 &m) const
 Sets transposed rotation matrix that describes this quaternion. More...

math::quaternion operator * (const math::quaternion &rhs) const
 Quaternion Multiplication.

math::vector3 operator * (const math::vector3 &rhs) const
 Quaternion Vector Multiplication. More...

void from_angle_axis (real_t radians, const math::vector3 &axis)
 Creates a rotation matrix given around an arbitrary axis. More...

void get_angle_axis (real_t &radians, math::vector3 &axis) const
 Returns the angle and axis the quaternion describes. More...


Static Public Methods

math::quaternion slerp (real_t percent, const math::quaternion &qa, const math::quaternion &qb)
 Spherical Linear Interpretation. More...


Static Public Attributes

const math::quaternion IDENTITY
 The identity quaternion. More...


Friends

std::ostream & operator<< (std::ostream &o, const math::quaternion &vec)
 stream output operator. More...


Detailed Description

A quaternion.

Quaternions take on the form:

Note:
When sending the quaternion to OpenGL, use get_transposed_matrix().

Definition at line 25 of file quaternion.h.


Constructor & Destructor Documentation

math::quaternion::quaternion void    [inline]
 

Default Constructor.

Sets quaternion to .

Definition at line 41 of file quaternion.h.

math::quaternion::quaternion const math::vector3   v_,
real_t    w_
[inline]
 

Constructor to set x y z w.

Parameters:
v_  vector which defines the quaternion's x y z.
w_  real_t which define the quaternion's w.

Definition at line 49 of file quaternion.h.

References real_t.

math::quaternion::quaternion real_t    x_,
real_t    y_,
real_t    z_,
real_t    w_
[inline]
 

Constructor to set a x y z w.

Parameters:
x_  real_t which defines the quaternion's x.
y_  real_t which defines the quaternion's y.
z_  real_t which defines the quaternion's z.
w_  real_t which defines the quaternion's w.

Definition at line 59 of file quaternion.h.

References real_t.


Member Function Documentation

math::quaternion math::quaternion::conjugate void    const [inline]
 

Returns the conjugate of the quaternion.

The conjugate of the quaternion is defined as:

Note:
Do data within quaternion is modified. A copy of the quaternion is returned.

Definition at line 149 of file quaternion.h.

void math::quaternion::from_angle_axis real_t    radians,
const math::vector3   axis
 

Creates a rotation matrix given around an arbitrary axis.

Given an axis and an angle, this method will create a set this quaternion as the quaternion that describes the rotation around the axis by angle.

Note:
Rotations are right-handed.
Parameters:
radians  A real number in radians.
axis  A unit length vector describing the axis to rotate around.

Definition at line 142 of file quaternion.cpp.

References math::vector3::length, and real_t.

void math::quaternion::get_angle_axis real_t   radians,
math::vector3   axis
const
 

Returns the angle and axis the quaternion describes.

Parameters:
radians  The angle about axis in radians (output).
axis  The axis the quaternion's rotation is aroiund (output).
Returns:
Sets radians and axis.

Definition at line 154 of file quaternion.cpp.

References math::equals, magnitude, real_t, math::vector3::set, math::vector3::x, math::vector3::y, and math::vector3::z.

void math::quaternion::get_rotation_matrix math::matrix4   m const
 

Sets a rotation matrix that describes this quaternion.

Parameters:
m  A matrix4 where the rotation matrix will be written.

Definition at line 15 of file quaternion.cpp.

References real_t, math::matrix4::set, math::vector3::x, math::vector3::y, and math::vector3::z.

math::matrix4 math::quaternion::get_rotation_matrix void    const
 

Returns the rotation matrix that describes this quaternion.

Returns:
A matrix4 that describes the rotation this quaternion represents.

Definition at line 56 of file quaternion.cpp.

Referenced by operator *.

void math::quaternion::get_transposed_rotation_matrix math::matrix4   m const
 

Sets transposed rotation matrix that describes this quaternion.

Parameters:
m  A matrix4 where the rotation matrix will be written.
Note:
Use this method to send the quaternion to OpenGL functions such as glMultMatrix().

Definition at line 65 of file quaternion.cpp.

References real_t, math::matrix4::set, math::vector3::x, math::vector3::y, and math::vector3::z.

math::matrix4 math::quaternion::get_transposed_rotation_matrix void    const
 

Returns the transposed rotation matrix that describes this quaternion.

Note:
Use this method to send the quaternion to OpenGL functions such as glMultMatrix().
Returns:
A transposed matrix4 that describes the rotation this quaternion represents.

Definition at line 106 of file quaternion.cpp.

double math::quaternion::magnitude void    const [inline]
 

Returns the magnitude of the quaternion.

The magnitude of the quaternion is defined as:

Definition at line 169 of file quaternion.h.

Referenced by get_angle_axis.

void math::quaternion::normalize void    [inline]
 

Normalizes the quaternion.

\warn If the quaternion has zero magnitude, a divide by zero may be possible.

Definition at line 178 of file quaternion.h.

References math::vector3::x, math::vector3::y, and math::vector3::z.

math::vector3 math::quaternion::operator * const math::vector3   rhs const
 

Quaternion Vector Multiplication.

Multiplies the matrix that this quaternion describes by the vector rhs.

Definition at line 132 of file quaternion.cpp.

References get_rotation_matrix.

math::quaternion math::quaternion::operator! void    const [inline]
 

Returns the inverse of the quaternion.

The inverse of a normalized quaternion is defined as:

Note:
Assumes the quaternion is normalized. No normalization check is performed.

Definition at line 159 of file quaternion.h.

real_t math::quaternion::scalar void    const [inline]
 

Returns a copy of w.

See also:
w

Definition at line 116 of file quaternion.h.

References real_t.

void math::quaternion::set const math::vector3   v_,
real_t    w_
[inline]
 

Sets the quaternion.

Parameters:
v_  vector which defines the quaternion's x y z.
w_  real_t which define the quaternion's w.

Definition at line 138 of file quaternion.h.

References real_t.

void math::quaternion::set real_t    x_,
real_t    y_,
real_t    z_,
real_t    w_
[inline]
 

Sets the quaternion.

Parameters:
x_  real_t which defines the quaternion's x.
y_  real_t which defines the quaternion's y.
z_  real_t which defines the quaternion's z.
w_  real_t which defines the quaternion's w.

Definition at line 127 of file quaternion.h.

References real_t, and math::vector3::set.

void math::quaternion::set_identity void    [inline]
 

Sets the quaternion to the identity quaternion.

The identity quaternion is defined as:

Definition at line 192 of file quaternion.h.

References math::vector3::set.

math::quaternion math::quaternion::slerp real_t    percent,
const math::quaternion &    qa,
const math::quaternion &    qb
[static]
 

Spherical Linear Interpretation.

Interprets the between the two rotations that qa and qb describe.

Parameters:
percent  A real_t between [0-1] descibing how much to interpret between qa and qb.

Definition at line 180 of file quaternion.cpp.

References math::equals, real_t, v, w, x, y, and z.

math::vector3 math::quaternion::v void    const [inline]
 

Returns a copy of x y z.

See also:
vec
Returns:
A vector containing x y z.

Definition at line 99 of file quaternion.h.

Referenced by slerp.

math::vector3 math::quaternion::vec void    const [inline]
 

Returns a copy of x y z.

See also:
v
Returns:
A vector containing x y z.

Definition at line 108 of file quaternion.h.


Friends And Related Function Documentation

std::ostream& operator<< std::ostream &    o,
const math::quaternion &    vec
[friend]
 

stream output operator.

Outputs quaternion as x y z w.

Definition at line 207 of file quaternion.cpp.


Member Data Documentation

const math::quaternion math::quaternion::IDENTITY [static]
 

The identity quaternion.

The identity quaternion is described as:


Generated on Tue Feb 11 18:49:50 2003 for uber by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002