c++ - Eigen ,用四元数旋转vector3d?

标签 c++ eigen

我有一个 3D 点数组,作​​为 std::vector<Eigen::Vector3d> .
我需要用位置和四元数转换这些点。
我的问题是:
如何用四元数旋转这些点?有没有比以下更快的方法:

    Eigen::Vector3d Trans; // position to move by
    Eigen::Quaterniond quats;  // quat to rotate by

for (int p = 0; p < objectPoints.size(); p++)
        {
            Eigen::Vector3d pnt;
            //add pose
            pnt.x = objectPointsTri[p].x + -Trans.x();
            pnt.y = objectPointsTri[p].y + -Trans.y();
            pnt.z = objectPointsTri[p].z + -Trans.z();

            Eigen::Vector3d pntRot = // rotate pnt by the quaternion



        }

最佳答案

接线员 *将完成这项工作,您当然可以简化您的代码:

pnt = objectPointsTri[p] - Trans;
pntRot = quat * pnt;

甚至:
pnt = quat * (objectPointsTri[p] - Trans);

或者,如果您将积分存储在 Matrix3Xd 中:
Matrix3Xd in_pts;
Matrix3Xd out_pts;
Affine3d T = quats * Translation3d(-Trans);
out_pts = T * in_pts;

关于c++ - Eigen ,用四元数旋转vector3d?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50507665/

相关文章:

c++ - 在不使用虚拟析构函数的情况下删除继承对象时中止

c++ - 如何创建一个自动启动的 C++ 程序

c++ - 采用恒定特征参数的重载函数的歧义

c++ - 在 EIGEN 中错误地设置 vector

c++ - Armadillo 的solve(A, b)从Matlab、Eigen返回不同的答案

c++ - 我怎样才能从文件中提取文件属性/元数据/注释

c++ - 似乎从复制构造函数中得到段错误?

c++ - Windows 套接字通知接收器

c++ - 将特征库中的 VectorXi 传递给类方法

c++ - 点云库:如何使用 pcl::addCoordinateSystem(double scale, const Eigen::Affine3f & t, int viewport = 0))