使用四元数插入旋转时的翻转问题 [英] Flipping issue when interpolating Rotations using Quaternions

查看:19
本文介绍了使用四元数插入旋转时的翻转问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 slerp 在表示旋转的两个四元数之间进行插值.然后将产生的旋转提取为欧拉角以输入图形库.这种工作,但我有以下问题;当沿绿色箭头方向围绕两个(一个工作正常)轴旋转时,如左图所示

I use slerp to interpolate between two quaternions representing rotations. The resulting rotation is then extracted as Euler angles to be fed into a graphics lib. This kind of works, but I have the following problem; when rotating around two (one works just fine) axes in the direction of the green arrow as shown in the left frame

这里

旋转很快就会跳来跳去,从相反的位置向相反的视觉方向旋转,如右框中的红色箭头所示.

the rotation soon jumps around to rotate from the opposite site to the opposite visual direction, as indicated by the red arrow in the right frame.

从数学的角度来看这可能是合乎逻辑的(虽然对我来说不是),但这是不受欢迎的.围绕多个轴旋转时,如何在没有视觉翻转和方向改变的情况下实现插值,始终遵循绿色箭头直到插值完成?

This may be logical from a mathematical perspective (although not to me), but it is undesired. How could I achieve an interpolation with no visual flipping and changing of directions when rotating around more than one axis, following the green arrow at all times until the interpolation is complete?

提前致谢.

推荐答案

坦率地说,您对问题的描述有点难以理解.但听起来您需要否定您的四元数之一.

Your description of the problem is a little hard to follow, quite frankly. But it sounds like you need to negate one of your quaternions.

请记住,每个旋转实际上可以由两个四元数 q 和 -q 表示.但是从 q 到 w 的 Slerp 路径将与从 (-q) 到 w 的路径不同:一个会走很长的路,另一个走很短的路.当你想要短途时,听起来你正在走很长的路.

Remember, each rotation can actually be represented by two quaternions, q and -q. But the Slerp path from q to w will be different from the path from (-q) to w: one will go the long away around, the other the short away around. It sounds like you're getting the long way when you want the short way.

尝试取两个四元数的点积(即 4-D 点积),如果点积为负,则在执行 Slerp 之前将四元数 q1 和 q2 替换为 -q1 和 q2.

Try taking the dot product of your two quaternions (i.e., the 4-D dot product), and if the dot product is negative, replace your quaterions q1 and q2 with -q1 and q2 before performing Slerp.

这篇关于使用四元数插入旋转时的翻转问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆