如果我有角度和轴,如何在 PCL 中进行旋转平移?

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

我想做一个点云的平移,目前我有轴的矢量和角度。我可以自动构建矩阵还是必须像 this?

那样手动计算它

在 PCL example 他们使用他们构建的 MAtrix 4x4,所以我希望有人知道一种自动获取此矩阵的方法。

在你给出的example中已经有一个更简单的构造变换矩阵的方法。不仅包括旋转,还包括移动(即平移)。

 /*  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())); 

示例中缺少的是,在 Eigen::AngleAxisf 的第二个参数中,我们应该像这样添加轴:

 //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);

我也不得不分两行写,因为我在编译时出现了模板错误。我刚刚添加了浮动,它起作用了!