quat2euler

Convert unit quaternion(s) to Euler angles.

Syntax
Angles = quat2euler(q0,q1,q2,q3)
Angles = quat2euler(q)
[alpha, beta, gamma] = quat2euler(...)
Description

Computes the set(s) of Euler angles corresponding to the input unit quaternion(s). The unit quaternion(s), which must be normalized to one, can be given as a 4xN array or using the individual components q0, q1, q2, q3 (each of size 1xN). The corresponding Euler angles (in radians) are returned as an array Angles = [alpha; beta; gamma] (size 3xN) or the individual angles alpha, beta, gamma (each of size 1xN).

Note that quat2euler is vectorized and will accept arrays of unit quaternions of size 4xNxMx... with an arbitrary number of dimensions, in which case the Euler angles will be returned as an array of size 3xNxMx....

For details about Euler angles, see the page on relative orientations.

Examples

Taking four arbitrary quaternion components and normalizing the result, we compute the Euler angles

q = [0.1; 0.438; -0.879; 0.699];
q = q./sqrt(sum(q.^2))
q =
    0.0827
    0.3621
   -0.7267
    0.5779
Angles = quat2euler(q)
Angles =
   -0.9664
    1.8949
   -1.8910

Now, feeding these Euler angles into euler2quat, we get back the four original quaternion components.

euler2quat(Angles)
ans =
    0.0827
    0.3621
   -0.7267
    0.5779
See also

quat2euler, rotmat2quat, quat2rotmat