I have a rotation matrix rot
(Eigen::Matrix3d) and a translation vector transl
(Eigen::Vector3d) and I want them both together in a 4x4 transformation matrix. I just for the life of me can't figure out how to do this in Eigen. I think Affine can be used somehow but I don't understand how it works.
Essentially I want a combination of How translation a matrix(4x4) in Eigen? and Multiplying Transform and Matrix types in Eigen
My code (that doesn't compile as I don't understand how Affine works) looks like this:
Eigen::Affine3d r(rot);
Eigen::Affine3d t(transl);
Eigen::Matrix4d m = t.matrix();
m *= r.matrix();
m = m * t.matrix()
, maybe the problem is the lack of operator*=
. Does it work that way? – CircumspectEigen
but a rotation matrix is in general a 3x3 matrix which you can put directly in your 4x4 matrix (assuming you don't have any scaling going on). In a 4x4 transformation matrix the elements _00, _01, _02, _10, _11, _12, _20, _21 and _22 form the rotation (time scale if you have scaling). The elements _30, _31 and _32 are the translation vector elements. – Peasecod