Convert Euler angles to unit quaternion(s).
q = euler2quat(Angles) q = euler2quat(alpha,beta,gamma)
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.
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
quat2euler, rotmat2quat, quat2rotmat