gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 15:45:34 25 4
gpt4 key购买 nike

我有一个 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com