在旋转矩阵之间插值

发布于 2024-10-30 19:38:23 字数 397 浏览 0 评论 0原文

我有 2 个旋转矩阵(我们称它们为 A 和 B),其中:

A = 1  0  0
    0  0 -1
    0  1  0

B = -1  0  0
     0  0 -1
     0 -1  0

基本上只是相机旋转以查看其后方的旋转。 显然我不能直接对矩阵中的值进行插值,因为它看起来很奇怪。 我尝试将矩阵转换为欧拉角,从而产生 2 组 X、Y、Z 角度,并尝试根据 X、Y、Z 角度每个分量之间的最小距离确定要使用的角度。这肯定会导致我想要的旋转,但我想不出一种合适的方法来确定在哪些角度之间进行插值,因为有时导致最小误差的角度集会导致绕错误的轴旋转。 我也尝试过四元数,但这基本上给了我相同的结果。有人能指出我正确的方向吗?

I have 2 rotation matrices (lets call them A and B) where:

A = 1  0  0
    0  0 -1
    0  1  0

and

B = -1  0  0
     0  0 -1
     0 -1  0

This is basically just a rotation where the camera spins around to look behind itself.
Obviously I can't just interpolate the values in the matrices directly because it looks weird.
I have tried converting the matrices to Euler angles which yields 2 sets of X,Y,Z angles and trying to determine which angles to use based on the minimum distance between each component of the X,Y,Z angle. That definitely results in the kind of rotation I want but I can't think of a decent way to determine which angles to interpolate between because sometimes the sets of angles which result in the least error result in a rotation about the wrong axis/axes.
I also tried quaternions but that essentially gave me the same result. Can anyone point me in the right direction?

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

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

发布评论

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

评论(2

粉红×色少女 2024-11-06 19:38:23

使用四元数 (SLERP)。旋转矩阵和欧拉角都不适合插值。

请参阅此处的 45:05(David Sachs,Google 技术讲座)

Use quaternions (SLERP). Neither rotation matrices nor Euler angles are appropriate for interpolation.

See 45:05 here (David Sachs, Google Tech Talk).

落日海湾 2024-11-06 19:38:23

我个人的观点是,使用四元数来处理此类事情更有意义。也就是说,您可以在不使用四元数的情况下做到这一点。

需要注意的是,“差”矩阵,即将“方位”A转化为“方位”B的矩阵,可以通过T计算出来= A.tranpose() * B (考虑到您在右侧相乘)。一旦有了旋转矩阵 T,您就可以转换为轴角表示(例如,请参见 http://en.wikipedia.org/wiki/Axis-angle_representation)。

最后,由于您知道从 AB 的旋转轴,因此您可以将角度从零线性插值到之前根据 T 计算出的角度。

这相当于使用 SLERP。

My personal opinion is that using quaternions for this type of thing makes more sense. That said, you can do it without using quaternions.

The thing to notice is that the "difference" matrix, that is, the matrix which takes "orientation" A into "orientation" B can be calculated by T = A.tranpose() * B (considering you are multiplying on the right). Once you have the rotation matrix T, you can convert to Axis-Angle representation (see for instance http://en.wikipedia.org/wiki/Axis-angle_representation).

Finally, since you know a rotation axis which takes A to B, you can linearly interpolate the angles from zero to the angle previously calculated from T.

This is equivalent to using SLERP.

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