#include <K3dQuaternion.h>
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 () |
K3dQuaternion & | operator= (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) |
K3dQuaternion & | operator+ (K3dQuaternion &rkQ) |
K3dQuaternion & | operator- (K3dQuaternion &rkQ) |
K3dQuaternion & | operator * (K3dQuaternion &rkQ) |
Multiplication is not generally commutative, so in most cases p*q != q*p. | |
K3dQuaternion & | operator * (float fScalar) |
K3dQuaternion & | operator/ (float fScalar) |
K3dQuaternion & | operator- () |
K3dQuaternion & | operator+= (K3dQuaternion &rkQ) |
K3dQuaternion & | operator-= (K3dQuaternion &rkQ) |
K3dQuaternion & | operator *= (float fScalar) |
K3dQuaternion & | operator/= (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. | |
K3dQuaternion & | Inverse () |
Apply to non-zero quaternion. | |
K3dQuaternion & | Conjugate () |
K3dQuaternion & | Exp () |
Apply to quaternion with w = 0. | |
K3dQuaternion & | Log () |
Apply to unit-length quaternion. | |
K3dVector3 & | 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... | |
K3dQuaternion & | Slerp (float fT, K3dQuaternion &rkP, K3dQuaternion &rkQ) |
Spherical linear interpolation. | |
K3dQuaternion & | SlerpExtraSpins (float fT, K3dQuaternion &rkP, K3dQuaternion &rkQ, int iExtraSpins) |
Spherical linear interpolation. | |
K3dQuaternion & | GetIntermediate (K3dQuaternion &rkQ0, K3dQuaternion &rkQ1, K3dQuaternion &rkQ2) |
Intermediate terms for spherical quadratic interpolation. | |
K3dQuaternion & | Squad (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. |
Definition at line 40 of file K3dQuaternion.h.
K3dQuaternion::K3dQuaternion | ( | ) |
Definition at line 42 of file K3dQuaternion.cpp.
K3dQuaternion::K3dQuaternion | ( | float | fW, | |
float | fX, | |||
float | fY, | |||
float | fZ | |||
) |
K3dQuaternion::K3dQuaternion | ( | K3dQuaternion & | rkQ | ) |
K3dQuaternion::K3dQuaternion | ( | K3dVector4 | kVec4 | ) |
K3dQuaternion::K3dQuaternion | ( | float | afVector[4] | ) |
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().
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 * | ( | ) |
float K3dQuaternion::operator[] | ( | int | i | ) | const |
float & K3dQuaternion::operator[] | ( | int | i | ) |
float K3dQuaternion::W | ( | ) | const |
float & K3dQuaternion::W | ( | ) |
float K3dQuaternion::X | ( | ) | const |
float & K3dQuaternion::X | ( | ) |
float K3dQuaternion::Y | ( | ) | const |
float & K3dQuaternion::Y | ( | ) |
float K3dQuaternion::Z | ( | ) | const |
float & K3dQuaternion::Z | ( | ) |
K3dQuaternion & K3dQuaternion::operator= | ( | K3dQuaternion & | rkQ | ) |
bool K3dQuaternion::operator== | ( | K3dQuaternion & | rkQ | ) |
bool K3dQuaternion::operator!= | ( | K3dQuaternion & | rkQ | ) |
bool K3dQuaternion::operator< | ( | K3dQuaternion & | rkQ | ) |
bool K3dQuaternion::operator<= | ( | K3dQuaternion & | rkQ | ) |
bool K3dQuaternion::operator> | ( | K3dQuaternion & | rkQ | ) |
bool K3dQuaternion::operator>= | ( | K3dQuaternion & | rkQ | ) |
K3dQuaternion & K3dQuaternion::operator+ | ( | K3dQuaternion & | rkQ | ) |
K3dQuaternion & K3dQuaternion::operator- | ( | K3dQuaternion & | rkQ | ) |
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 | ) |
K3dQuaternion & K3dQuaternion::operator/ | ( | float | fScalar | ) |
K3dQuaternion & K3dQuaternion::operator- | ( | ) |
K3dQuaternion & K3dQuaternion::operator+= | ( | K3dQuaternion & | rkQ | ) |
K3dQuaternion & K3dQuaternion::operator-= | ( | K3dQuaternion & | rkQ | ) |
K3dQuaternion & K3dQuaternion::operator *= | ( | float | fScalar | ) |
K3dQuaternion & K3dQuaternion::operator/= | ( | float | fScalar | ) |
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] | ) |
void K3dQuaternion::ToRotationMatrix | ( | K3dVector3 | akRotColumn[3] | ) |
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>=().
const float K3dQuaternion::IDENTITY [static] |
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().