00001 
00032 #ifndef LL_M3MATH_H
00033 #define LL_M3MATH_H
00034 
00035 #include "llerror.h"
00036 
00037 class LLVector4;
00038 class LLVector3;
00039 class LLVector3d;
00040 class LLQuaternion;
00041 
00042 
00043 
00044 
00045 
00046 
00047 
00048 
00049 
00050 
00051 
00052 
00053 
00054 
00055 
00056 
00057 static const U32 NUM_VALUES_IN_MAT3     = 3;
00058 class LLMatrix3
00059 {
00060         public:
00061                 F32     mMatrix[NUM_VALUES_IN_MAT3][NUM_VALUES_IN_MAT3];
00062 
00063                 LLMatrix3(void);                                                        
00064                 explicit LLMatrix3(const F32 *mat);                                     
00065                 explicit LLMatrix3(const LLQuaternion &q);                      
00066 
00067                 LLMatrix3(const F32 angle, const F32 x, const F32 y, const F32 z);      
00068                 LLMatrix3(const F32 angle, const LLVector3 &vec);       
00069                 LLMatrix3(const F32 angle, const LLVector3d &vec);      
00070                 LLMatrix3(const F32 angle, const LLVector4 &vec);       
00071                 LLMatrix3(const F32 roll, const F32 pitch, const F32 yaw);      
00072 
00074                 
00075                 
00076                 
00077 
00078                 
00079                 const LLMatrix3& identity();                            
00080                 const LLMatrix3& zero();                                        
00081 
00083                 
00084                 
00085                 
00086 
00087                 
00088                 const LLMatrix3& setRot(const F32 angle, const F32 x, const F32 y, const F32 z);        
00089                 const LLMatrix3& setRot(const F32 angle, const LLVector3 &vec); 
00090                 const LLMatrix3& setRot(const F32 roll, const F32 pitch, const F32 yaw);        
00091                 const LLMatrix3& setRot(const LLQuaternion &q);                 
00092 
00093                 const LLMatrix3& setRows(const LLVector3 &x_axis, const LLVector3 &y_axis, const LLVector3 &z_axis);
00094                 
00096                 
00097                 
00098                 
00099                 LLQuaternion quaternion() const;                
00100                 void getEulerAngles(F32 *roll, F32 *pitch, F32 *yaw) const;     
00101 
00102                 
00103                 LLVector3 getFwdRow() const;
00104                 LLVector3 getLeftRow() const;
00105                 LLVector3 getUpRow() const;
00106                 F32      determinant() const;                                           
00107 
00108 
00110                 
00111                 
00112                 
00113                 const LLMatrix3& transpose();                                   
00114                 const LLMatrix3& invert();                                      
00115                 const LLMatrix3& orthogonalize();                                               
00116                 const LLMatrix3& adjointTranspose();            
00117 
00118                 
00119                 
00120                 
00121                 
00122                 
00123                 
00124                 const LLMatrix3& rotate(const F32 angle, const F32 x, const F32 y, const F32 z);        
00125                 const LLMatrix3& rotate(const F32 angle, const LLVector3 &vec);                                         
00126                 const LLMatrix3& rotate(const F32 roll, const F32 pitch, const F32 yaw);                        
00127                 const LLMatrix3& rotate(const LLQuaternion &q);                 
00128 
00129 
00130 
00131 
00132                 friend LLVector3 operator*(const LLVector3 &a, const LLMatrix3 &b);                     
00133                 friend LLVector3d operator*(const LLVector3d &a, const LLMatrix3 &b);                   
00134                 friend LLMatrix3 operator*(const LLMatrix3 &a, const LLMatrix3 &b);                     
00135 
00136                 friend bool operator==(const LLMatrix3 &a, const LLMatrix3 &b);                         
00137                 friend bool operator!=(const LLMatrix3 &a, const LLMatrix3 &b);                         
00138 
00139                 friend const LLMatrix3& operator*=(LLMatrix3 &a, const LLMatrix3 &b);                           
00140 
00141                 friend std::ostream&     operator<<(std::ostream& s, const LLMatrix3 &a);       
00142 };
00143 
00144 inline LLMatrix3::LLMatrix3(void)
00145 {
00146         mMatrix[0][0] = 1.f;
00147         mMatrix[0][1] = 0.f;
00148         mMatrix[0][2] = 0.f;
00149 
00150         mMatrix[1][0] = 0.f;
00151         mMatrix[1][1] = 1.f;
00152         mMatrix[1][2] = 0.f;
00153 
00154         mMatrix[2][0] = 0.f;
00155         mMatrix[2][1] = 0.f;
00156         mMatrix[2][2] = 1.f;
00157 }
00158 
00159 inline LLMatrix3::LLMatrix3(const F32 *mat)
00160 {
00161         mMatrix[0][0] = mat[0];
00162         mMatrix[0][1] = mat[1];
00163         mMatrix[0][2] = mat[2];
00164 
00165         mMatrix[1][0] = mat[3];
00166         mMatrix[1][1] = mat[4];
00167         mMatrix[1][2] = mat[5];
00168 
00169         mMatrix[2][0] = mat[6];
00170         mMatrix[2][1] = mat[7];
00171         mMatrix[2][2] = mat[8];
00172 }
00173 
00174 
00175 #endif
00176 
00177 
00178 
00179 
00180 
00181 
00182 
00183 
00184 
00185 
00186 
00187 
00188 
00189 
00190 
00191 
00192 
00193 
00194 
00195 
00196 
00197 
00198 
00199 
00200 
00201 
00202 
00203 
00204 
00205 
00206 
00207 
00208 
00209 
00210 
00211 
00212 
00213 
00214