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
Another way is to use the Eigen::Transform.
Let's take a example such as to implemente this affine transform ,
#include
#include
using namespace Eigen;
Matrix4f create_affine_matrix(float a, float b, float c, Vector3f trans)
{
Transform t;
t = Translation(trans);
t.rotate(AngleAxis(a, Vector3f::UnitX()));
t.rotate(AngleAxis(b, Vector3f::UnitY()));
t.rotate(AngleAxis(c, Vector3f::UnitZ()));
return t.matrix();
}
You can also implemented as the following
Matrix4f create_affine_matrix(float a, float b, float c, Vector3f trans)
{
Transform t;
t = AngleAxis(c, Vector3f::UnitZ());
t.prerotate(AngleAxis(b, Vector3f::UnitY()));
t.prerotate(AngleAxis(a, Vector3f::UnitX()));
t.pretranslate(trans);
return t.matrix();
}
The difference between the first implementation and the second is like the difference between Fix Angle and Euler Angle, you can refer to this video.