22 #ifndef BLADERUNNER_MATRIX_H 23 #define BLADERUNNER_MATRIX_H 25 #include "bladerunner/vector.h" 36 float m00,
float m01,
float m02,
37 float m10,
float m11,
float m12);
39 float &operator()(
int r,
int c) { assert(r >= 0 && r < 2); assert(c >= 0 && c < 3);
return _m[r][c]; }
40 const float &operator()(
int r,
int c)
const { assert(r >= 0 && r < 2); assert(c >= 0 && c < 3);
return _m[r][c]; }
46 t(0, 0) = a(0, 0) * b(0, 0) + a(0, 1) * b(1, 0);
47 t(0, 1) = a(0, 0) * b(0, 1) + a(0, 1) * b(1, 1);
48 t(0, 2) = a(0, 0) * b(0, 2) + a(0, 1) * b(1, 2) + a(0, 2);
49 t(1, 0) = a(1, 0) * b(0, 0) + a(1, 1) * b(1, 0);
50 t(1, 1) = a(1, 0) * b(0, 1) + a(1, 1) * b(1, 1);
51 t(1, 2) = a(1, 0) * b(0, 2) + a(1, 1) * b(1, 2) + a(1, 2);
68 t.x = a(0, 0) * b.x + a(0, 1) * b.y + a(0, 2);
69 t.y = a(1, 0) * b.x + a(1, 1) * b.y + a(1, 2);
81 float m00,
float m01,
float m02,
float m03,
82 float m10,
float m11,
float m12,
float m13,
83 float m20,
float m21,
float m22,
float m23);
85 float &operator()(
int r,
int c) { assert(r >= 0 && r < 3); assert(c >= 0 && c < 4);
return _m[r][c]; }
86 const float &operator()(
int r,
int c)
const { assert(r >= 0 && r < 3); assert(c >= 0 && c < 4);
return _m[r][c]; }
97 for (
int i = 0; i !=3; ++i) {
98 t(i, 0) = a(i, 0) * b(0, 0) + a(i, 1) * b(1, 0) + a(i, 2) * b(2, 0);
99 t(i, 1) = a(i, 0) * b(0, 1) + a(i, 1) * b(1, 1) + a(i, 2) * b(2, 1);
100 t(i, 2) = a(i, 0) * b(0, 2) + a(i, 1) * b(1, 2) + a(i, 2) * b(2, 2);
101 t(i, 3) = a(i, 0) * b(0, 3) + a(i, 1) * b(1, 3) + a(i, 2) * b(2, 3) + a(i, 3);
110 r.x = m(0, 0) * v.x + m(0, 1) * v.y + m(0, 2) * v.z + m(0, 3);
111 r.y = m(1, 0) * v.x + m(1, 1) * v.y + m(1, 2) * v.z + m(1, 3);
112 r.z = m(2, 0) * v.x + m(2, 1) * v.y + m(2, 2) * v.z + m(2, 3);