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

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

问题描述

我使用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天全站免登陆