使用四元数插值旋转时出现翻转问题

发布于 2024-09-02 10:58:27 字数 349 浏览 9 评论 0原文

我使用 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

here

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?

Thanks in advance.

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

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

发布评论

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

评论(2

唱一曲作罢 2024-09-09 10:58:27

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

请记住,每次旋转实际上可以用两个四元数 q 和 -q 表示。但是从 q 到 w 的 Slerp 路径与从 (-q) 到 w 的路径不同:一个会走长距离,另一个会走短距离。听起来好像你想要走近路,却走的是远路。

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

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.

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.

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.

孤君无依 2024-09-09 10:58:27

总旋转距离是多少?您可能会要求对角度相差太远的两个方向进行插值。从某种意义上说,无论是否是四元数,数学都很难决定走哪条路。就像动画中没有足够的关键帧一样。

确定大约一半的良好中间方向,并从初始方向到中间方向以及从中间方向到最终方向进行单独的插值。

How far is the total rotation? You may be asking for an interpolation for two orientation too far apart in angle. The math, quaternions or not, has trouble deciding which way to go, in a sense. Like not having enough keyframes in animation.

Determine a good intermediate orientation about halfway along, and make separate interpolations from the initial orientation to that intermediate one, and from the intermediate to the final.

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