什么是四元数旋转?

发布于 2024-09-29 06:41:19 字数 171 浏览 0 评论 0原文

四元数旋转只是一个带有 X、Y、Z 的向量(物体将朝着该方向旋转),以及使物体绕其轴旋转的滚动吗?

真有这么简单吗?

这意味着如果 X=0、Z=0 且 Y=1,则对象将面朝上?
如果 Y=0、Z=0 和 X=1,物体会面向右侧吗?

(假设 X 向右,Y 向上,Z 深度)

Is quaternion rotation just a vector with X,Y,Z which the object will rotate towards, and a roll which turns the object on its axis?

Is it that simple?

Meaning if you have X=0, Z=0 and Y=1 the object will face upwards?
And if you have Y=0, Z=0 and X=1 the object will face to the right?

(assuming X right, Y up and Z depth)

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

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

发布评论

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

评论(2

甜是你 2024-10-06 06:41:19

四元数有 4 个分量,它们可以与角度 θ 和轴向量 n 相关。旋转将使物体绕轴n旋转角度θ。

例如,如果我们有一个像这样的立方体

 ______
|\  6  \
| \_____\     z
|5 |    | : y ^
 \ | 4  |    \|
  \|____|     +--> x

,那么绕轴 (x=0, y=0, z=1) 旋转 90° 会将“5”面从左侧旋转到前面。

 ______
|\  6  \
| \_____\      z
|3 |    | :  x ^
 \ | 5  |     \|
  \|____|  y<--+

(注:这是旋转的轴/角度描述,这就是OP混淆的地方。四元数如何应用于旋转,请参见http://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation

A quaternion has 4 components, which can be related to an angle θ and an axis vector n. The rotation will make the object rotate about the axis n by an angle θ.

For example, if we have an cube like

 ______
|\  6  \
| \_____\     z
|5 |    | : y ^
 \ | 4  |    \|
  \|____|     +--> x

Then a rotation of 90° about the axis (x=0, y=0, z=1) will rotate the "5" face from the left to the front.

 ______
|\  6  \
| \_____\      z
|3 |    | :  x ^
 \ | 5  |     \|
  \|____|  y<--+

(Note: This is the axis/angle description of rotation, which is what OP confuses. For how quaternion is applied to rotation, see http://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation)

娇纵 2024-10-06 06:41:19

一般来说,四元数是将复数​​扩展到 4 个维度。所以不,它们不仅仅是 x、y、z 和一个角度,而且它们很接近。更多内容如下...

四元数可用于表示旋转,因此它们对于图形很有用:

单位四元数提供了方便的
表示的数学符号
物体的方向和旋转
在三个维度上。与欧拉相比
它们的角度更容易组合并且
避免万向节锁问题。
与旋转矩阵相比,它们是
数值更稳定并且可能
效率更高。

那么这 4 个组件是什么以及它们与旋转有何关系?

[单位四元数]点(w,x,y,z)代表一个
绕由 指示的轴旋转
向量 (x,y,z) 的角度 alpha
= 2 cos-1 w = 2 sin-1 sqrt(x2+y2+z2)。

那么回到你的问题,

这意味着如果 X=0、Z=0 且 Y=1
物体会面朝上吗?

不...对象将围绕此 <0,1,0> 向量旋转,即它将围绕 y 轴旋转,从上面看逆时针旋转,如果您的图形系统使用右-手旋转。 (如果我们代入 w = sqrt(1 - (0 + 1 + 0)),你的单位四元数是 (0,0,1,0),它将旋转角度 2 cos-10, = 2 * 90 度 = 180 度或 pi 弧度。)

如果 Y=0、Z=0 和 X=1,物体将面向右侧?

这将围绕向量<1,0,0>(x 轴)旋转,因此从正 x 方向(例如向右)看,它将逆时针旋转。因此顶部会向前转动(180 度,因此它会旋转直到面朝下)。

A quaternion in general is an extension of a complex number into 4 dimensions. So no, they are not just x, y, and z, and an angle, but they're close. More below...

Quaternions can be used to represent rotation, so they're useful for graphics:

Unit quaternions provide a convenient
mathematical notation for representing
orientations and rotations of objects
in three dimensions. 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 may be
more efficient.

So what are the 4 components and how do they relate to the rotation?

The [unit quaternion] point (w,x,y,z) represents a
rotation around the axis directed by
the vector (x,y,z) by an angle alpha
= 2 cos-1 w = 2 sin-1 sqrt(x2+y2+z2).

So back to your question,

Meaning if you have X=0, Z=0 and Y=1
the object will face upwards?

No... the object will rotate around this <0,1,0> vector, i.e. it will rotate around the y axis, turning counterclockwise as seen from above, if your graphics system uses right-hand rotation. (And if we plug in w = sqrt(1 - (0 + 1 + 0)), your unit quaternion is (0,0,1,0), and it will rotate by angle 2 cos-10, = 2 * 90 degrees = 180 degrees or pi radians.)

And if you have Y=0, Z=0 and X=1 the object will face to the right?

This will rotate around the vector <1,0,0>, the x axis, so it will rotate counterclockwise as seen from the positive x direction (e.g. right). So the top would turn forward (180 degrees, so it would rotate until it faced downward).

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