在旋转矩阵之间插值
我有 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用四元数 (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).
我个人的观点是,使用四元数来处理此类事情更有意义。也就是说,您可以在不使用四元数的情况下做到这一点。
需要注意的是,“差”矩阵,即将“方位”
A
转化为“方位”B
的矩阵,可以通过T计算出来= A.tranpose() * B
(考虑到您在右侧相乘)。一旦有了旋转矩阵T
,您就可以转换为轴角表示(例如,请参见 http://en.wikipedia.org/wiki/Axis-angle_representation)。最后,由于您知道从
A
到B
的旋转轴,因此您可以将角度从零线性插值到之前根据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 byT = A.tranpose() * B
(considering you are multiplying on the right). Once you have the rotation matrixT
, 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
toB
, you can linearly interpolate the angles from zero to the angle previously calculated fromT
.This is equivalent to using SLERP.