K3dQuaternion Class Reference

#include <K3dQuaternion.h>

List of all members.

Public Member Functions

 K3dQuaternion ()
 K3dQuaternion (float fW, float fX, float fY, float fZ)
 K3dQuaternion (K3dQuaternion &rkQ)
 K3dQuaternion (K3dVector4 kVec4)
 K3dQuaternion (float afVector[4])
 ~K3dQuaternion ()
 K3dQuaternion (K3dMatrix &rkRot)
 Quaternion for the input rotation matrix.
 K3dQuaternion (K3dVector3 &rkAxis, float fAngle)
 Quaternion for the rotation of the axis-angle pair.
 K3dQuaternion (K3dVector3 akRotColumn[3])
 Quaternion for the rotation matrix with specified columns.
 operator const float * () const
 Member access: 0 = w, 1 = x, 2 = y, 3 = z.
 operator float * ()
float operator[] (int i) const
float & operator[] (int i)
float W () const
float & W ()
float X () const
float & X ()
float Y () const
float & Y ()
float Z () const
float & Z ()
K3dQuaternionoperator= (K3dQuaternion &rkQ)
bool operator== (K3dQuaternion &rkQ)
bool operator!= (K3dQuaternion &rkQ)
bool operator< (K3dQuaternion &rkQ)
bool operator<= (K3dQuaternion &rkQ)
bool operator> (K3dQuaternion &rkQ)
bool operator>= (K3dQuaternion &rkQ)
K3dQuaternionoperator+ (K3dQuaternion &rkQ)
K3dQuaternionoperator- (K3dQuaternion &rkQ)
K3dQuaternionoperator * (K3dQuaternion &rkQ)
 Multiplication is not generally commutative, so in most cases p*q != q*p.
K3dQuaternionoperator * (float fScalar)
K3dQuaternionoperator/ (float fScalar)
K3dQuaternionoperator- ()
K3dQuaternionoperator+= (K3dQuaternion &rkQ)
K3dQuaternionoperator-= (K3dQuaternion &rkQ)
K3dQuaternionoperator *= (float fScalar)
K3dQuaternionoperator/= (float fScalar)
void FromRotationMatrix (K3dMatrix &rkRot)
void ToRotationMatrix (K3dMatrix &rkRot)
 Translate quternion to rotation matrix.
void FromRotationMatrix (K3dVector3 akRotColumn[3])
void ToRotationMatrix (K3dVector3 akRotColumn[3])
void FromAxisAngle (K3dVector3 &rkAxis, float fAngle)
 The quaternion representing the rotation is q = cos(A/2)+sin(A/2)*(x*i+y*j+z*k).
void FromAxisAngle (K3dVector3 _kAngle)
 Translate axis angle to quaternion.
void ToAxisAngle (K3dVector3 &rkAxis, float &rfAngle)
 The quaternion representing the rotation is q = cos(A/2)+sin(A/2)*(x*i+y*j+z*k).
float Dot (K3dQuaternion &rkQ)
 Dot product.
K3dQuaternionInverse ()
 Apply to non-zero quaternion.
K3dQuaternionConjugate ()
K3dQuaternionExp ()
 Apply to quaternion with w = 0.
K3dQuaternionLog ()
 Apply to unit-length quaternion.
K3dVector3operator * (K3dVector3 &rkVector)
 Given a vector u = (x0,y0,z0) and a unit length quaternion q = <w,x,y,z>, the vector v = (x1,y1,z1) which represents the rotation of u by q is v = q*u*q^{-1} where * indicates quaternion multiplication and where u is treated as the quaternion <0,x0,y0,z0>. Note that q^{-1} = <w,-x,-y,-z>, so no real work is required to invert q. Now

q*u*q^{-1} = q*<0,x0,y0,z0>*q^{-1} = q*(x0*i+y0*j+z0*k)*q^{-1} = x0*(q*i*q^{-1})+y0*(q*j*q^{-1})+z0*(q*k*q^{-1})

As 3-vectors, q*i*q^{-1}, q*j*q^{-1}, and 2*k*q^{-1} are the columns of the rotation matrix computed in Quaternion::ToRotationMatrix. The vector v is obtained as the product of that rotation matrix with vector u. As such, the quaternion representation of a rotation matrix requires less space than the matrix and more time to compute the rotated vector. Typical space-time tradeoff...

K3dQuaternionSlerp (float fT, K3dQuaternion &rkP, K3dQuaternion &rkQ)
 Spherical linear interpolation.
K3dQuaternionSlerpExtraSpins (float fT, K3dQuaternion &rkP, K3dQuaternion &rkQ, int iExtraSpins)
 Spherical linear interpolation.
K3dQuaternionGetIntermediate (K3dQuaternion &rkQ0, K3dQuaternion &rkQ1, K3dQuaternion &rkQ2)
 Intermediate terms for spherical quadratic interpolation.
K3dQuaternionSquad (float fT, K3dQuaternion &rkQ0, K3dQuaternion &rkA0, K3dQuaternion &rkA1, K3dQuaternion &rkQ1)
 Spherical quadratic interpolation.
void GetValue (K3dMatrix &rkMatrix)
 Get value from quaternion to the matrix.

Static Public Attributes

static const float IDENTITY [4]
 Special values.
static const float ZERO [4]

Protected Member Functions

int CompareArrays (K3dQuaternion &rkQ)
 Support for comparisons.

Protected Attributes

float m_afTuple [4]

Static Protected Attributes

static const int NEXT [3]
 Support for FromRotationMatrix.


Detailed Description

Definition at line 40 of file K3dQuaternion.h.


Constructor & Destructor Documentation

K3dQuaternion::K3dQuaternion (  ) 

Definition at line 42 of file K3dQuaternion.cpp.

K3dQuaternion::K3dQuaternion ( float  fW,
float  fX,
float  fY,
float  fZ 
)

Definition at line 50 of file K3dQuaternion.cpp.

References m_afTuple.

K3dQuaternion::K3dQuaternion ( K3dQuaternion rkQ  ) 

Definition at line 74 of file K3dQuaternion.cpp.

References m_afTuple.

K3dQuaternion::K3dQuaternion ( K3dVector4  kVec4  ) 

Definition at line 58 of file K3dQuaternion.cpp.

References m_afTuple.

K3dQuaternion::K3dQuaternion ( float  afVector[4]  ) 

Definition at line 66 of file K3dQuaternion.cpp.

References m_afTuple.

K3dQuaternion::~K3dQuaternion (  ) 

Definition at line 46 of file K3dQuaternion.cpp.

K3dQuaternion::K3dQuaternion ( K3dMatrix rkRot  ) 

Quaternion for the input rotation matrix.

Definition at line 79 of file K3dQuaternion.cpp.

References FromRotationMatrix().

K3dQuaternion::K3dQuaternion ( K3dVector3 rkAxis,
float  fAngle 
)

Quaternion for the rotation of the axis-angle pair.

Definition at line 84 of file K3dQuaternion.cpp.

References FromAxisAngle().

K3dQuaternion::K3dQuaternion ( K3dVector3  akRotColumn[3]  ) 

Quaternion for the rotation matrix with specified columns.

Definition at line 89 of file K3dQuaternion.cpp.

References FromRotationMatrix().


Member Function Documentation

K3dQuaternion::operator const float * (  )  const

Member access: 0 = w, 1 = x, 2 = y, 3 = z.

Definition at line 94 of file K3dQuaternion.cpp.

References m_afTuple.

K3dQuaternion::operator float * (  ) 

Definition at line 99 of file K3dQuaternion.cpp.

References m_afTuple.

float K3dQuaternion::operator[] ( int  i  )  const

float & K3dQuaternion::operator[] ( int  i  ) 

Definition at line 104 of file K3dQuaternion.cpp.

References m_afTuple.

float K3dQuaternion::W (  )  const

Definition at line 113 of file K3dQuaternion.cpp.

References m_afTuple.

float & K3dQuaternion::W (  ) 

Definition at line 118 of file K3dQuaternion.cpp.

References m_afTuple.

float K3dQuaternion::X (  )  const

Definition at line 123 of file K3dQuaternion.cpp.

References m_afTuple.

float & K3dQuaternion::X (  ) 

Definition at line 128 of file K3dQuaternion.cpp.

References m_afTuple.

float K3dQuaternion::Y (  )  const

Definition at line 133 of file K3dQuaternion.cpp.

References m_afTuple.

float & K3dQuaternion::Y (  ) 

Definition at line 138 of file K3dQuaternion.cpp.

References m_afTuple.

float K3dQuaternion::Z (  )  const

Definition at line 143 of file K3dQuaternion.cpp.

References m_afTuple.

float & K3dQuaternion::Z (  ) 

Definition at line 148 of file K3dQuaternion.cpp.

References m_afTuple.

K3dQuaternion & K3dQuaternion::operator= ( K3dQuaternion rkQ  ) 

Definition at line 153 of file K3dQuaternion.cpp.

References m_afTuple.

bool K3dQuaternion::operator== ( K3dQuaternion rkQ  ) 

Definition at line 159 of file K3dQuaternion.cpp.

References m_afTuple.

Referenced by operator!=().

bool K3dQuaternion::operator!= ( K3dQuaternion rkQ  ) 

Definition at line 169 of file K3dQuaternion.cpp.

References operator==().

bool K3dQuaternion::operator< ( K3dQuaternion rkQ  ) 

Definition at line 188 of file K3dQuaternion.cpp.

References CompareArrays().

bool K3dQuaternion::operator<= ( K3dQuaternion rkQ  ) 

Definition at line 193 of file K3dQuaternion.cpp.

References CompareArrays().

bool K3dQuaternion::operator> ( K3dQuaternion rkQ  ) 

Definition at line 198 of file K3dQuaternion.cpp.

References CompareArrays().

bool K3dQuaternion::operator>= ( K3dQuaternion rkQ  ) 

Definition at line 203 of file K3dQuaternion.cpp.

References CompareArrays().

K3dQuaternion & K3dQuaternion::operator+ ( K3dQuaternion rkQ  ) 

Definition at line 208 of file K3dQuaternion.cpp.

References m_afTuple.

K3dQuaternion & K3dQuaternion::operator- ( K3dQuaternion rkQ  ) 

Definition at line 215 of file K3dQuaternion.cpp.

References m_afTuple.

K3dQuaternion & K3dQuaternion::operator * ( K3dQuaternion rkQ  ) 

Multiplication is not generally commutative, so in most cases p*q != q*p.

Definition at line 223 of file K3dQuaternion.cpp.

References m_afTuple.

K3dQuaternion & K3dQuaternion::operator * ( float  fScalar  ) 

Definition at line 256 of file K3dQuaternion.cpp.

References m_afTuple.

K3dQuaternion & K3dQuaternion::operator/ ( float  fScalar  ) 

Definition at line 263 of file K3dQuaternion.cpp.

References m_afTuple, and K3dMath::MAX_REAL.

K3dQuaternion & K3dQuaternion::operator- (  ) 

Definition at line 282 of file K3dQuaternion.cpp.

References m_afTuple.

K3dQuaternion & K3dQuaternion::operator+= ( K3dQuaternion rkQ  ) 

Definition at line 289 of file K3dQuaternion.cpp.

References m_afTuple.

K3dQuaternion & K3dQuaternion::operator-= ( K3dQuaternion rkQ  ) 

Definition at line 296 of file K3dQuaternion.cpp.

References m_afTuple.

K3dQuaternion & K3dQuaternion::operator *= ( float  fScalar  ) 

Definition at line 303 of file K3dQuaternion.cpp.

References m_afTuple.

K3dQuaternion & K3dQuaternion::operator/= ( float  fScalar  ) 

Definition at line 310 of file K3dQuaternion.cpp.

References m_afTuple, and K3dMath::MAX_REAL.

void K3dQuaternion::FromRotationMatrix ( K3dMatrix rkRot  ) 

Definition at line 329 of file K3dQuaternion.cpp.

References m_afTuple, NEXT, and K3dMath::Sqrt().

Referenced by FromRotationMatrix(), and K3dQuaternion().

void K3dQuaternion::ToRotationMatrix ( K3dMatrix rkRot  ) 

Translate quternion to rotation matrix.

Definition at line 369 of file K3dQuaternion.cpp.

References m_afTuple.

Referenced by K3dCamera::ChangeMatrix(), operator *(), K3dSphereMove::Rotate(), and ToRotationMatrix().

void K3dQuaternion::FromRotationMatrix ( K3dVector3  akRotColumn[3]  ) 

Definition at line 384 of file K3dQuaternion.cpp.

References FromRotationMatrix().

void K3dQuaternion::ToRotationMatrix ( K3dVector3  akRotColumn[3]  ) 

Definition at line 397 of file K3dQuaternion.cpp.

References ToRotationMatrix().

void K3dQuaternion::FromAxisAngle ( K3dVector3 rkAxis,
float  fAngle 
)

The quaternion representing the rotation is q = cos(A/2)+sin(A/2)*(x*i+y*j+z*k).

Definition at line 437 of file K3dQuaternion.cpp.

References K3dMath::Cos(), m_afTuple, and K3dMath::Sin().

Referenced by K3dCamera::ChangeMatrix(), K3dQuaternion(), and K3dSphereMove::Rotate().

void K3dQuaternion::FromAxisAngle ( K3dVector3  _kAngle  ) 

Translate axis angle to quaternion.

Definition at line 412 of file K3dQuaternion.cpp.

References m_afTuple.

void K3dQuaternion::ToAxisAngle ( K3dVector3 rkAxis,
float &  rfAngle 
)

The quaternion representing the rotation is q = cos(A/2)+sin(A/2)*(x*i+y*j+z*k).

Definition at line 448 of file K3dQuaternion.cpp.

References K3dMath::ACos(), K3dMath::EPSILON, K3dMath::InvSqrt(), and m_afTuple.

float K3dQuaternion::Dot ( K3dQuaternion rkQ  ) 

Dot product.

Definition at line 470 of file K3dQuaternion.cpp.

References m_afTuple.

Referenced by Slerp(), and SlerpExtraSpins().

K3dQuaternion & K3dQuaternion::Inverse (  ) 

Apply to non-zero quaternion.

Definition at line 478 of file K3dQuaternion.cpp.

References m_afTuple.

K3dQuaternion & K3dQuaternion::Conjugate (  ) 

Definition at line 506 of file K3dQuaternion.cpp.

References m_afTuple.

Referenced by GetIntermediate().

K3dQuaternion & K3dQuaternion::Exp (  ) 

Apply to quaternion with w = 0.

Definition at line 518 of file K3dQuaternion.cpp.

References K3dMath::Cos(), K3dMath::EPSILON, K3dMath::FAbs(), m_afTuple, K3dMath::Sin(), and K3dMath::Sqrt().

Referenced by GetIntermediate().

K3dQuaternion & K3dQuaternion::Log (  ) 

Apply to unit-length quaternion.

Definition at line 548 of file K3dQuaternion.cpp.

References K3dMath::ACos(), K3dMath::EPSILON, K3dMath::FAbs(), m_afTuple, and K3dMath::Sin().

Referenced by GetIntermediate().

K3dVector3 & K3dQuaternion::operator * ( K3dVector3 rkVector  ) 

Given a vector u = (x0,y0,z0) and a unit length quaternion q = <w,x,y,z>, the vector v = (x1,y1,z1) which represents the rotation of u by q is v = q*u*q^{-1} where * indicates quaternion multiplication and where u is treated as the quaternion <0,x0,y0,z0>. Note that q^{-1} = <w,-x,-y,-z>, so no real work is required to invert q. Now

q*u*q^{-1} = q*<0,x0,y0,z0>*q^{-1} = q*(x0*i+y0*j+z0*k)*q^{-1} = x0*(q*i*q^{-1})+y0*(q*j*q^{-1})+z0*(q*k*q^{-1})

As 3-vectors, q*i*q^{-1}, q*j*q^{-1}, and 2*k*q^{-1} are the columns of the rotation matrix computed in Quaternion::ToRotationMatrix. The vector v is obtained as the product of that rotation matrix with vector u. As such, the quaternion representation of a rotation matrix requires less space than the matrix and more time to compute the rotated vector. Typical space-time tradeoff...

Definition at line 592 of file K3dQuaternion.cpp.

References ToRotationMatrix().

K3dQuaternion & K3dQuaternion::Slerp ( float  fT,
K3dQuaternion rkP,
K3dQuaternion rkQ 
)

Spherical linear interpolation.

Definition at line 601 of file K3dQuaternion.cpp.

References K3dMath::ACos(), Dot(), K3dMath::EPSILON, K3dMath::FAbs(), and K3dMath::Sin().

Referenced by Squad().

K3dQuaternion & K3dQuaternion::SlerpExtraSpins ( float  fT,
K3dQuaternion rkP,
K3dQuaternion rkQ,
int  iExtraSpins 
)

Spherical linear interpolation.

Definition at line 620 of file K3dQuaternion.cpp.

References K3dMath::ACos(), Dot(), K3dMath::EPSILON, K3dMath::FAbs(), K3dMath::K_PI, and K3dMath::Sin().

K3dQuaternion & K3dQuaternion::GetIntermediate ( K3dQuaternion rkQ0,
K3dQuaternion rkQ1,
K3dQuaternion rkQ2 
)

Intermediate terms for spherical quadratic interpolation.

Definition at line 638 of file K3dQuaternion.cpp.

References Conjugate(), Exp(), and Log().

K3dQuaternion & K3dQuaternion::Squad ( float  fT,
K3dQuaternion rkQ0,
K3dQuaternion rkA0,
K3dQuaternion rkA1,
K3dQuaternion rkQ1 
)

Spherical quadratic interpolation.

Definition at line 651 of file K3dQuaternion.cpp.

References Slerp().

void K3dQuaternion::GetValue ( K3dMatrix rkMatrix  ) 

Get value from quaternion to the matrix.

Definition at line 662 of file K3dQuaternion.cpp.

References EQUIVALENT, and m_afTuple.

int K3dQuaternion::CompareArrays ( K3dQuaternion rkQ  )  [protected]

Support for comparisons.

Definition at line 174 of file K3dQuaternion.cpp.

References m_afTuple.

Referenced by operator<(), operator<=(), operator>(), and operator>=().


Member Data Documentation

const float K3dQuaternion::IDENTITY [static]

Special values.

Definition at line 135 of file K3dQuaternion.h.

const float K3dQuaternion::ZERO [static]

Definition at line 136 of file K3dQuaternion.h.

const int K3dQuaternion::NEXT [static, protected]

Support for FromRotationMatrix.

Definition at line 145 of file K3dQuaternion.h.

Referenced by FromRotationMatrix().

float K3dQuaternion::m_afTuple[4] [protected]

Definition at line 147 of file K3dQuaternion.h.

Referenced by CompareArrays(), Conjugate(), Dot(), Exp(), FromAxisAngle(), FromRotationMatrix(), GetValue(), Inverse(), K3dQuaternion(), Log(), operator *(), operator *=(), operator const float *(), operator float *(), operator+(), operator+=(), operator-(), operator-=(), operator/(), operator/=(), operator=(), operator==(), operator[](), ToAxisAngle(), ToRotationMatrix(), W(), X(), Y(), and Z().


The documentation for this class was generated from the following files:
Generated on Thu Aug 16 23:53:33 2007 for K3dEngine by  doxygen 1.5.0