Howto make a roto-translation in PCL if I have the angle and the axis?

Question!

I want to make a translation of a point cloud, currently I have the vector of the axis and I also have the angle. Can I construct automatically the matrix or I have to calculate it by manually like this?

In the PCL example they use a MAtrix 4x4 that they build, so I hope someone know a way to obtain this matrix automatically.

By : aburbanol


Answers

What was missing in the Example is that in the second parameter of Eigen::AngleAxisf we should add the axis like this:

 //Eigen::Transform t;
Eigen::Vector3f axis(v_Ux,v_Uy,v_Uz);
 Eigen::Affine3f transform_2 = Eigen::Affine3f::Identity();
// Define a translation of 2.5 meters on the x axis.
transform_2.translation() << 2.5, 0.0, 0.0;
Eigen::AngleAxis<float> rot(angle,axis);
transform_1.rotate(rot);

I also had to write it in 2 lines because when I was compiling I had template errors. I just added the float and it worked!

By : aburbanol


In the example given by you there already is a simpler method of constructing a transformation matrix. Not only covering rotation but also shifting (i.e. translation).

 /*  METHOD #2: Using a Affine3f
    This method is easier and less error prone
  */
  Eigen::Affine3f transform_2 = Eigen::Affine3f::Identity();

  // Define a translation of 2.5 meters on the x axis.
  transform_2.translation() << 2.5, 0.0, 0.0;

  // The same rotation matrix as before; tetha radians arround Z axis
  transform_2.rotate (Eigen::AngleAxisf (theta, Eigen::Vector3f::UnitZ())); 


This video can help you solving your question :)
By: admin