angle2quat - Convert rotation angles to quaternion

Syntax

q = angle2quat(r1,r2,r3)
q = angle2quat(r1,r2,r3,s)

Description

q = angle2quat(r1,r2,r3) calculates the quaternion, q, for the three rotation angles, r1, r2, r3. q returns an m-by-4 matrix containing m quaternions. q has its scalar number as the first column. Rotation angles are input in radians.

r1

m array of first rotation angles.

r2

m array of second rotation angles.

r3

m array of third rotation angles.

q = angle2quat(r1,r2,r3,s) calculates the quaternion, q, for a given set of rotation angles, r1, r2, r3, 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, s, are 'ZYX', 'ZYZ', 'ZXY', 'ZXZ', 'YXZ', 'YXY', 'YZX', 'YZY', 'XYZ', 'XYX', 'XZY', and 'XZX'.

Examples

Determine the quaternion from rotation angles:

yaw = 0.7854; 
pitch = 0.1; 
roll = 0;
q = angle2quat(yaw, pitch, roll)
q =
    0.9227   -0.0191    0.0462    0.3822

Determine the quaternion from multiple rotation angles:

yaw = [0.7854 0.5]; 
pitch = [0.1 0.3]; 
roll = [0 0.1];
q = angle2quat(pitch, roll, yaw, 'YXZ')
q =
    0.9227    0.0191    0.0462    0.3822
    0.9587    0.0848    0.1324    0.2371

See Also

angle2dcm, dcm2angle, dcm2quat, quat2angle, quat2dcm

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS