Quaternions to Rotation Angles

Determine rotation vector from quaternion

Library

Utilities/Axes Transformations

Description

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 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:

DCM=[cosθcosψcosθsinψsinθ(sinϕsinθcosψcosϕsinψ)(sinϕsinθsinψ+cosϕcosψ)sinϕcosθ(cosϕsinθcosψ+sinϕsinψ)(cosϕsinθsinψsinϕcosψ)cosϕcosθ]

The DCM defined by a unit quaternion vector is:

DCM=[(q02+q12q22q32)2(q1q2+q0q3)2(q1q3q0q2)2(q1q2q0q3)(q02q12+q22q32)2(q2q3+q0q1)2(q1q3+q0q2)2(q2q3q0q1)(q02q12q22+q32)]

From the preceding equation, you can derive the following relationships between DCM elements and individual rotation angles for a ZYX rotation order:

ϕ=atan(DCM(2,3),DCM(3,3))=atan(2(q2q3+q0q1),(q02q12q22+q32))θ=asin(DCM(1,3))=asin(2(q1q3q0q2))ψ=atan(DCM(1,2),DCM(1,1))=atan(2(q1q2+q0q3),(q02+q12q22q32))

where Ψ is R1, Θ is R2, and Φ is R3.

Dialog Box

Rotation Order

Specifies the output rotation order for three rotation angles. From the list, select ZYX, ZYZ, ZXY, ZXZ, YXZ, YXY, YZX, YZY, XYZ, XYX, XZY, or XZX. The default is ZYX.

Inputs and Outputs

InputDimension TypeDescription

First

4-by-1 quaternion vectorContains the quaternion vector.

OutputDimension TypeDescription

First

3-by-3 vectorContains the rotation angles, in radians.

Assumptions and Limitations

The limitations for the 'ZYX', 'ZXY', 'YXZ', 'YZX', 'XYZ', and 'XZY' implementations generate an R2 angle that is between ±90 degrees, and R1 and R3 angles that are between ±180 degrees.

The limitations for the 'ZYZ', 'ZXZ', 'YXY', 'YZY', 'XYX', and 'XZX' implementations generate an R2 angle that is between 0 and 180 degrees, and R1 and R3 angles that are between ±180 degrees.

Was this topic helpful?