Get rotation matrix from rotation axis and angle.
R = rotaxi2mat(n,phi);
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 phi
around n
.
rotaxi2mat
converts R
to n
and
phi
decribing the same rotation.
n
must be a 3-element vector, not necessarily normalized.
phi
is a number giving the angle in radians, not degrees.
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.
rotangle = 2*pi/3; rotaxis = [1; 1; 1]; R = rotaxi2mat(rotaxis,rotangle)
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.
ang2vec, erot, rotmat2axi, vec2ang