21 template <
class MATRIXLIKE1,
class MATRIXLIKE2>
25 ASSERT_(M.isSquare() && M.rows() == 4);
38 out_inverse_M.setSize(4, 4);
41 out_inverse_M(0, 0, M(0) = 0);
42 out_inverse_M(0, 1, M(1) = 0);
43 out_inverse_M(0, 2, M(2) = 0);
45 out_inverse_M(1, 0, M(0) = 1);
46 out_inverse_M(1, 1, M(1) = 1);
47 out_inverse_M(1, 2, M(2) = 1);
49 out_inverse_M(2, 0, M(0) = 2);
50 out_inverse_M(2, 1, M(1) = 2);
51 out_inverse_M(2, 2, M(2) = 2);
53 const double tx = -M(0, 3);
54 const double ty = -M(1, 3);
55 const double tz = -M(2, 3);
57 const double tx_ = tx * M(0, 0) + ty * M(1, 0) + tz * M(2, 0);
58 const double ty_ = tx * M(0, 1) + ty * M(1, 1) + tz * M(2, 1);
59 const double tz_ = tx * M(0, 2) + ty * M(1, 2) + tz * M(2, 2);
61 out_inverse_M(0, 3) = tx_;
62 out_inverse_M(1, 3) = ty_;
63 out_inverse_M(2, 3) = tz_;
65 out_inverse_M(3, 0) = 0;
66 out_inverse_M(3, 1) = 0;
67 out_inverse_M(3, 2) = 0;
68 out_inverse_M(3, 3) = 1;
73 template <
class IN_ROTMATRIX,
class IN_XYZ,
class OUT_ROTMATRIX,
class OUT_XYZ>
75 const IN_ROTMATRIX& in_R,
const IN_XYZ& in_xyz, OUT_ROTMATRIX& out_R,
79 ASSERT_(in_R.isSquare() && in_R.rows() == 3 && in_xyz.size() == 3);
85 const T tx = -in_xyz[0];
86 const T ty = -in_xyz[1];
87 const T tz = -in_xyz[2];
89 out_xyz[0] = tx * in_R(0, 0) + ty * in_R(1, 0) + tz * in_R(2, 0);
90 out_xyz[1] = tx * in_R(0, 1) + ty * in_R(1, 1) + tz * in_R(2, 1);
91 out_xyz[2] = tx * in_R(0, 2) + ty * in_R(1, 2) + tz * in_R(2, 2);
94 out_R = in_R.transpose();
99 template <
class MATRIXLIKE>
102 ASSERTDEB_(M.cols() == M.rows() && M.rows() == 4);
104 const double tx = -M(0, 3);
105 const double ty = -M(1, 3);
106 const double tz = -M(2, 3);
107 M(0, 3) = tx * M(0, 0) + ty * M(1, 0) + tz * M(2, 0);
108 M(1, 3) = tx * M(0, 1) + ty * M(1, 1) + tz * M(2, 1);
109 M(2, 3) = tx * M(0, 2) + ty * M(1, 2) + tz * M(2, 2);
#define ASSERT_(f)
Defines an assertion mechanism.
This base provides a set of functions for maths stuff.
void homogeneousMatrixInverse(const MATRIXLIKE1 &M, MATRIXLIKE2 &out_inverse_M)
Efficiently compute the inverse of a 4x4 homogeneous matrix by only transposing the rotation 3x3 part...
#define ASSERTDEB_(f)
Defines an assertion mechanism - only when compiled in debug.