rotateframe

Rotate a frame around a specific axis.

Syntax
ang = rotateframe(ang0,nRot,rho)
[ang,R] = rotateframe(ang0,nRot,rho)
Description

rotateframe rotates the frame described by the three Euler angles (in radians) in ang0 by the angle rho (in radians) around the rotation axis nRot, returning the rotated frames in ang (Euler angles) and R (rotation matrix).

ang0 describes the frame orientation before the rotation. It is a row vector of three Euler angles (in radians). See the page on frames for details.

nRot is the axis of rotation. For example, the vector nRot = [1;0;0] indicates the rotation axis is x. In general, the vector nRot = [a;b;c] means that the space-fixed rotation axis is a*x+b*y+c*z, where x, y and z are the unit vectors of the space-fixed frame. nRot does not have to be normalized.

rho is the angle of rotation, in units of radians. The rotation is defined in a positive sense around the rotation axis nRot. rho can be be a single number or an array. If an array is given, rotateframe calculates the rotated frame for each angle in the rho array.

The output ang is a set of Euler angles that describe the new frame orientations resulting from the rotation. If rho contains more than one value, ang contains multiple rows, with one Euler angle set per row.

The output R is the rotation matrix that corresponds to the Euler angles in ang. If multiple rotation angles are given, R is a cell array where each cell contains a rotation matrix for one rotation angle.

Examples

Here is a simple example that involves the rotation of a crystal around the lab x axis.

xL = [1;0;0];                       % space-fixed x axis
rho = 20*pi/180;                    % rotation angle (radians)
ang0 = [40 65 0]*pi/180;            % Euler angles for initial frame orientation
[ang,R] = rotateframe(ang0,xL,rho);     % frame orientation after rotation
Algorithm

This function uses erot, rotaxi2mat and eulang to perform the rotation. The call

ang = rotateframe(ang0,xL,rho);

calculates the Euler angles of the rotated frame using

R0 = erot(ang0);
Rrot = rotaxi2mat(xL,rho);
R = R0*Rrot;
ang = eulang(R);

Refer to the page on frames and Euler angles for more details.

See also

ang2vec, erot, eulang, rotaxi2mat, rotmat2axi, vec2ang