Eigen combine rotation and translation into one matrix

前端 未结 3 1047
野趣味
野趣味 2021-02-02 02:32

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

3条回答
  •  不思量自难忘°
    2021-02-02 03:05

    Another method is to do the following:

    Eigen::Matrix3d R;
    // Find your Rotation Matrix
    Eigen::Vector3d T;
    // Find your translation Vector
    Eigen::Matrix4d Trans; // Your Transformation Matrix
    Trans.setIdentity();   // Set to Identity to make bottom row of Matrix 0,0,0,1
    Trans.block<3,3>(0,0) = R;
    Trans.block<3,1>(0,3) = T;
    

    This method literally copies the Rotation matrix into the first 3 rows and columns and the translation vector to the 4th column. Then sets the bottom right matrix entry to 1. You final matrix will look like:

    R R R T
    R R R T
    R R R T
    0 0 0 1
    

    where R are the corresponding values from the rotation matrix and T the values from the Translation vector.

提交回复
热议问题