Search code examples
c++image-rotationprinter-control-language

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


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.


Solution

  • 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!