In file matrix.h:

class quaternion

Quaternion class.

Public Fields

[more]double r
scalar component
[more]double i
1st vector component
[more]double j
2nd vector component
[more]double k
3rd vector component

Public Methods

[more]inline quaternion(void)
constructs a quaternion equal to (1, 0, 0, 0), which represents a zero rotation
[more] quaternion(int zero)
constructs a quaternion equal to (1, 0, 0, 0), which represents a zero rotation
[more] quaternion(const matrix &m)
constructs a quaternion corresponding to a rotation matrix.
[more] quaternion(const tmatrix &m)
constructs a quaternion corresponding to t's rotation component
[more]inline quaternion(double d, const triple &t)
constructs a quaternion
[more]inline quaternion(double R, double I, double J, double K)
constructs a quaternion with the supplied components
[more]void normalize(void)
normalizes the quaternion
[more] member overloaded operators


Documentation

Quaternion class. If you're not familiar with quaternions, their key properties are: Quaternions can be manually initialized or they can be typecast from matrix or tmatrix objects. A handy trick for computing a quaternion representing a rotation of 'a' about an axis 'axis' is:
 quaternion q(cos(a/2), sin(a/2)*axis);
 

To rotate a triple 't' by a quaternion 'q', the syntax is

 tRotated = q*t*(~q);
 
where ~ is the complement operator for quaternions. To rotate a triple 't' by the inverse of a quaternion 'q', the syntax is
 tUnrotated = (~q)*t*q;
 
Note that it's a good idea to include the parentheses to ensure that the complement is computed correctly.
odouble r
scalar component

odouble i
1st vector component

odouble j
2nd vector component

odouble k
3rd vector component

oinline quaternion(void)
constructs a quaternion equal to (1, 0, 0, 0), which represents a zero rotation

o quaternion(int zero)
constructs a quaternion equal to (1, 0, 0, 0), which represents a zero rotation

o quaternion(const matrix &m)
constructs a quaternion corresponding to a rotation matrix. NOTE: m must be 3x3 or 4x4 (in which case only the upper-left 3x3 block is used), and must represent a valid rotation.

o quaternion(const tmatrix &m)
constructs a quaternion corresponding to t's rotation component

oinline quaternion(double d, const triple &t)
constructs a quaternion

oinline quaternion(double R, double I, double J, double K)
constructs a quaternion with the supplied components

ovoid normalize(void)
normalizes the quaternion

o member overloaded operators

oquaternion& operator=(int zero)
sets the quaternion to the zero rotation

oquaternion& operator=(const matrix &m)
sets q to the rotation represented by m. m must be 3x3 or 4x4 (in which case only the upper 3x3 block is used) and must represent a valid rotation.

oquaternion& operator=(const tmatrix &m)
sets q to the rotation component of m

oquaternion& operator=(const quaternion &q)
assignment operator

oquaternion& operator*=(double d)
scalar multiplication

oquaternion& operator/=(double d)
scalar division

oquaternion operator-(void) const
returns the negatino of the quaternion

oquaternion operator~(void) const
returns the complement of the quaternion


This class has no child classes.
Friends:
quaternion normalize(const quaternion &q)
quaternion operator+(const quaternion &q1, const quaternion &q2)
quaternion operator-(const quaternion &q1, const quaternion &q2)
quaternion operator*(const quaternion &q1, const quaternion &q2)
quaternion operator*(const quaternion &q, const triple &t)
quaternion operator*(const triple &t, const quaternion &q)
quaternion operator*(const quaternion &q, double d)
quaternion operator*(double d, const quaternion &q)
quaternion operator/(const quaternion &q, double d)
double abs(const quaternion &q)
double sqr(const quaternion &q)

Alphabetic index HTML hierarchy of classes or Java



This page was generated with the help of DOC++.