00001
00002
00003
00004
00005 #ifndef _MAT33_
00006 #define _MAT33_
00007
00008 #include "vec3f.hpp"
00009
00010 static const float Mat33TORADS = 0.0174532f;
00011 static const float Mat33VIEWPORT_TOL = 0.001f;
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 template<class Type>
00025 class Mat33
00026 {
00027 public:
00028 Type M[9];
00029
00030 Mat33();
00031 Mat33(const Type *N);
00032 Mat33(Type M0, Type M3, Type M6,
00033 Type M1, Type M4, Type M7,
00034 Type M2, Type M5, Type M8);
00035 Mat33<Type>& operator = (const Mat33& A);
00036
00037 Mat33<Type>& operator = (const Type* a);
00038 Mat33<Type> operator * (const Mat33& A) const;
00039
00040 Vec3<Type> operator * (const Vec3<Type>& V) const;
00041
00042 friend Vec3<Type> operator * (const Vec3<Type>& V, const Mat33<Type>& M);
00043
00044 Mat33<Type> operator * (Type a) const;
00045
00046 friend Mat33<Type> operator * (Type a, const Mat44& M);
00047
00048 Mat33<Type> operator / (Type a) const;
00049 Mat33<Type> operator + (Mat33& M) const;
00050 Mat33<Type>& operator += (Mat33& M);
00051 Mat33<Type>& operator -= (Mat33& M);
00052 Mat33<Type>& operator *= (Type a);
00053 Mat33<Type>& operator /= (Type a);
00054
00055 bool Inverse(Mat33<Type> &inv, Type tolerance) const;
00056
00057 operator const Type*() const;
00058 operator Type*();
00059
00060 void RowMajor(Type m[9]);
00061
00062 Type& operator()(int col, int row);
00063 const Type& operator()(int col, int row) const;
00064 void Set(const Type* a);
00065 void Set(Type M0, Type M3, Type M6,
00066 Type M1, Type M4, Type M7,
00067 Type M2, Type M5, Type M8);
00068
00069 void Identity();
00070 void Zero();
00071 void Transpose();
00072 void Scale(Type Sx, Type Sy, Type Sz);
00073 void Scale(const Vec3<Type>& S);
00074 void invScale(Type Sx, Type Sy, Type Sz);
00075 void invScale(const Vec3<Type>& S);
00076 void Rotate(Type DegAng, const Vec3<Type>& Axis);
00077 void invRotate(Type DegAng, const Vec3<Type>& Axis);
00078 void Star(const Vec3<Type>& v);
00079 void OuterProduct(const Vec3<Type>& u, const Vec3<Type>& v);
00080 Type Trace() const;
00081 void Print() const;
00082 void CopyInto(Type *Mat) const;
00083 static void SWAP(Type& a, Type& b) {Type t; t=a;a=b;b=t;}
00084 };
00085
00086 #include "mat33impl.hpp"
00087
00088 typedef Mat33<float> Mat33f;
00089 typedef Mat33<double> Mat33d;
00090
00091 #endif
00092
00093
00094
00095