Matrix4x4.h

00001 /*************************************************************************************************
00002  *
00003  * Modeling and animation (TNM079) 2007
00004  * Code base for lab assignments. Copyright:
00005  *   Gunnar Johansson (gunnar.johansson@itn.liu.se)
00006  *   Ken Museth (ken.museth@itn.liu.se)
00007  *   Michael Bang Nielsen (bang@daimi.au.dk)
00008  *   Ola Nilsson (ola.nilsson@itn.liu.se)
00009  *   Andreas Söderström (andreas.soderstrom@itn.liu.se)
00010  *
00011  *************************************************************************************************/
00012 #ifndef _matrix4x4_h
00013 #define _matrix4x4_h
00014 
00015 template <typename Real> class Vector3;
00016 template <typename Real> class Vector4;
00017 
00018 template <typename Real>
00019 class Matrix4x4
00020 {
00021 public:
00022   Matrix4x4();
00023   Matrix4x4(const Real m[4][4]);
00024         
00025   void toGLMatrix(float glMatrix[16]) const;
00026   Matrix4x4 inverse() const;
00027   // Input: i (row), j (column)
00028   Real &operator()(unsigned int i, unsigned int j);
00029   Real *operator[](unsigned int i) { return m[i]; }
00030   Vector4<Real> operator*(const Vector4<Real>& vec4) const;
00031   Matrix4x4 operator*(const Matrix4x4& m2) const;
00032 
00033   // Static methods     
00034   static Matrix4x4 scale(Real scale);
00035   static Matrix4x4 scale(Real sx, Real sy, Real sz);
00036   // Angles in radians
00037   static Matrix4x4 rotationXYZ(Real rx, Real ry, Real rz);
00038   static Matrix4x4 translation(Real tx, Real ty, Real tz);
00039   static Matrix4x4 identity();
00040 
00041 protected:
00042   Real m[4][4];
00043 
00044   static Matrix4x4 identityMatrix;
00045 };
00046 
00047 #include "Matrix4x4_Impl.h"
00048 
00049 #endif

Generated on Fri Jul 20 23:57:42 2007 for HalfEdge by  doxygen 1.5.1