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.

To obtain the Euler angles associated with this rotation, use eulang.

Examples

A rotation by 2π/3 (120 degrees) around the axis [1;1;1] permutes the three coordinate axes: x becomes y, y becomes z, and z becomes x. The associated rotation matrix is

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

R =
     0     1     0
     0     0     1
     1     0     0

Applying this to the x vector gives

v = [1;0;0];      % vector to rotate
v_rot = R.'*v     % rotated vector; note transpose
v_rot =
     0
     1
     0
See also

ang2vec, erot, rotmat2axi, vec2ang