Aix-Marseille Université, CNRS, ISM, Marseille, France.
PLoS One. 2022 Nov 10;17(11):e0276302. doi: 10.1371/journal.pone.0276302. eCollection 2022.
Current methods of the conversion between a rotation quaternion and Euler angles are either a complicated set of multiple sequence-specific implementations, or a complicated method relying on multiple matrix multiplications. In this paper a general formula is presented for extracting the Euler angles in any desired sequence from a unit quaternion. This is a direct method, in that no intermediate conversion step is required (no quaternion-to-rotation matrix conversion, for example) and it is general because it works with all 12 possible sequences of rotations. A closed formula was first developed for extracting angles in any of the 12 possible sequences, both "Proper Euler angles" and "Tait-Bryan angles". The resulting algorithm was compared with a popular implementation of the matrix-to-Euler angle algorithm, which involves a quaternion-to-matrix conversion in the first computational step. Lastly, a single-page pseudo-code implementation of this algorithm is presented, illustrating its conciseness and straightforward implementation. With an execution speed 30 times faster than the classical method, our algorithm can be of great interest in every aspect.
目前将旋转四元数转换为欧拉角的方法要么是一组复杂的、特定于多个序列的实现,要么是一种依赖于多次矩阵乘法的复杂方法。本文提出了一种从单位四元数中提取任意期望序列的欧拉角的通用公式。这是一种直接的方法,因为不需要中间转换步骤(例如,不需要将四元数转换为旋转矩阵),而且它是通用的,因为它适用于所有 12 种可能的旋转序列。首先为提取 12 种可能序列中的角度(包括“规范欧拉角”和“Tait-Bryan 角”)开发了一个封闭公式。所得到的算法与一种流行的矩阵到欧拉角算法的实现进行了比较,该算法在第一个计算步骤中涉及四元数到矩阵的转换。最后,提出了此算法的单页伪代码实现,说明了其简洁性和直接实现。我们的算法执行速度比经典方法快 30 倍,在各个方面都具有很大的优势。