Documentation Center

  • 評価版
  • 製品アップデート

quat2angle

Convert quaternion to rotation angles

Syntax

[r1 r2 r3] = quat2angle(q)
[r1 r2 r3] = quat2angle(q, s)

Description

[r1 r2 r3] = quat2angle(q) calculates the set of rotation angles, r1, r2, r3, for a given quaternion, q. q is an m-by-4 matrix containing m quaternions. Each element of q must be a real number. q has its scalar number as the first column.

Rotation angles are output in radians.

r1

Returns an m array of first rotation angles.

r2

Returns an m array of second rotation angles.

r3

Returns an m array of third rotation angles.

[r1 r2 r3] = quat2angle(q, s) calculates the set of rotation angles, r1, r2, r3, for a given quaternion, q, and a specified rotation sequence, s.

The default rotation sequence is 'ZYX', where r1 is z-axis rotation, r2 is y-axis rotation, and r3 is x-axis rotation.

Supported rotation sequence strings are 'ZYX', 'ZYZ', 'ZXY', 'ZXZ', 'YXZ', 'YXY', 'YZX', 'YZY', 'XYZ', 'XYX', 'XZY', and 'XZX'.

Examples

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

Assumptions and Limitations

The limitations for the 'ZYX', 'ZXY', 'YXZ', 'YZX', 'XYZ', and 'XZY' implementations generate an r2 angle that lies between ±90 degrees, and r1 and r3 angles that lie between ±180 degrees.

The limitations for the 'ZYZ', 'ZXZ', 'YXY', 'YZY', 'XYX', and 'XZX' implementations generate an r2 angle that lies between 0 and 180 degrees, and r1 and r3 angles that lie between ±180 degrees.

See Also

| | | |

Was this topic helpful?