将局部旋转添加到全局旋转

发布于 2024-11-14 05:27:20 字数 509 浏览 4 评论 0原文

我尝试了很多公式和转换,但没有给我带来我期望的结果。

场景很简单:

3DS Max等3D软件如何将局部旋转增量“转化”为全局绝对旋转?

一个例子可以帮助你理解: 3DS Max - Maya - Modo(所有三个都给了我相同的结果,所以我倾向于相信这个结果是正确的。)假设绝对旋转顺序为 XYZ。

1. World Rotation Y = 35.0;
2. Local Rotation X = 35.0;

在这些转换之后,按照这个顺序,我查看世界绝对旋转,我看到的是 X:40.524 Y:-28.024 Z:-21.881

他们是如何实现这个结果的?什么样的公式?使用矩阵、欧拉角或四元数,无论如何,我怎样才能得到相同的结果?

谢谢。

PS:一个简单的解决方案是使用四元数或矩阵,将局部旋转添加到全局旋转中,然后检索绝对结果。但这效果不佳,因为这样我们无法控制旋转顺序,结果总是使用公式的顺序来检索值。

I've tried many formulas and conversions, but nothing gave me the result I expect.

The scenario is very simple:

How the 3DS Max and other 3D softwares make the "transformation" of an increment in local rotation to the global absolute rotation?

An example can help you to understand:
3DS Max - Maya - Modo (all three gave me the same result, so I'm inclined to believe that this result is correct.) Assuming Absolute rotation order as XYZ.

1. World Rotation Y = 35.0;
2. Local Rotation X = 35.0;

After these transformations, in that order, I look at the World Absolute rotation and what I see is X:40.524 Y:-28.024 Z:-21.881

How they achieve that result? What kind of formula? Using matrix, Euler angles or quaternions, whatever, how can I get the same result?

Thank you.

PS: A simple solution could be use of a quaternion or a matrix, add the local rotation into the global and then retrieve the absolute result. But this doesn't work well, because at this way we don't have control over the rotation order, the result always come using the order of the formula to retrieve the values.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

最终幸福 2024-11-21 05:27:20

您想要根据旋转应用的顺序旋转矩阵,如果要首先应用局部旋转(我怀疑是这样),那么:(

WorldMat * LocalMat [* column vector]

前提是您预先-乘以列向量来应用你的变换,如果你以相反的方式做,只需取整个表达式的转置)

类似地,如果你正在使用四元数,你应该你的四元数(不添加它们)。

You want to multiply the rotation matrices in order dependent on the order in which the rotations are applied, if the local rotation is to be applied first (which I suspect it is) then:

WorldMat * LocalMat [* column vector]

(provided you are pre-multiplying column vectors to apply your transformations, just take the transpose of the whole expression if you're doing it the other way round)

Similarly, if you are working with quaternions you should be multiplying your quaternions (not adding them).

丑丑阿 2024-11-21 05:27:20

旋转矩阵如下所示(假设列向量表示):

[   1      0       0   ]
[   0    cos(a)  sin(a)] = Rx(a)
[   0   -sin(a)  cos(a)] 

[ cos(a)   0    -sin(a)]
[   0      1       0   ] = Ry(a)
[ sin(a)   0     cos(a)]

[ cos(a) sin(a)   0    ]
[-sin(a) cos(a)   0    ] = Rz(a)
[   0      0      1    ]

乘以“局部”意味着矩阵位于右侧。乘以“全局”意味着矩阵位于左侧。所以你的旋转是Ry(35°)*Rx(35°)。或者近似:

[ .819  .329 -.469 ]
[  0    .019  .574 ]
[ .574 -.470  .671 ]

欧拉旋转顺序 XYZ 表示Rx(ax)*Ry(ay)*Rz(az)。因此,如果您插入数字Rx(40.524°)*Ry(-28.024°)*Rz(-21.881),您将得到大约(在舍入误差内)相同的矩阵(我做了尝试一下,只是为了确定一下)。

The rotation matrices look like this (assuming column vector representation):

[   1      0       0   ]
[   0    cos(a)  sin(a)] = Rx(a)
[   0   -sin(a)  cos(a)] 

[ cos(a)   0    -sin(a)]
[   0      1       0   ] = Ry(a)
[ sin(a)   0     cos(a)]

[ cos(a) sin(a)   0    ]
[-sin(a) cos(a)   0    ] = Rz(a)
[   0      0      1    ]

Multiplying 'local' means that the matrix goes on the right. Multiplying 'global' means the matrix goes on the left. So your rotation is Ry(35°)*Rx(35°). Or approximately:

[ .819  .329 -.469 ]
[  0    .019  .574 ]
[ .574 -.470  .671 ]

The Euler rotation order XYZ means Rx(ax)*Ry(ay)*Rz(az). So, if you plug in the numbers Rx(40.524°)*Ry(-28.024°)*Rz(-21.881), you get approximately (within round-off error) the same matrix (I did try it, just to make sure).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文