21 template <
class MATRIXLIKE1,
class MATRIXLIKE2>
25 ASSERT_(M.isSquare() && M.rows() == 4);
38 out_inverse_M.setSize(4, 4);
41 out_inverse_M.set_unsafe(0, 0, M.get_unsafe(0, 0));
42 out_inverse_M.set_unsafe(0, 1, M.get_unsafe(1, 0));
43 out_inverse_M.set_unsafe(0, 2, M.get_unsafe(2, 0));
45 out_inverse_M.set_unsafe(1, 0, M.get_unsafe(0, 1));
46 out_inverse_M.set_unsafe(1, 1, M.get_unsafe(1, 1));
47 out_inverse_M.set_unsafe(1, 2, M.get_unsafe(2, 1));
49 out_inverse_M.set_unsafe(2, 0, M.get_unsafe(0, 2));
50 out_inverse_M.set_unsafe(2, 1, M.get_unsafe(1, 2));
51 out_inverse_M.set_unsafe(2, 2, M.get_unsafe(2, 2));
53 const double tx = -M.get_unsafe(0, 3);
54 const double ty = -M.get_unsafe(1, 3);
55 const double tz = -M.get_unsafe(2, 3);
57 const double tx_ = tx * M.get_unsafe(0, 0) +
ty * M.get_unsafe(1, 0) +
58 tz * M.get_unsafe(2, 0);
59 const double ty_ = tx * M.get_unsafe(0, 1) +
ty * M.get_unsafe(1, 1) +
60 tz * M.get_unsafe(2, 1);
61 const double tz_ = tx * M.get_unsafe(0, 2) +
ty * M.get_unsafe(1, 2) +
62 tz * M.get_unsafe(2, 2);
64 out_inverse_M.set_unsafe(0, 3, tx_);
65 out_inverse_M.set_unsafe(1, 3, ty_);
66 out_inverse_M.set_unsafe(2, 3, tz_);
68 out_inverse_M.set_unsafe(3, 0, 0);
69 out_inverse_M.set_unsafe(3, 1, 0);
70 out_inverse_M.set_unsafe(3, 2, 0);
71 out_inverse_M.set_unsafe(3, 3, 1);
76 template <
class IN_ROTMATRIX,
class IN_XYZ,
class OUT_ROTMATRIX,
class OUT_XYZ>
78 const IN_ROTMATRIX& in_R,
const IN_XYZ& in_xyz, OUT_ROTMATRIX& out_R,
82 ASSERT_(in_R.isSquare() && in_R.rows() == 3 && in_xyz.size() == 3);
88 const T tx = -in_xyz[0];
89 const T
ty = -in_xyz[1];
90 const T
tz = -in_xyz[2];
92 out_xyz[0] = tx * in_R.get_unsafe(0, 0) +
ty * in_R.get_unsafe(1, 0) +
93 tz * in_R.get_unsafe(2, 0);
94 out_xyz[1] = tx * in_R.get_unsafe(0, 1) +
ty * in_R.get_unsafe(1, 1) +
95 tz * in_R.get_unsafe(2, 1);
96 out_xyz[2] = tx * in_R.get_unsafe(0, 2) +
ty * in_R.get_unsafe(1, 2) +
97 tz * in_R.get_unsafe(2, 2);
100 out_R = in_R.adjoint();
105 template <
class MATRIXLIKE>
108 ASSERTDEB_(M.cols() == M.rows() && M.rows() == 4);
110 const double tx = -M(0, 3);
111 const double ty = -M(1, 3);
112 const double tz = -M(2, 3);
113 M(0, 3) = tx * M(0, 0) +
ty * M(1, 0) +
tz * M(2, 0);
114 M(1, 3) = tx * M(0, 1) +
ty * M(1, 1) +
tz * M(2, 1);
115 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.