我在Eigen中进行了几次转换( Eigen::Vector3f )和旋转( Eigen::Quaternionf )。 我想按照我选择的顺序将所有这些转换组合成一个4x4转换矩阵Eigen::Matrix4f 。
例如,我想在A,B,C,D,E的顺序中应用以下转换:
Eigen::Vector3f translation_A; Eigen::Quaternionf rotation_B; Eigen::Quaternionf rotation_C; Eigen::Quaternionf rotation_D; Eigen::Vector3f translation_E;实现这个最简单的方法是什么? 到目前为止,我一直将它们分别应用于我的最终数据,如下所示:
pcl::transformPointCloud(*cloud_in, *cloud_out, translation_A, IDENTITY_QUATERNION); pcl::transformPointCloud(*cloud_out, *cloud_out, ZERO_TRANSLATION, rotation_B); pcl::transformPointCloud(*cloud_out, *cloud_out, ZERO_TRANSLATION, rotation_C); pcl::transformPointCloud(*cloud_out, *cloud_out, ZERO_TRANSLATION, rotation_D); pcl::transformPointCloud(*cloud_out, *cloud_out, translation_E, IDENTITY_QUATERNION);...但是必须有一个简单的(内置的)方法将这些使用Eigen的转换组合到最终的4x4转换矩阵中。
I have several transformations in Eigen, in the form of translations (Eigen::Vector3f) and rotations (Eigen::Quaternionf). I would like to combine all these transformations, in an order of my choosing, into a 4x4 transformation matrix Eigen::Matrix4f.
For example, I would like to apply the following transformations in the order A, B, C, D, E:
Eigen::Vector3f translation_A; Eigen::Quaternionf rotation_B; Eigen::Quaternionf rotation_C; Eigen::Quaternionf rotation_D; Eigen::Vector3f translation_E;What is the simplest way of achieving this? I have so far been applying them individually to my final data like so:
pcl::transformPointCloud(*cloud_in, *cloud_out, translation_A, IDENTITY_QUATERNION); pcl::transformPointCloud(*cloud_out, *cloud_out, ZERO_TRANSLATION, rotation_B); pcl::transformPointCloud(*cloud_out, *cloud_out, ZERO_TRANSLATION, rotation_C); pcl::transformPointCloud(*cloud_out, *cloud_out, ZERO_TRANSLATION, rotation_D); pcl::transformPointCloud(*cloud_out, *cloud_out, translation_E, IDENTITY_QUATERNION);...but there must be a simple (built-in?) way of combining these transformations using Eigen, into a final 4x4 transformation matrix.
最满意答案
Eigen文档中有一个很好的教程: 这里
在你的情况下,这应该看起来像:
Eigen::Vector3f trans_vec_A; //note that you have to create a Translation because multiplying a //Transform with a vector will _apply_ the transform to the vector Eigen::Translation<float,3> translation_A(trans_vec_A); Eigen::Quaternionf rotation_B; Eigen::Quaternionf rotation_C; Eigen::Quaternionf rotation_D; Eigen::Vector3f trans_vec_E; Eigen::Translation<float,3> translation_E(trans_vec_E); Eigen::Transform<float,3,Affine> combined = translation_A * rotation_B * rotation_C * rotation_D * translation_E;注意
combined = A*B*C*D*E所以combined应用于矢量v是
combined*v = A*B*C*D*E*v = A*(B*(C*(D*(E*v))))即首先应用E ,然后应用D ,依此类推。 在我看来,这是正确的顺序,但这可能是一个品味问题。
There is a good tutorial in the Eigen docs: here
In your case, this should look like:
Eigen::Vector3f trans_vec_A; //note that you have to create a Translation because multiplying a //Transform with a vector will _apply_ the transform to the vector Eigen::Translation<float,3> translation_A(trans_vec_A); Eigen::Quaternionf rotation_B; Eigen::Quaternionf rotation_C; Eigen::Quaternionf rotation_D; Eigen::Vector3f trans_vec_E; Eigen::Translation<float,3> translation_E(trans_vec_E); Eigen::Transform<float,3,Affine> combined = translation_A * rotation_B * rotation_C * rotation_D * translation_E;Note that
combined = A*B*C*D*Eso combined applied to a vector v is
combined*v = A*B*C*D*E*v = A*(B*(C*(D*(E*v))))that is, E is applied first, then D, and so on. In my mind, this is the correct order, but that may be a matter of taste.
更多推荐
发布评论