Main Content

quat2angle

Convert quaternion to rotation angles

Description

example

[rotationAng1rotationAng2rotationAng3] = quat2angle(q)calculates the set of rotation angles,rotationAng1,rotationAng2,rotationAng3, for a given quaternion,q. The rotation used in this function is a passive transformation between two coordinate systems.

[rotationAng1rotationAng2rotationAng3] = quat2angle(q,s)calculates the set of rotation anglesrotationAng1,rotationAng2,rotationAng3for a given quaternion,q, and a specified rotation sequence,s.

Aerospace Toolboxuses quaternions that are defined using the scalar-first convention. This function normalizes all quaternion inputs.

Examples

collapse all

Determine the rotation angles from q = [1 0 1 0].

[yaw, pitch, roll] = quat2angle([1 0 1 0])
yaw = 0 pitch = 1.5708 roll = 0

Determine the rotation angles from multiple quaternions.

q = [1 0 1 0; 1 0.5 0.3 0.1]; [pitch, roll, yaw] = quat2angle(q,'YXZ')
pitch = 1.5708 0.8073 roll = 0 0.7702 yaw = 0 0.5422

Input Arguments

collapse all

Quaternion, specified as anm-by-4 matrix containingmquaternions.qhas its scalar number as the first column.

Data Types:double

Rotation order for three rotation angles, whereZis in thez-axis,Yis in they-axis, andXis in thex-axis.

Data Types:char|string

Output Arguments

collapse all

First rotation angles, returned as anm-array, in radians.

Second rotation angles, returned as anm-array, in radians.

Third rotation angles, returned as anm-array, in radians.

Limitations

  • The'ZYX','ZXY','YXZ','YZX','XYZ', and'XZY'implementations generate arotationAng2angle that lies between ±90 degrees, androtationAng1androtationAng3angles that lie between ±180 degrees.

  • The'ZYZ','ZXZ','YXY','YZY','XYX', and'XZX'implementations generate arotationAng2angle that lies between 0 and 180 degrees, androtationAng1androtationAng3angles that lie between ±180 degrees.

Version History

Introduced in R2007b