00001 00002 #ifndef __QUATERNION_H 00003 #define __QUATERNION_H 00004 00005 #include <ostream> 00006 00007 #include "Vector.h" 00008 #include "Matrix.h" 00009 00021 class Quaternion { 00022 private: 00024 float m_data[4]; 00025 00026 private: 00028 void initialize(float w, float x, float y, float z); 00029 00030 public: 00032 static const int W; 00034 static const int X; 00036 static const int Y; 00038 static const int Z; 00039 00041 Quaternion(); 00043 Quaternion(float w, float x, float y, float z); 00056 Quaternion(float angle, const Vector& axis); 00057 00059 float& operator[](int which); 00060 00062 float operator[](int which) const; 00063 00068 const Quaternion normalize() const; 00069 00076 float length() const; 00077 00082 const Matrix toMatrix() const; 00083 00088 friend std::ostream& operator<< (std::ostream& out, const Quaternion& quat); 00089 }; 00090 00091 #endif // __QUATERNION_H