# quat2angle

Convert quaternion to rotation angles

## Description

example

[rotationAng1 rotationAng2 rotationAng3] = 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.

[rotationAng1 rotationAng2 rotationAng3] = quat2angle(q,s) calculates the set of rotation angles rotationAng1, rotationAng2, rotationAng3 for a given quaternion, q, and a specified rotation sequence, s.

Aerospace Toolbox uses 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 an m-by-4 matrix containing m quaternions. q has its scalar number as the first column.

Data Types: double

Rotation order for three rotation angles, where Z is in the z-axis, Y is in the y-axis, and X is in the x-axis.

Data Types: char | string

## Output Arguments

collapse all

First rotation angles, returned as an m-array, in radians.

Second rotation angles, returned as an m-array, in radians.

Third rotation angles, returned as an m-array, in radians.

## Limitations

• The 'ZYX', 'ZXY', 'YXZ', 'YZX', 'XYZ', and 'XZY' implementations generate a rotationAng2 angle that lies between ±90 degrees, and rotationAng1 and rotationAng3 angles that lie between ±180 degrees.

• The 'ZYZ', 'ZXZ', 'YXY', 'YZY', 'XYX', and 'XZX' implementations generate a rotationAng2 angle that lies between 0 and 180 degrees, and rotationAng1 and rotationAng3 angles that lie between ±180 degrees.

## Version History

Introduced in R2007b