9 #ifndef MRPT_HOMOG_MATRICES_H 10 #define MRPT_HOMOG_MATRICES_H 12 #include <mrpt/config.h> 26 template <
class MATRIXLIKE1,
class MATRIXLIKE2>
43 out_inverse_M.setSize(4,4);
46 out_inverse_M.set_unsafe(0,0, M.get_unsafe(0,0));
47 out_inverse_M.set_unsafe(0,1, M.get_unsafe(1,0));
48 out_inverse_M.set_unsafe(0,2, M.get_unsafe(2,0));
50 out_inverse_M.set_unsafe(1,0, M.get_unsafe(0,1));
51 out_inverse_M.set_unsafe(1,1, M.get_unsafe(1,1));
52 out_inverse_M.set_unsafe(1,2, M.get_unsafe(2,1));
54 out_inverse_M.set_unsafe(2,0, M.get_unsafe(0,2));
55 out_inverse_M.set_unsafe(2,1, M.get_unsafe(1,2));
56 out_inverse_M.set_unsafe(2,2, M.get_unsafe(2,2));
58 const double tx = -M.get_unsafe(0,3);
59 const double ty = -M.get_unsafe(1,3);
60 const double tz = -M.get_unsafe(2,3);
62 const double tx_ = tx*M.get_unsafe(0,0)+
ty*M.get_unsafe(1,0)+
tz*M.get_unsafe(2,0);
63 const double ty_ = tx*M.get_unsafe(0,1)+
ty*M.get_unsafe(1,1)+
tz*M.get_unsafe(2,1);
64 const double tz_ = tx*M.get_unsafe(0,2)+
ty*M.get_unsafe(1,2)+
tz*M.get_unsafe(2,2);
66 out_inverse_M.set_unsafe(0,3, tx_ );
67 out_inverse_M.set_unsafe(1,3, ty_ );
68 out_inverse_M.set_unsafe(2,3, tz_ );
70 out_inverse_M.set_unsafe(3,0, 0);
71 out_inverse_M.set_unsafe(3,1, 0);
72 out_inverse_M.set_unsafe(3,2, 0);
73 out_inverse_M.set_unsafe(3,3, 1);
78 template <
class IN_ROTMATRIX,
class IN_XYZ,
class OUT_ROTMATRIX,
class OUT_XYZ>
80 const IN_ROTMATRIX & in_R,
81 const IN_XYZ & in_xyz,
82 OUT_ROTMATRIX & out_R,
87 ASSERT_( in_R.isSquare() &&
size(in_R,1)==3 && in_xyz.size()==3)
93 const T tx = -in_xyz[0];
94 const T
ty = -in_xyz[1];
95 const T
tz = -in_xyz[2];
97 out_xyz[0] = tx*in_R.get_unsafe(0,0)+
ty*in_R.get_unsafe(1,0)+
tz*in_R.get_unsafe(2,0);
98 out_xyz[1] = tx*in_R.get_unsafe(0,1)+
ty*in_R.get_unsafe(1,1)+
tz*in_R.get_unsafe(2,1);
99 out_xyz[2] = tx*in_R.get_unsafe(0,2)+
ty*in_R.get_unsafe(1,2)+
tz*in_R.get_unsafe(2,2);
102 out_R = in_R.adjoint();
107 template <
class MATRIXLIKE>
112 const double tx = -M(0,3);
113 const double ty = -M(1,3);
114 const double tz = -M(2,3);
115 M(0,3) = tx*M(0,0)+
ty*M(1,0)+
tz*M(2,0);
116 M(1,3) = tx*M(0,1)+
ty*M(1,1)+
tz*M(2,1);
117 M(2,3) = tx*M(0,2)+
ty*M(1,2)+
tz*M(2,2);
120 t=M(1,0); M(1,0) = M(0,1); M(0,1)=
t;
121 t=M(2,0); M(2,0) = M(0,2); M(0,2)=
t;
122 t=M(1,2); M(1,2) = M(2,1); M(2,1)=
t;
size_t size(const MATRIXLIKE &m, const int dim)
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
#define ASSERTDEB_(f)
Defines an assertion mechanism - only when compiled in debug.
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...