OpenCV
5.0.0pre
Open Source Computer Vision

#include <opencv2/core/quaternion.hpp>
Public Types  
enum  EulerAnglesType { INT_XYZ, INT_XZY, INT_YXZ, INT_YZX, INT_ZXY, INT_ZYX, INT_XYX, INT_XZX, INT_YXY, INT_YZY, INT_ZXZ, INT_ZYZ, EXT_XYZ, EXT_XZY, EXT_YXZ, EXT_YZX, EXT_ZXY, EXT_ZYX, EXT_XYX, EXT_XZX, EXT_YXY, EXT_YZY, EXT_ZXZ, EXT_ZYZ } 
Enum of Euler angles type. More...  
Enum of Euler angles type.
Without considering the possibility of using two different convertions for the definition of the rotation axes , there exists twelve possible sequences of rotation axes, divided into two groups:
The three elemental rotations may be extrinsic (rotations about the axes xyz of the original coordinate system, which is assumed to remain motionless), or intrinsic(rotations about the axes of the rotating coordinate system XYZ, solidary with the moving body, which changes its orientation after each elemental rotation).
Extrinsic and intrinsic rotations are relevant.
The definition of the Euler angles is as following,
For intrinsic rotations in the order of XYZ, the rotation matrix R can be calculated by:
\[R =X(\theta_1) Y(\theta_2) Z(\theta_3) \]
For extrinsic rotations in the order of XYZ, the rotation matrix R can be calculated by:
\[R =Z({\theta_3}) Y({\theta_2}) X({\theta_1})\]
where
\[X({\theta})={\begin{bmatrix}1&0&0\\0&\cos {\theta_1} &\sin {\theta_1} \\0&\sin {\theta_1} &\cos {\theta_1} \\\end{bmatrix}}, Y({\theta})={\begin{bmatrix}\cos \theta_{2}&0&\sin \theta_{2}\\0&1 &0 \\\ sin \theta_2& 0&\cos \theta_{2} \\\end{bmatrix}}, Z({\theta})={\begin{bmatrix}\cos\theta_{3} &\sin \theta_3&0\\\sin \theta_3 &\cos \theta_3 &0\\0&0&1\\\end{bmatrix}}. \]
The function is designed according to this set of conventions:
For \(\theta_1\) and \(\theta_3\), the valid range is (−π, π].
For \(\theta_2\), the valid range is [−π/2, π/2] or [0, π].
For Tait–Bryan angles, the valid range of \(\theta_2\) is [−π/2, π/2]. When transforming a quaternion to Euler angles, the solution of Euler angles is unique in condition of \( \theta_2 \in (−π/2, π/2)\) . If \(\theta_2 = −π/2 \) or \( \theta_2 = π/2\), there are infinite solutions. The common name for this situation is gimbal lock. For Proper Euler angles,the valid range of \(\theta_2\) is in [0, π]. The solutions of Euler angles are unique in condition of \( \theta_2 \in (0, π)\) . If \(\theta_2 =0 \) or \(\theta_2 =π \), there are infinite solutions and gimbal lock will occur.