euler2quat

Convert Euler angles to unit quaternion(s).

Syntax
q = euler2quat(Angles)
q = euler2quat(alpha,beta,gamma)
Description

Computes the unit quaternion(s) corresponding to the input set(s) of Euler angles. The Euler angles (in radians) can be given as an array Angles = [alpha; beta; gamma] (size 3xN) or the separate input arguments alpha, beta, gamma (each of size 1xN). The corresponding unit quaternion(s) are returned as a 4-element vector q = [q0; q1; q2; q3] or a 4xN array.

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

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

Examples

Taking three arbitrary angles, we compute the unit quaternion

ang = [34; 72; -143]*pi/180;
q = euler2quat(ang)
q =
    0.4698
    0.5876
   -0.0154
    0.6586

Now, feeding this quaternion into quat2euler, we get back the three original angles.

quat2euler(q)*180/pi
ans =
   34
   72
 -143
See also

quat2euler, rotmat2quat, quat2rotmat