本征,用四元数旋转vector3d吗? [英] Eigen, rotate a vector3d with a quaternion?

查看:69
本文介绍了本征,用四元数旋转vector3d吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个3d点数组,作​​为 std :: vector< Eigen :: Vector3d>

I have an array of 3d point, as an std::vector<Eigen::Vector3d>.

我需要使用位置和四元数来转换这些点。

I need to transform these points with a position and quaternion.

我的问题是:

如何我用四元数旋转这些点?还有比以下更快速的方法:

How can i rotate these points with a quaternion? And is there a faster way than:

    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



        }


推荐答案

操作员 * 即可完成工作,您可以当然可以简化您的代码:

Operator * will do the job, and you can of course simplify your code:

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

甚至:

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

或者,如果您将点存储在 Matrix3Xd

or, if you store your points in a Matrix3Xd:

Matrix3Xd in_pts;
Matrix3Xd out_pts;
Affine3d T = quats * Translation3d(-Trans);
out_pts = T * in_pts;

这篇关于本征,用四元数旋转vector3d吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆