%%% %%% Create a 3x3 rotation matrix from three rotation angles (in degrees). %%% function [RM] = rotmat(Rx,Ry,Rz) Cos_Rx = cos( Rx*pi/180 ); Sin_Rx = sin( Rx*pi/180 ); Cos_Ry = cos( Ry*pi/180 ); Sin_Ry = sin( Ry*pi/180 ); Cos_Rz = cos( Rz*pi/180 ); Sin_Rz = sin( Rz*pi/180 ); RMx = [ 1 0 0 ; 0 Cos_Rx -Sin_Rx ; 0 Sin_Rx Cos_Rx ]; RMy = [ Cos_Ry 0 Sin_Ry ; 0 1 0 ; -Sin_Ry 0 Cos_Ry ]; RMz = [ Cos_Rz -Sin_Rz 0 ; Sin_Rz Cos_Rz 0 ; 0 0 1 ]; RM = RMz * RMy * RMx;