Quaternions to Rotation Angles
Determine rotation vector from quaternion
Aerospace Blockset / Utilities / Axes Transformations
The Quaternions to Rotation Angles block converts the four-element quaternion vector (q0, q1, q2, q3), into the rotation described by the three rotation angles (R1, R2, R3). The block generates the conversion by comparing elements in the direction cosine matrix (DCM) as a function of the rotation angles. The rotation used in this block is a passive transformation between two coordinate systems. The elements in the DCM are functions of a unit quaternion vector. Aerospace Blockset™ uses quaternions that are defined using the scalar-first convention. This block normalizes all quaternion inputs. For more information on the direction cosine matrix, see Algorithms.
XZYrotations, the block generates an R2 angle that lies between ±pi/2 radians, and R1 and R3 angles that lie between ±pi radians.
For the 'ZYZ', 'ZXZ', 'YXY', 'YZY', 'XYX', and 'XZX' rotations, the block generates an R2 angle that lies between 0 and pi radians, and R1 and R3 angles that lie between ±pi radians. However, in the latter case, when R2 is 0, R3 is set to 0 radians.
q — Quaternion
Quaternion, specified as a 4-by-1 vector.
[R1,R2,R3] — Rotation angles
Rotation angles, returned 3-by-1 vector, in radians.
Rotation order — Rotation order
ZYX (default) |
Output rotation order for the three rotation angles.
|Type: character vector|
The elements in the DCM are functions of a unit quaternion vector. For example, for
the rotation order
z-y-x, the DCM is defined as:
The DCM defined by a unit quaternion vector is:
From the preceding equation, you can derive the following relationships between DCM elements and individual rotation angles for a ZYX rotation order:
where Ψ is R1, Θ is R2, and Φ is R3.
C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.
Introduced in R2007b