Matlab routines for Rotations


Return to voicebox home page


Rotation Representations

Rotations can be represented in any of the eight forms listed below; each has a two-letter mnemonic given in the first column. The conversion routine from form xx to form yy is called rotxx2yy. The second column lists the parameters required: A,a,a,a denote matrix, vector, scalar and text arguments and the subscripts indicate their dimension. The ro and pl forms can be used in a n-dimensional space; the other forms are restricted to 3-dimensions. To visualize a rotation, call rotqr2ro(q) without any output argument.

Rotation conventions

In 3-dimensions, the x, y and z axes form a right-handed triple. A positive rotation of pi/2 radians around one of these axes will rotate y->z, z->x or x->y respectively, i.e. it corresponds to a clockwise rotation when looking along the corresponding axis from the origin..

Applying a sequence of rotations to an object can have one of four interpretations. We show below the Euler angle (eu) representation for each case where we do a rotation of 0.1 around z followed by a rotation of 0.2 around x; in each case, multiplying by the rotation matrix converts the coordinates of a point on the object to its new value.

  1. m='zx', t=[0.1; 0.2]: keeping the axes fixed in space, rotate the object first around the z axis and then rotate it around the original x axis. . This is the point of view from which the routines have been written.
  2. m='xz', t=[0.2; 0.1]: rotate the object  first around the z axis and then rotate it around the line on the object that was originally aligned with the x axis (i.e. the rotation axes have moved with the object).
  3. m='xz', t=[-0.2; -0.1]: keeping the object fixed in space, rotate the frame of reference around the z axis and then rotate it around the original x axis (which has not moved relative to the object).
  4. m='zx', t=[-0.1; -0.2]: keeping the object fixed in space, rotate the frame of reference around the z axis and then rotate it around the new position of the x axis.
Code Params Convert from Convert to Description
ro Rn#n eu, pl, qr eu, pl, qr Rotation Matrix: This is an n by n rotation matrix. Multiplying the coordinates of an object by R gives the coordinates of the rotated object. [rotation matrix properties]
eu m,t3 qr, ro qr, ro Euler Angles: t contains a sequence of "euler angles" while m contains the sequence of axes around which the rotations should be performed (e.g. 'xzy' means rotate around x first). The axes are fixed in space and do not rotate with the object.
ax a3,t qr qr Axis of Rotation: the axis of rotation is a, while t gives the rotation angle in radians.
pl un,vn,t ro ro Plane of Rotation: The plane of rotation is that containing u and v while t gives the rotation angle in radians. If t is omitted, the rotation moves direction u to direction v.
qr q4 eu, mr, qc, ro ax, eu, mr, qc, ro Real Quaternion Vector: q = [c; s*a] where c=cos(t/2), s=sin(t/2) and a is the axis of rotation. The values q and -q represent the same rotation. [quaternion properties]
mr Q4#4 qr qr Real Quaternion Matrix: A 4 by 4 real matrix whose first column is the real quaternion vector defined above. Multiplication of quaternion matrices is homomorphic to multiplication of the corresponding rotation matrices.
qc q2 mc, qr mc, qr Complex Quaternion Vector: A 2 element vector of the form a+jb  where [a; b] is the real quaternion vector defined above.
mc Q2#2 qc qc Complex Quaternion Matrix:  A 2 by 2 complex matrix whose first column is the complex quaternion vector defined above. Multiplication of quaternion matrices is homomorphic to multiplication of the corresponding rotation matrices.