00001
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #pragma once
00035
00036 #include "K3dVector4.h"
00037 #include "K3dMatrix.h"
00038
00039
00040 class K3dQuaternion
00041 {
00042 public:
00043
00044
00045
00046 K3dQuaternion ();
00047 K3dQuaternion ( float fW, float fX, float fY, float fZ );
00048 K3dQuaternion ( K3dQuaternion& rkQ );
00049 K3dQuaternion ( K3dVector4 kVec4 );
00050 K3dQuaternion ( float afVector[4] );
00051 ~K3dQuaternion();
00053 K3dQuaternion ( K3dMatrix& rkRot );
00054
00056 K3dQuaternion ( K3dVector3& rkAxis, float fAngle );
00057
00059 K3dQuaternion ( K3dVector3 akRotColumn[3] );
00060
00062 operator const float* () const;
00063 operator float* ();
00064 float operator[] ( int i ) const;
00065 float& operator[] ( int i );
00066 float W () const;
00067 float& W ();
00068 float X () const;
00069 float& X ();
00070 float Y () const;
00071 float& Y ();
00072 float Z () const;
00073 float& Z ();
00074
00075 K3dQuaternion& operator= ( K3dQuaternion& rkQ );
00076 bool operator== ( K3dQuaternion& rkQ ) ;
00077 bool operator!= ( K3dQuaternion& rkQ ) ;
00078 bool operator< ( K3dQuaternion& rkQ ) ;
00079 bool operator<= ( K3dQuaternion& rkQ ) ;
00080 bool operator> ( K3dQuaternion& rkQ ) ;
00081 bool operator>= ( K3dQuaternion& rkQ ) ;
00082
00083 K3dQuaternion& operator+ ( K3dQuaternion& rkQ ) ;
00084 K3dQuaternion& operator- ( K3dQuaternion& rkQ ) ;
00085 K3dQuaternion& operator* ( K3dQuaternion& rkQ ) ;
00086 K3dQuaternion& operator* ( float fScalar ) ;
00087 K3dQuaternion& operator/ ( float fScalar ) ;
00088 K3dQuaternion& operator- () ;
00089
00090 K3dQuaternion& operator+= ( K3dQuaternion& rkQ );
00091 K3dQuaternion& operator-= ( K3dQuaternion& rkQ );
00092 K3dQuaternion& operator*= ( float fScalar );
00093 K3dQuaternion& operator/= ( float fScalar );
00094
00095
00096 void FromRotationMatrix ( K3dMatrix& rkRot );
00097 void ToRotationMatrix ( K3dMatrix& rkRot ) ;
00098
00099 void FromRotationMatrix ( K3dVector3 akRotColumn[3] );
00100 void ToRotationMatrix ( K3dVector3 akRotColumn[3] ) ;
00101 void FromAxisAngle ( K3dVector3& rkAxis, float fAngle );
00103 void FromAxisAngle ( K3dVector3 _kAngle );
00104 void ToAxisAngle ( K3dVector3& rkAxis, float& rfAngle ) ;
00105
00107 float Dot ( K3dQuaternion& rkQ ) ;
00109 K3dQuaternion& Inverse () ;
00110 K3dQuaternion& Conjugate () ;
00112 K3dQuaternion& Exp ();
00114 K3dQuaternion& Log ();
00115
00116
00117 K3dVector3& operator* ( K3dVector3& rkVector );
00118
00119
00121 K3dQuaternion& Slerp ( float fT, K3dQuaternion& rkP, K3dQuaternion& rkQ );
00123 K3dQuaternion& SlerpExtraSpins ( float fT, K3dQuaternion& rkP, K3dQuaternion& rkQ, int iExtraSpins );
00124
00126 K3dQuaternion& GetIntermediate ( K3dQuaternion& rkQ0, K3dQuaternion& rkQ1, K3dQuaternion& rkQ2 );
00127
00129 K3dQuaternion& Squad ( float fT, K3dQuaternion& rkQ0, K3dQuaternion& rkA0, K3dQuaternion& rkA1, K3dQuaternion& rkQ1 );
00130
00132 void GetValue ( K3dMatrix & rkMatrix ) ;
00133
00135 static const float IDENTITY[4];
00136 static const float ZERO[4];
00137
00138
00139
00140
00141 protected:
00143 int CompareArrays ( K3dQuaternion& rkQ ) ;
00145 static const int NEXT[3];
00146
00147 float m_afTuple[4];
00148 };
00149