0

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.

aburbanol
  • 437
  • 8
  • 27

2 Answers2

1

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())); 
Oncaphillis
  • 1,888
  • 13
  • 15
  • I already saw that part, I was wondering how to add the vector, but i finally found it in the Eigen Documentation, not in the PCL one. Thanks @Oncaphilis! – aburbanol Jan 26 '16 at 11:50
1

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!

aburbanol
  • 437
  • 8
  • 27