Rotation matrixandTranslation vectorcompositionHomogeneous transformation matrix

Block operation

Block operation Version constructing a dynamic-size block expression Version constructing a fixed-size block expression
Block of size (p,q), starting at (i,j) matrix.block(i,j,p,q) matrix.block<p,q>(i,j);

methods

Matrix3f r; // rotation matrix
Vector3f t; // translation vector

Matrix4f trans; // transformation matrix
trans.setIdentity();   // set to identity
trans.block<3.3> (0.0) = r; // first 3x3 block set to rotation matrix
trans.block<3.1> (0.3) = t; // fourth column set to translation vector
Copy the code

test

#include <iostream> #include <exception> #include <Eigen/Eigen> using namespace std; using namespace Eigen; Constexpr float PI = 3.14f; constexpr float PI = 3.14f; int main(int argc, char **argv) { Matrix3f r; // rotation matrix Vector3f t; // translation vector AngleAxisf rot_x (pi/4, Vector3f(1, 0, 0)); r = rot_x.matrix(); T = {0.0f, 0.5f, 0.0f}; /* construct transformation matrix with rotaion matirx and translation vector */ Matrix4f trans; // transformation matrix trans.setIdentity(); // set to identity trans. Block <3,3>(0,0) = r; Rotation matrix trans. Block <3,1>(0,3) = t; // fourth column set to translation vector /* print */ cout << "rotaiton matrix: " << endl << r.format({3}) << endl; cout << "translation vector: " << endl << t.format({3}) << endl; cout << "transformation matrix: " << endl << trans.format({3}) << endl; return EXIT_SUCCESS; }Copy the code

The output

reference

  • [1] Block operations