四元数仍然有万向节锁

发布于 2024-10-21 06:43:06 字数 816 浏览 7 评论 0原文

我不再使用欧拉角,而是使用四元数来表示和处理 3D 立方体的旋转。虽然它可以解决万向节锁定问题,但我仍然遇到这个问题。

我的代码是:

// p is the point to be rotated
// angles is a Vector3D representing the rotation angles

var xaxis = new Vector3D(1, 0, 0);
var yaxis = new Vector3D(0, 1, 0);
var zaxis = new Vector3D(0, 0, 1);

p = rotate(p, xaxis, angles.x);
p = rotate(p, yaxis, angles.y);
p = rotate(p, zaxis, angles.z);

rotate 函数来自 http://en .wikipedia.org/wiki/Quaternions_and_spatial_rotation#Pseudo-code_for_rotating_using_a_quaternion_in_3D_space(翻译成JavaScript)。

我想问题是由于我仍然使用轴的顺序(xy z),这是万向节锁的主要问题。

如何以解决万向节锁定的方式实现四元数旋转?

提前致谢。

Instead of Euler angles I moved to Quaternions to represent and process the rotation of a cube in 3D. Although it would solve gimbal lock, I'm still experiencing this issue.

My code is:

// p is the point to be rotated
// angles is a Vector3D representing the rotation angles

var xaxis = new Vector3D(1, 0, 0);
var yaxis = new Vector3D(0, 1, 0);
var zaxis = new Vector3D(0, 0, 1);

p = rotate(p, xaxis, angles.x);
p = rotate(p, yaxis, angles.y);
p = rotate(p, zaxis, angles.z);

The rotate functions comes from http://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation#Pseudo-code_for_rotating_using_a_quaternion_in_3D_space (translated into JavaScript).

I guess the problem is due to the fact that I still use an order of axes (x y z) which is the main problem of gimbal lock.

How would one implement quaternion rotation in such a way that gimbal lock is solved?

Thanks in advance.

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

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

发布评论

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

评论(2

尸血腥色 2024-10-28 06:43:07

四元数不易受到万向节锁定的影响,所以这不是你的问题。如果你的
x、y 和 z 角旨在表示类似欧拉角的东西,问题
您更有可能相对于原始定义 xaxis、yaxis 和 zaxis
坐标系。但这不会给出预期的结果,因为在第一个之后
绕x轴旋转,Y轴和Z轴不指向原始方向
不再多了,但接下来的两次旋转仍然参考原始坐标
系统。

Quaternions are not susceptible to gimbal lock, so that's not your problem. If your
x, y, and z angles are intended to represent something like Euler angles, the issue
is more likely that you're defining xaxis, yaxis, and zaxis relative to the original
coordinate system. But that won't give the expected results, because after the first
rotation around xaxis, the Y and Z axes don't point in the original directions
any more, yet the next two rotations are still referenced to the original coordinate
system.

神回复 2024-10-28 06:43:06

正如您提到的,每当您连续旋转三个(例如欧拉角)以从惯性坐标系到身体坐标系时,就会出现万向节锁定问题。这包括组合三个连续的四元数旋转(通过称为组合的操作)。

四元数之所以能够克服万向节锁,是因为它们可以在一次旋转中表示从惯性坐标系到身体固定坐标系的变换。然而,恕我直言,这是四元数的一大缺点 - 提出所需的四元数在物理上并不直观。

As you mention the gimbal lock issue arises anytime you do three consecutive rotations (such as Euler Angles) to get from an inertial coordinate frame to a body frame. This includes combining three successive quaternion rotations (through a operation called composition).

The reason why quaternions can overcome gimbal lock is that they can represent the transformation from the inertial coordinate frame to the body fixed frame in a single rotation. This is however imho the big disadvantage of quaternions - it is not physically intuitive to come up with a desired quaternion.

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