rotaxi2mat

Get rotation matrix from rotation axis and angle.

Syntax
R = rotaxi2mat(n,rho);
Description

A given rotation can be represented either by a 3x3 rotation matrix R or by a rotation axis n (3-element column vector) plus a rotation angle rho around n.

rotaxi2mat converts R to n and rho describing the same rotation.

n must be a 3-element vector, not necessarily normalized. Alternatively, n can be one of the following letter abbreviations: 'x' ([1;0;0]), 'y' ([0;1;0]), 'z' ([0;0;1]), 'xy' ([1;1;0]), 'xz' ([1;0;1]), or 'xyz' ([1;1;1]).

rho is a number giving the angle in radians, not degrees.

Examples

A rotation by 2π/3 (120 degrees) around the axis [1;1;1] amounts to the interchange of the three coordinate axes. Therefore, the associated rotation matrix only contains zeros and ones.

rho = 2*pi/3;                % radians
rotaxis = [1; 1; 1];
R = rotaxi2mat(rotaxis,rho)

R =
     0     1     0
     0     0     1
     1     0     0

The associated Euler angles are

Angles = eulang(R);
Angles*180/pi
ans =
     0    90    90

The rotation can thus be obtained by first rotating by 90 degrees around the y axis, followed by a rotation by 90 degrees around the resulting z axis.

See also

ang2vec, erot, rotmat2axi, vec2ang