什么时候需要使用四元数?

发布于 2024-08-13 23:30:35 字数 182 浏览 5 评论 0原文

我多年来一直在进行 2D 和 3D 操作,包括图形,并且从未使用过四元数,所以我对它们没有感觉。我知道它们可以用于欧拉角中困难的某些操作,并且它们可以用于找到最适合一组坐标(X1,X2...XN,X=(xyz))所需的旋转到另一个(X1',X2'...XN')。

有哪些地方需要四元数?他们是否在某些地方使解决方案变得更优雅或更高效?

I have been carrying out 2D and 3D operations, including graphics, for many years and have never used quaternions so I don't have a feel for them. I know that they can be used for certain operations that are difficult in Euler angles and also that they can be used to find the rotation required to best fit one set of coordinates (X1, X2...XN, X=(xyz)) onto another (X1', X2'... XN').

Are there places where quaternions are essential? And are there places where they make solutions more elegant or more efficient?

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

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

发布评论

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

评论(6

゛清羽墨安 2024-08-20 23:30:35

它们比旋转矩阵具有更小的内存占用,并且比矩阵和角度/轴表示更有效。

另外:

  • 在两个四元数之间进行插值非常容易,这对于平滑相机移动等很有用。
  • 浮点四元数的单位归一化比矩阵表示的舍入缺陷更少。

They have a smaller memory footprint than rotation matrices and they are more efficient than both matrix and angle/axis representations.

Also:

  • It's extremely easy to interpolate between two quaternions, which is useful for smooth camera movements etc.
  • Unit normalisation of floating point quaternions suffers from fewer rounding defects than matrix representations.
掩于岁月 2024-08-20 23:30:35

与欧拉角相比,四元数具有许多优点,并且通常更适合 3D 旋转:

  • 四元数(或:方向)之间的插值更容易(且定义明确):生成的运动具有绕单个轴的恒定角速度,这通常在美观上更令人愉悦。这个过程称为“slerp”,对于动画/旋转混合至关重要。此外,四元数插值不会受到万向节锁的影响。
  • 它们很容易重新规范化。

缺点:

  • 主要缺点是它们需要更多的数学知识,并且不如欧拉/卡丹尼克角直观。
  • 与仿射变换矩阵相比,四元数仅包含旋转,没有平移和缩放。

Quaternions have many advantages over Euler angles and are often preferable for 3D rotations:

  • Easier (and well-defined) interpolation between quaternions (or: orientations): the resulting movement has constant angular velocity around a single axis, which is often aesthetically more pleasing. This process is called "slerp" and critical for animation/rotation blending. Furthermore, quaternion interpolation does not suffer from Gimbal locks.
  • They are easy to renormalize.

Disadvantages:

  • The main disadvantage is that they require a bit more math and are less intuitive than Euler/Cardanic angles.
  • Compared to affine transformation matrices, Quaternions only contain a rotation, and no translation and scaling.
夏有森光若流苏 2024-08-20 23:30:35

使用四元数还可以解决万向节锁的问题。当您想要执行任意旋转时,它们更容易使用。

With quaternions you also handle the problem of the gimbal lock. And they are easier to work with when you want to perform arbitrary rotations.

孤独陪着我 2024-08-20 23:30:35

四元数的优点

  1. 快速乘法
  2. 快速到/从矩阵转换
  3. 避免额外的(来自计算的)噪声(缩放、剪切),并表示纯旋转
  4. 简单的旋转插值,在实时动画的自定义情况下可以使用线性插值。
  5. 一些棘手的操作可用,快速旋转积分,扭转摆动

分解

  1. 向量变换不像 3x3 矩阵那么快。
  2. 包含 4 个标量,但紧凑旋转表示只能使用 3 个。

Pros of quaternions

  1. Fast multiplication
  2. Fast to/from matrix conversion
  3. Avoid additional (from computation) noise (scale , shear) , and represent pure rotation
  4. Simple rotation interpolation, in custom case for real time animation can be used linear interpolation.
  5. Some tricky operations available, fast rotation integration, twist swing decompositions

Cons.

  1. Transformation of vector is not so fast as with 3x3 matrix.
  2. Contains 4 scalar, but compact rotation representation can use only 3.
闻呓 2024-08-20 23:30:35

四元数相对于矩阵的优点不仅在于计算速度更快,而且主要是因为围绕任意角度连续旋转的矩阵表示最终会产生可怕的浮点舍入误差,并且不再表示正确的仿射旋转。 “恢复”旋转矩阵在计算上比归一化四元数更昂贵。因此,应选择四元数而不是纯旋转矩阵。

The advantage of quaternions over matrices is not only faster computation, but mostly because a matrix representation of successive rotations around arbitrary angles eventually give in to dreadful floating-point round-off errors and no longer represent proper, affine rotations. "Restoring" a rotation matrix is computationally more expensive than normalizing a quaternion. Therefore, quaternions should be chosen over pure rotation matrices.

皓月长歌 2024-08-20 23:30:35

与欧拉角相比,它们的构成更简单,并且避免了万向节锁问题。

与旋转矩阵相比,它们在数值上更稳定,并且表示形式(4 个数字)更紧凑。

Compared to Euler angles they are simpler to compose and avoid the problem of gimbal lock.

Compared to rotation matrices they are more numerically stable and the representation (4 numbers) is more compact.

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