用欧拉角旋转一个四元数
Rotate a Quaternion with Euler angles using Eigen
我正在尝试创建一个四元数,围绕欧拉角旋转它并将其转换回欧拉角。我用的是Eigen。从欧拉转换到四元数,反之亦然,但当我使用角轴旋转时,我的值大约下降了20 - 50%。例如,当我尝试从0,0,0旋转到90,50,60时,我得到x: 75,5 y: 103,13, z: 78,46。你知道我哪里拐错弯了吗?我使用102/YXZ惯例。我试图实现它像这里描述:旋转四元数欧拉角度输入。
Vector3f retVector;
Matrix3f rotFromMat, qautRotMatrix;
const auto fromPitch = xFrom*M_PI/360;
const auto fromYaw = zFrom*M_PI / 360;
const auto fromRoll = yFrom*M_PI / 360;
rotFromMat = AngleAxisf(fromRoll, Vector3f::UnitY())
* AngleAxisf(fromPitch, Vector3f::UnitX())
* AngleAxisf(fromYaw, Vector3f::UnitZ());
Quaternionf fromQuat(rotFromMat);
fromQuat.normalize();
fromQuat = fromQuat * AngleAxisf(yTo, Vector3f::UnitY());
fromQuat = fromQuat * AngleAxisf(xTo, Vector3f::UnitX());
fromQuat = fromQuat * AngleAxisf(zTo, Vector3f::UnitZ());
qautRotMatrix = fromQuat.toRotationMatrix();
retVector = quatRotMatrix.eulerAngles(1, 0, 2);
retVector *= 360 / M_PI;
return retVector;
你没有详细说明如何复制这个。
但是我可以看出两个错误:*度和弧度的比值是180/PI,而不是360/PI。*你的轮换顺序不对!左侧正在旋转右侧:
fromQuat = AngleAxisf(...) * fromQuat;
从日期我猜你已经解决了这个问题,我在这里为新的观众评论
相关文章:
- 单元测试欧拉到四元数实现失败
- 零四元数和任何向量都不为零的特征积,这是一个错误吗?
- 将四元数旋转的游戏对象旋转另一个四元数时出现问题
- 在OpenGL(GLM/C++)中使用四元数旋转时出现问题
- 想要将 CGAL 与四元数相结合是否合乎逻辑
- Eigen::Quaternion FromTwoVectors() 不返回有效的四元数
- C++四元数方程程序
- 四元数旋转不起作用
- 四元数和翻译
- 使用四元数防止绕某个轴旋转
- 如何使用四元数来描述超过360度的旋转角度?
- 四元数旋转错误
- 为什么我简单的四元数乘法比SSE快
- 特征:将矩阵3d旋转转换为四元数
- 从四元数查看矩阵
- 用四元数绕轴旋转矢量
- 基于四元数的相机不需要的卷轴
- 在C++中使用1D FFT的四元数FFT
- 四元数到轴的角度
- 用欧拉角旋转一个四元数