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