In 3D graphics, the most common rotation representation method is the four-element and the Euclidean angle, which saves storage space and facilitates interpolation compared with the matrix. This article mainly summarizes the conversion of two expressions. The calculation formula uses the 3D Cartesian coordinate system:
Figure 1 3D Cartesian coordinate system (from Wikipedia)
It is defined as the rotation angle around the Z axis, Y axis, and X axis respectively. If Tait-Bryan angle is used, the rotation angles are yaw, pitch, and roll.
Figure 2 Tait-Bryan angles (from Wikipedia)
I. Definition of the Quaternary Element
By rotating the axis of rotation and the angle around the axis, You can construct a four-element system:
The rotation angle around the rotating axis is the component of the rotating axis in the direction of X, Y, and Z (the rotating axis is determined ).
Ii. Conversion from orah to Quaternary
Iii. Conversion from a quaternary element to an ouarla corner
ArctanAndArcsinThe result is that this does not cover all orientations (the value range for the angle has been satisfied), so you need to useAtan2To replaceArctan.
4. Use in other Coordinate Systems
In other coordinate systems, adjust the above formula according to the definition of the coordinate axis. For example, in direct3d, the X axis of the Cartesian coordinate system is changed to the Z axis, the Y axis is changed to the X axis, and the Z axis is changed to the Y axis (you do not need to consider the direction ).