四元数与非交换旋转
哈密顿寻找能描述三维旋转的数系,最终发现了四元数。四元数乘法不满足交换律:旋转顺序会影响结果。
i² = j² = k² = ijk = −1, so i j = k while j i = −k. Order changes the product.
| × | i | j | k |
| i | −1 | k | −j |
| j | −k | −1 | i |
| k | j | −i | −1 |
A rotation is encoded as a unit quaternion q = cos(θ/2) + sin(θ/2)(xi + yj + zk). Applying rotation qᵢ then qⱼ composes as qⱼ · qᵢ. Because quaternion multiplication is not commutative, swapping the order gives a different product and therefore a different orientation. That is why 3D engines must track rotation order and why quaternions avoid the gimbal-lock problems of Euler angles.
Both cubes receive two 90°-style rotations, but in opposite order. The left cube uses i then j, the right uses j then i. The tracked amber vertex ends in a different place whenever the angle is not a multiple of 180°, which is precisely the failure of commutativity i j ≠ j i.
你看到的是什么
四元数由一个实部和三个虚部组成:a + bi + cj + dk。
单位满足 i² = j² = k² = ijk = −1,因此 i j = k,而 j i = −k。
由于乘法不满足交换律,先旋转 i 再旋转 j,通常不等于先 j 后 i。
为什么重要
四元数用于三维图形、机器人和航天器姿态控制,因为它们能紧凑表示旋转并避免万向节锁。
复杂度与细节
两个四元数相乘为 O(1);把四元数旋转作用到向量上也是 O(1)。
常见问题
为什么不用普通数表示三维旋转?+
实数上不存在三维的结合可除代数。四元数使用四维,避免了复数的局限。
什么是万向节锁?+
欧拉角中两个旋转轴重合,导致失去一个自由度。四元数避免了这种表示问题。