# 四元数运动学

**四元数运动学**是使用单位四元数——带有单位长度约束的四参数数——来表示和计算三维空间中刚体姿态的方法，涵盖旋转复合、角速度积分、姿态插值以及姿态误差计算，应用于机器人学、航空航天和计算机图形学。单位四元数能给出光滑、全局非奇异的姿态表示，这正是它在控制和轨迹生成流程中取代欧拉角的主要原因。<sup>[1](https://mohammadijoo.github.io/CaaT_Academy/Lectures/Robotics_Kinematics_and_Dynamics_Course/Chapter03/Lesson3.html)</sup>

| 关键事实 | 详情 |
|---|---|
| 参数数量 | 四个分量加一个单位范数约束，描述三个旋转自由度；与欧拉角不同，不存在奇异性<sup>[1](https://mohammadijoo.github.io/CaaT_Academy/Lectures/Robotics_Kinematics_and_Dynamics_Course/Chapter03/Lesson3.html)</sup><sup> • </sup><sup>[2](https://simeon-ned.github.io/robotic_systems/notes/04-quaternions/)</sup> |
| 轴角形式 | 绕单位轴 \( \mathbf{n} \) 旋转角度 \( \theta \) 时，\( Q = (\cos(\theta/2),\ \mathbf{n}\sin(\theta/2)) \)<sup>[2](https://simeon-ned.github.io/robotic_systems/notes/04-quaternions/)</sup> |
| 双重覆盖 | \( Q \) 与 \( -Q \) 表示同一旋转；从单位三维球面 \( S^3 \) 到 \( SO(3) \) 的映射是二对一的<sup>[2](https://simeon-ned.github.io/robotic_systems/notes/04-quaternions/)</sup><sup> • </sup><sup>[3](https://raw.org/book/geometry/rotations/)</sup> |
| 复合代价 | 两次连续旋转：用四元数需16次乘法和12次加减法，而用旋转矩阵需27次乘法和18次加减法<sup>[4](https://mecademic.com/insights/academic-tutorials/quaternions-in-industrial-robotics/)</sup> |
| 运动学方程 | \( \dot{q} = \tfrac{1}{2}\,\Omega(\omega)\,q \)，即把四元数变化率与角速度联系起来的基本姿态微分方程<sup>[5](https://ntrs.nasa.gov/api/citations/20130014073/downloads/20130014073.pdf?attachment=true)</sup> |
| 插值 | 球面线性插值（SLERP），由肯·舒梅克（Ken Shoemake）于1985年引入图形学，沿 \( S^3 \) 上最短测地线以恒定角速度移动<sup>[6](https://doi.org/10.1145%2F325334.325242)</sup><sup> • </sup><sup>[1](https://mohammadijoo.github.io/CaaT_Academy/Lectures/Robotics_Kinematics_and_Dynamics_Course/Chapter03/Lesson3.html)</sup> |
| 工业应用 | 大多数工业机器人在沿直线路径调整末端执行器姿态时使用SLERP<sup>[4](https://mecademic.com/insights/academic-tutorials/quaternions-in-industrial-robotics/)</sup> |

## 四元数代数

四元数是一个四元组，包含一个标量部分和一个三维向量部分，写作 \( q = (q_0, \mathbf{q}_v) \)，或用原始代数形式写作 \( q = q_1 + q_2 i + q_3 j + q_4 k \)，其中虚数单位满足 \( i^2 = j^2 = k^2 = -1 \) 以及 \( ij = k = -ji \)，其他数对之间也有类似关系。<sup>[1](https://mohammadijoo.github.io/CaaT_Academy/Lectures/Robotics_Kinematics_and_Dynamics_Course/Chapter03/Lesson3.html)</sup><sup> • </sup><sup>[4](https://mecademic.com/insights/academic-tutorials/quaternions-in-industrial-robotics/)</sup> 四元数由爱尔兰数学家哈密顿（W. R. Hamilton）于1843年作为复数的推广而发明。<sup>[4](https://mecademic.com/insights/academic-tutorials/quaternions-in-industrial-robotics/)</sup>

**乘法不满足交换律。** 两个四元数的Hamilton积，设其标量部分分别为 \( w_1, w_2 \)，向量部分分别为 \( \mathbf{r}_1, \mathbf{r}_2 \)，为

\[ Q_1 \otimes Q_2 = \left( w_1 w_2 - \mathbf{r}_1^\top \mathbf{r}_2,\; w_1 \mathbf{r}_2 + w_2 \mathbf{r}_1 + \mathbf{r}_1 \times \mathbf{r}_2 \right), \]

因此一般而言 \( qp \neq pq \)。<sup>[2](https://simeon-ned.github.io/robotic_systems/notes/04-quaternions/)</sup><sup> • </sup><sup>[4](https://mecademic.com/insights/academic-tutorials/quaternions-in-industrial-robotics/)</sup> 这正对应三维旋转本身的非交换性：先绕z轴旋转90度再绕x轴旋转90度，与按相反顺序进行同样的旋转，得到的姿态不同。<sup>[7](https://link.springer.com/chapter/10.1007/978-3-319-62533-1_16)</sup> 相比之下，加法是可交换的，且按分量进行。<sup>[4](https://mecademic.com/insights/academic-tutorials/quaternions-in-industrial-robotics/)</sup>

单位四元数的逆是它的共轭，通过取向量部分的相反数得到：绕有向轴 \( \mathbf{u} \) 旋转 \( \theta \) 的逆是绕同一轴旋转 \( -\theta \)，且 \( q^{-1} q = q q^{-1} = (1, 0, 0, 0) \)，即单位元。<sup>[4](https://mecademic.com/insights/academic-tutorials/quaternions-in-industrial-robotics/)</sup>

## 四元数作为旋转

与旋转的联系建立在欧拉（Euler）定理之上，该定理于1775年得到证明：刚体的任何重新定向都等价于绕某一轴的单次旋转，因此姿态可以用沿该轴的单位向量 \( \mathbf{u} \) 和角度 \( \theta \) 表示，正旋转方向由右手定则给出。<sup>[4](https://mecademic.com/insights/academic-tutorials/quaternions-in-industrial-robotics/)</sup> 对应的单位四元数为

\[ q = \left( \cos\frac{\theta}{2},\; u_x \sin\frac{\theta}{2},\; u_y \sin\frac{\theta}{2},\; u_z \sin\frac{\theta}{2} \right). \]

向量的旋转通过将其嵌入为纯四元数 \( v = (0, v_x, v_y, v_z) \) 并计算三重积 \( q v q^{-1} \) 来实现。<sup>[4](https://mecademic.com/insights/academic-tutorials/quaternions-in-industrial-robotics/)</sup><sup> • </sup><sup>[7](https://link.springer.com/chapter/10.1007/978-3-319-62533-1_16)</sup>

**双重覆盖。** 由于同一姿态既可以描述为绕 \( \mathbf{u} \) 旋转 \( \theta \)，也可以描述为绕 \( -\mathbf{u} \) 旋转 \( 360^\circ - \theta \)，将四元数的每个分量取反得到的是同一姿态的四元数：处处有 \( R_q(q) = R_q(-q) \)。<sup>[4](https://mecademic.com/insights/academic-tutorials/quaternions-in-industrial-robotics/)</sup><sup> • </sup><sup>[8](https://motion.cs.illinois.edu/RoboticSystems/3DRotations.html)</sup> 因此映射 \( S^3 \to SO(3) \) 是二对一的，即双重覆盖。<sup>[3](https://raw.org/book/geometry/rotations/)</sup> 这有实际后果。通过比较四元数分量来比较姿态是错误的，因为 \( \hat{q} \) 与 \( -\hat{q} \) 作为旋转是相等的；正确的比较使用 \( |\hat{q}_1 \cdot \hat{q}_2| \)。<sup>[3](https://raw.org/book/geometry/rotations/)</sup> 在插值之前，实现中会翻转其中一个四元数，使点积 \( q_0^\top q_1 \ge 0 \)，确保沿 \( S^3 \) 走最短弧而非绕超球面的长路径。<sup>[1](https://mohammadijoo.github.io/CaaT_Academy/Lectures/Robotics_Kinematics_and_Dynamics_Course/Chapter03/Lesson3.html)</sup>

## 为什么用四元数而不是欧拉角或矩阵

[欧拉角](https://www.edgepedia.org/zh/euler-angles)将姿态存储为绕坐标轴的三次连续旋转。它们紧凑且为人熟悉，但不连续、难以直接复合，并且受万向节锁影响：当两个轴对齐时表示欠定，而且欧拉角表示在第一次和最后一次旋转绕同一轴发生时总是表现出奇异性。<sup>[9](https://journals.plos.org/plosone/article?id=10.1371%2Fjournal.pone.0276302)</sup><sup> • </sup><sup>[10](https://www.sambuz.com/doc/handbook-of-robotics-chapter-1-kinematics-pdf-document-681499)</sup> 旋转矩阵全局良定义但冗余，有九个参数加正交归一约束，且会数值漂移，需要重新正交化。<sup>[1](https://mohammadijoo.github.io/CaaT_Academy/Lectures/Robotics_Kinematics_and_Dynamics_Course/Chapter03/Lesson3.html)</sup><sup> • </sup><sup>[11](https://github.com/SiliconWit/robotics/blob/main/orientation-quaternions.mdx)</sup>

单位四元数介于这两个极端之间：四个数、一步廉价归一化、无奇异性、易于通过乘法复合、易于插值。<sup>[1](https://mohammadijoo.github.io/CaaT_Academy/Lectures/Robotics_Kinematics_and_Dynamics_Course/Chapter03/Lesson3.html)</sup><sup> • </sup><sup>[12](https://opencourse.inf.ed.ac.uk/sites/default/files/https/opencourse.inf.ed.ac.uk/aro/2024/2-aro-so3_0.pdf)</sup> [归一化](https://www.edgepedia.org/zh/normalization)计算代价低，常见做法是在高频循环中每个控制周期重新归一化，或每当 \( |\|q\|^2 - 1| > 0.01 \) 时重新归一化，因为不归一化的重复乘法会让单位四元数漂移几个百分点。<sup>[11](https://github.com/SiliconWit/robotics/blob/main/orientation-quaternions.mdx)</sup> 一条常见的工程准则是：内部以四元数存储姿态，仅在接口边界处转换为其他表示。<sup>[11](https://github.com/SiliconWit/robotics/blob/main/orientation-quaternions.mdx)</sup>

## 运动学微分方程

姿态的时间演化来自小旋转的复合。若角速度 \( \omega \) 在区间 \( \Delta t \) 上恒定，则旋转角度为 \( \Delta\theta = |\omega| \Delta t \)，四元数更新为 \( q(t + \Delta t) = q(\Delta t) \otimes q(t) \)。取小角度极限得到基本姿态微分方程

\[ \frac{d}{dt} q(t) = \frac{1}{2}\, \Omega(\omega(t))\, q(t), \]

其中 \( \Omega(\omega) \) 是由 \( \omega \) 的分量构成的4×4矩阵。<sup>[5](https://ntrs.nasa.gov/api/citations/20130014073/downloads/20130014073.pdf?attachment=true)</sup> 用李群形式表示，对于本体角速度 \( \omega^B \)，\( \dot{Q} = \tfrac{1}{2} Q \otimes (0, \omega^B) \)，一步内恒定的本体角速度给出 \( Q_{k+1} = Q_k \otimes \operatorname{Exp}_Q(\Delta t\, \omega^B) \)，其中 \( \operatorname{Exp}_Q(\phi) = (\cos(\|\phi\|/2),\ \phi \sin(\|\phi\|/2)/\|\phi\|) \)；世界坐标系角速度则在另一侧相乘。<sup>[2](https://simeon-ned.github.io/robotic_systems/notes/04-quaternions/)</sup> 反过来，角速度可以从四元数及其时间导数恢复，这是SPICE函数qdq2av_c等例程的基础，该函数返回 \( -2 q^* \dot{q} \) 的向量部分作为角速度。<sup>[13](https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/qdq2av_c.html)</sup>

一个相关的微妙之处出现在微分运动学中：姿态参数化（包括四元数分量）的时间导数一般不是角速度向量 \( \omega \)，因此基于雅可比的控制使用角速度本身而非原始四元数变化率。<sup>[14](https://robotmechanics.softmachineslab.org/lecture/chapter5.html)</sup>

## 插值：SLERP及其扩展

给定两个单位四元数 \( q_0 \) 和 \( q_1 \)，它们在 \( S^3 \) 上的测地线位于二者张成的大圆上，二者之间的夹角为 \( \theta = \arccos(q_0^\top q_1) \)。<sup>[1](https://mohammadijoo.github.io/CaaT_Academy/Lectures/Robotics_Kinematics_and_Dynamics_Course/Chapter03/Lesson3.html)</sup> 球面线性插值沿此弧移动：

\[ q(t) = \frac{\sin\big((1-t)\theta\big)}{\sin\theta}\, q_0 + \frac{\sin(t\theta)}{\sin\theta}\, q_1, \]

当 \( \theta \) 非常小时回退到归一化线性插值。<sup>[1](https://mohammadijoo.github.io/CaaT_Academy/Lectures/Robotics_Kinematics_and_Dynamics_Course/Chapter03/Lesson3.html)</sup> 结果是沿最短路径的恒定角速度，这正是SLERP被优先用于平滑机器人运动的原因；逐分量欧拉插值则行程更远且在中间加速。<sup>[11](https://github.com/SiliconWit/robotics/blob/main/orientation-quaternions.mdx)</sup><sup> • </sup><sup>[15](https://robotics.biblio.guru/course/foundations/quaternions/)</sup>

肯·舒梅克（Ken Shoemake）1985年的SIGGRAPH论文《Animating Rotation with Quaternion Curves》将SLERP引入计算机图形学，他还提出了球面上的球面样条曲线，用于对任意旋转序列进行平滑的中间过渡。<sup>[6](https://doi.org/10.1145%2F325334.325242)</sup>

**SLERP在实践中的出现。** 大多数工业机器人在沿直线路径调整末端执行器姿态时使用SLERP；如果起始和终止姿态相差180度，则存在两条相同的最小力矩路径，控制器的任意选择意味着用户无法预知运动，因此工业机器人对沿直线路径的位移施加限制。<sup>[4](https://mecademic.com/insights/academic-tutorials/quaternions-in-industrial-robotics/)</sup> MoveIt Pilz工业运动规划器对其LIN和CIRC笛卡尔指令的旋转运动使用四元数SLERP，并与平移运动在时间上同步。<sup>[16](https://github.com/moveit/moveit_tutorials/blob/master/doc/pilz_industrial_motion_planner/pilz_industrial_motion_planner.rst)</sup> MathWorks Robotics System Toolbox的轨迹模块同样沿最短路径用SLERP计算姿态轨迹。<sup>[17](https://ch.mathworks.com/help/robotics/ref/rotationtrajectory.html)</sup>

## 姿态误差与控制

基亚韦里尼（Chiaverini）和西西利亚诺（Siciliano）于1999年提出了一种闭环逆运动学算法，采用单位四元数代替欧拉角，正是为了避免表示奇异性，并在工业机械臂上实现。<sup>[18](https://www.iris.unina.it/handle/11588/486043)</sup> 基于四元数的滑模控制器和滑动变量控制器利用四元数超球面的几何性质获得全局指数收敛，同时避免双重覆盖引起的展开问题。<sup>[19](https://arxiv.org/abs/2403.10934)</sup><sup> • </sup><sup>[20](https://arxiv.org/abs/2412.18921)</sup>

**超越单一姿态。** 对偶四元数是由两个四元数构成的八参数数，将同样的代数扩展到完整刚体位姿，同时表示位置和姿态；它们被用于机器人研究中的运动学建模、设定点位姿控制和SLERP到SCLERP的运动插值。<sup>[21](https://www.mdpi.com/2075-1702/12/6/402)</sup><sup> • </sup><sup>[22](https://www.sciencedirect.com/science/article/pii/S0736584516301831)</sup>

## References

1. [Unit Quaternions and Interpolation, Robotics Kinematics and Dynamics Course, CaaT Academy](https://mohammadijoo.github.io/CaaT_Academy/Lectures/Robotics_Kinematics_and_Dynamics_Course/Chapter03/Lesson3.html)
2. [Scalar-first quaternions and attitude integration, Robotic Systems notes](https://simeon-ned.github.io/robotic_systems/notes/04-quaternions/)
3. [Introduction to Rotations with Complex Numbers and Quaternions, raw.org](https://raw.org/book/geometry/rotations/)
4. [How to Use Quaternions in Industrial Robotics, Mecademic](https://mecademic.com/insights/academic-tutorials/quaternions-in-industrial-robotics/)
5. [NASA/TM-2013-208641, Spacecraft attitude kinematics](https://ntrs.nasa.gov/api/citations/20130014073/downloads/20130014073.pdf?attachment=true)
6. [Ken Shoemake (1985). Animating Rotation with Quaternion Curves. ACM SIGGRAPH Computer Graphics 19(3).](https://doi.org/10.1145%2F325334.325242)
7. [Ben-Ari, M., Mondada, F. Kinematics of a Robotic Manipulator, Springer](https://link.springer.com/chapter/10.1007/978-3-319-62533-1_16)
8. [Robotic Systems, 3D Rotations, Kris Hauser, University of Illinois](https://motion.cs.illinois.edu/RoboticSystems/3DRotations.html)
9. [Quaternion to Euler angles conversion: A direct, general and computationally efficient method, PLOS One](https://journals.plos.org/plosone/article?id=10.1371%2Fjournal.pone.0276302)
10. [Handbook of Robotics, Chapter 1: Kinematics](https://www.sambuz.com/doc/handbook-of-robotics-chapter-1-kinematics-pdf-document-681499)
11. [Orientation Quaternions, SiliconWit robotics notes](https://github.com/SiliconWit/robotics/blob/main/orientation-quaternions.mdx)
12. [Robotics: Science and Systems, SO(3) lecture, University of Edinburgh](https://opencourse.inf.ed.ac.uk/sites/default/files/https/opencourse.inf.ed.ac.uk/aro/2024/2-aro-so3_0.pdf)
13. [qdq2av_c, SPICE Toolkit documentation, NASA JPL](https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/qdq2av_c.html)
14. [Differential Kinematics and Statics, Robot Mechanics](https://robotmechanics.softmachineslab.org/lecture/chapter5.html)
15. [Quaternions: the four numbers robotics runs on, robotics.biblio.guru](https://robotics.biblio.guru/course/foundations/quaternions/)
16. [Pilz Industrial Motion Planner, MoveIt Tutorials](https://github.com/moveit/moveit_tutorials/blob/master/doc/pilz_industrial_motion_planner/pilz_industrial_motion_planner.rst)
17. [Rotation Trajectory, MathWorks Robotics System Toolbox](https://ch.mathworks.com/help/robotics/ref/rotationtrajectory.html)
18. [Chiaverini, S., Siciliano, B. (1999). Unit quaternion: a useful tool for inverse kinematics of robot manipulators. Systems Analysis, Modelling, Simulation 35(1).](https://www.iris.unina.it/handle/11588/486043)
19. [Quaternion-Based Sliding Mode Control for Six Degrees of Freedom Flight Control of Quadrotors, arXiv](https://arxiv.org/abs/2403.10934)
20. [Lopez, B.T., Slotine, J.-J. Quaternion Sliding Variables in Manipulator Control, arXiv](https://arxiv.org/abs/2412.18921)
21. [A Review on the Applications of Dual Quaternions, Machines (MDPI)](https://www.mdpi.com/2075-1702/12/6/402)
22. [Set-point control of robot end-effector pose using dual quaternion feedback, Mechanism and Machine Theory](https://www.sciencedirect.com/science/article/pii/S0736584516301831)

---
*Initially written Oct 15, 2026*

Topic: 技术与人造世界 › 工程与制造 › 机器人技术与自动化 › Mechanical foundations of robotics › Robot kinematics and differential kinematics

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/quaternion-kinematics

English original: https://www.edgepedia.org/quaternion-kinematics
