00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef LUX_MATRIX4X4_H
00025 #define LUX_MATRIX4X4_H
00026
00027 namespace lux
00028 {
00029
00030 class Matrix4x4 {
00031 public:
00032
00033 Matrix4x4() {
00034 for (int i = 0; i < 4; ++i)
00035 for (int j = 0; j < 4; ++j)
00036 if (i == j) m[i][j] = 1.;
00037 else m[i][j] = 0.;
00038 }
00039 Matrix4x4(float mat[4][4]);
00040 Matrix4x4(float t00, float t01, float t02, float t03,
00041 float t10, float t11, float t12, float t13,
00042 float t20, float t21, float t22, float t23,
00043 float t30, float t31, float t32, float t33);
00044 boost::shared_ptr<Matrix4x4> Transpose() const;
00045 void Print(ostream &os) const {
00046 os << "[ ";
00047 for (int i = 0; i < 4; ++i) {
00048 os << "[ ";
00049 for (int j = 0; j < 4; ++j) {
00050 os << m[i][j];
00051 if (j != 3) os << ", ";
00052 }
00053 os << " ] ";
00054 }
00055 os << " ] ";
00056 }
00057 static boost::shared_ptr<Matrix4x4>
00058 Mul(const boost::shared_ptr<Matrix4x4> &m1,
00059 const boost::shared_ptr<Matrix4x4> &m2) {
00060 float r[4][4];
00061 for (int i = 0; i < 4; ++i)
00062 for (int j = 0; j < 4; ++j)
00063 r[i][j] = m1->m[i][0] * m2->m[0][j] +
00064 m1->m[i][1] * m2->m[1][j] +
00065 m1->m[i][2] * m2->m[2][j] +
00066 m1->m[i][3] * m2->m[3][j];
00067 boost::shared_ptr<Matrix4x4> o (new Matrix4x4(r));
00068 return o;
00069 }
00070 boost::shared_ptr<Matrix4x4> Inverse() const;
00071 float m[4][4];
00072 };
00073
00074 }
00075
00076 #endif //LUX_MATRIX4X4_H