四元数与欧拉角

发布于 11-07 05:42 字数 223 浏览 4 评论 0原文


四元数”和“欧拉角”方法的优点缺点
- 哪一个更快
- 哪一个需要更少的计算工作
- 哪一个更准确(在舍入误差中)?

Hi
What is the pros and cons of "Quaternions" and "Euler Angles" Method
- Which one is faster?
- Which one need less Computational Effort?
- which one is more accurate, (in round off error)?

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

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

发布评论

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

评论(6

咆哮2024-11-14 05:42:57

欧拉角更容易被人类理解,也有利于将旋转分解为单独的自由度(对于运动关节等),但具有模糊性和万向节锁定等缺点。在实践中,我更喜欢四元数,因为它们更容易计算(对于计算机,而不是人类)并且效率更高。当按欧拉角旋转时,您必须进行三次旋转并将它们相乘,而四元数只有一次旋转,并且由于它已经对 sin 和 cos 进行了编码,因此从四元数到矩阵的转换非常有效。

Euler angles are more human understandable and also good for decomposing rotations into individual degrees of freedom (for kinematic joints and the like) but have disadvantages like ambiguity and gimbal lock. In practice I would prefer quaternions, as they are easier to compute with (for the computer, not for humans) and more efficient. You have to make three rotations and multiply them together when rotating by Euler angles, whereas a Quaternion is only one rotation and as it already encodes the sin and cos, the conversion from quaternion to matrix is quite efficient.

不必了2024-11-14 05:42:57

四元数避免万向节锁定。更多信息请此处

Quaternions avoid Gimbal lock. More here.

薄暮涼年2024-11-14 05:42:57

从克里斯蒂安·劳(Christian Rau)的回答中扩展一点:

欧拉角的规范存在歧义:哪个角度适用于哪个轴?使用约定(偏航、俯仰、横滚)的代码不会与假设(横滚、俯仰、横滚)的代码互操作,并且从查看代码来看,正在使用哪种解释可能并不明显。

四元数不会受到这种歧义的影响,因为它们仅表示具有明确定义的轴的单个旋转。

Expanding a bit on a point from Christian Rau's answer:

There's an ambiguity in the specification of Euler angles: which angle applies to which axis? Code that uses the convention (yaw, pitch, roll) won't interoperate with code that assumes (roll, pitch, yaw), and it may not be obvious, from looking at the code, which interpretation is being used.

Quaternions don't suffer from this ambiguity, since they only represent a single rotation, with a well-defined axis.

吾家有女初长成2024-11-14 05:42:57

正如其他答案中指出的那样,四元数比欧拉角有很多优点。但是,欧拉角确实比四元数有一个优势:

欧拉角可以告诉您旋转的方向和大小。当您将欧拉角转换为四元数时,该信息就会丢失。例如,(-270°, 0, 0) 和 (1170°, 0, 0) 的欧拉旋转产生相同的四元数 (-0.7071, 0, 0, -0.7071)。

Quaternions have many advantages over Euler angles, as pointed out in the other answers. However, Euler angles do have one advantage over Quaternions:

Euler angles can tell you the direction and magnitude of a rotation. When you convert a Euler angle to a Quaternion, that information is lost. For example, the Euler rotations of (-270°, 0, 0) and (1170°, 0, 0) produce the identical Quaternions (-0.7071, 0, 0, -0.7071).

樱花坊2024-11-14 05:42:57

欧拉角比四元数更好。您应该始终将欧拉角存储在内存中,并仅使用四元数进行计算。没有人知道这一点,但我说的是绝对正确的。如果您潜伏在周围,请知道这很重要。听我说完。

原因是因为您总是可以轻松地从欧拉角导出四元数。转换是微不足道的。然而,从四元数到欧拉角的转换从根本上被破坏了。每个四元数都有两个可能的欧拉角,您无法知道您的四元数来自这两种可能性中的哪一种。

对于虚拟世界和 3D 游戏,您始终可以只使用四元数。这是因为您的计算机可以仅在某个方向上绘制物体的图片,而无需实际偏航和俯仰实际的物理万向节来实现该方向。然而,对于机器人和其他现实世界的应用程序来说,转换为四元数时确实会丢失信息。

如果您有一个真实的物理万向节,并且给定了一个代表该万向节方向的四元数,那么您绝对无法提取用于实现该方向的万向节原始偏航、滚动或俯仰,除非万向节在某处的运动范围受到限制。

记住这一点。如果您处于机器人技术或某些机械设置中,请将方向值保存为原始欧拉角。仅暂时转换为四元数仅用于计算。

一旦转换为四元数,基本上就不再返回欧拉了。因此,不要使该行程永久化,而是将所有信息存储为欧拉角。

Euler angles are better than quaternions. You should always store Euler angles in memory and use quaternions only for calculations. Nobody knows this but what I say is absolutely true. If you're lurking around, know that this is important. Hear me out.

The reason is because you can always easily derive a quaternion from a Euler angles. The conversion is trivial. However the conversion from quaternion to Euler angles is fundamentally broken. There are two possible Euler angles for every quaternion and you cannot know which of the two possibilities your quaternions came from.

For virtual worlds and 3D games you can always just use quaternions. This is because your computer can just draw a picture of the object at an orientation without actually yawing and pitching an actual physical gimbal to achieve that orientation. However for robots and other real world applications there is real information loss when converting to a quaternion.

If you have a real physical gimbal and you are given a quaternion that represents the orientation of that gimbal you absolutely cannot ever extract the original yaw, roll or pitch the gimbal used to achieve that orientation UNLESS the gimbal is restricted in it's range of motion somewhere.

Remember this. If you're in robotics or some mechanical setting save the orientation value as the original Euler angles. Only convert to quaternions temporarily only for a calculation.

There's basically no return trip back to Euler once you convert to quaternion. So don't make that trip permanent, store all your information as Euler angles.

夕色琉璃2024-11-14 05:42:57

欧拉角更快。

欧拉角需要较少的计算工作。

四元数绝对更准确。

在欧拉角中发现了一个称为万向节锁的问题。当两个轴对齐时就会发生这种情况。
另一方面,四元数更灵活,并且解决了这个问题,因为它更面向轴。然而,理解起来却很复杂。

好吧,为了让大家更容易理解四元数。让我们将四个分量一分为二:一个角度和连接到轴原点(即 P)的 x、y、z 点。
(x,y,z)-P 线代表新轴。
该角度表示轴与实际方向之间的角度。
为了直观地看到这个答案,您需要观看这个 5 分钟的视频。
https://eater.net/quaternions/video/intro

Euler angles is faster.

Euler angles requires less computational effort.

Quaternions are absolutely more accurate.

There is a problem called Gimbal lock which was found in Euler angles. It happens when two axis align together.
On the other hand quaternions are more flexible and solved this problem as it is more axis oriented. Yet, it is complicated to understand.

Well, to make it easy to understand Quaternions. Let's divide the four components to two: An angle and x,y,z point that is connected to the origin of the axis say P.
The (x,y,z)-P line representing a new axis.
The angle represents the angle between the axis and real orientation.
To visualize this answer you need to check this 5-minutes video.
https://eater.net/quaternions/video/intro

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