00001 /* Written by Steven Kilthau */ 00002 00003 #ifndef _MATRIX_H_ 00004 #define _MATRIX_H_ 00005 00006 #include "vuSimpleTypes.h" 00007 00008 class vuVector; 00009 00019 class vuMatrix 00020 { 00021 friend class vuVector; 00022 public: 00024 vuMatrix(); 00026 vuMatrix(const vuMatrix& m); 00028 vuMatrix(float v); 00030 00032 vuMatrix(const float* v); 00034 ~vuMatrix(); 00035 00037 vuMatrix& operator=(const vuMatrix& m); 00039 vuMatrix& operator=(float v); 00041 vuMatrix& operator=(const float* v); 00042 00043 // 00044 // Generate various special matrices by 00045 // changing values in the current instance. 00046 // All transformation matrices are pre- 00047 // transforms, meaning they should be left 00048 // multiplied against a vuVector. 00049 // 00051 vuMatrix& makeIdentity(void); 00053 00056 vuMatrix& makeRotate(const vuVector& axis, float a); 00058 vuMatrix& makeRotateX(float a); 00060 vuMatrix& makeRotateY(float a); 00062 vuMatrix& makeRotateZ(float a); 00064 vuMatrix& makeTranslate(float x, float y, float z); 00066 vuMatrix& makeScale(float x, float y, float z); 00068 vuMatrix& makeShearXY(float s); 00070 vuMatrix& makeShearXZ(float s); 00072 vuMatrix& makeShearYX(float s); 00074 vuMatrix& makeShearYZ(float s); 00076 vuMatrix& makeShearZX(float s); 00078 vuMatrix& makeShearZY(float s); 00080 vuMatrix& makeReflectX(void); 00082 vuMatrix& makeReflectY(void); 00084 vuMatrix& makeReflectZ(void); 00086 vuMatrix& makePerspective(float d); 00088 vuMatrix& makePerspectiveKeepZ(float d); 00089 00091 float* operator[](unsigned int index); 00093 const float* operator[](unsigned int index) const; 00095 00096 float* getData(void); 00098 float const* getData(void) const; 00099 00101 vuMatrix invOrtho() const; 00103 vuMatrix operator+(const vuMatrix& m) const; 00105 vuMatrix operator-(const vuMatrix& m) const; 00107 vuMatrix operator*(const vuMatrix& m) const; 00109 vuVector operator*(const vuVector& v) const; 00111 vuMatrix operator*(float s) const; 00113 friend vuMatrix operator*(float s,const vuMatrix& m); 00115 vuMatrix& operator+=(const vuMatrix& m); 00117 vuMatrix& operator-=(const vuMatrix& m); 00119 vuMatrix& operator*=(const vuMatrix& m); 00121 vuMatrix& operator*=(float s); 00122 00124 bool operator==(const vuMatrix& m) const; 00126 bool operator!=(const vuMatrix& m) const; 00127 00129 vuMatrix inverse(void) ; 00130 00132 00135 void invertRotationMatrix(); 00136 00137 private: 00138 float val[16]; 00139 }; 00140 00141 #endif