
function Q = euler(theta)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Computes the rotation matrix Q corresponding to 
% the coordinates theta using the Euler angle map.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

u1 = theta(1); u2 = theta(2); u3 = theta(3);

c1 = cos(u1) ; c2 = cos(u2) ; c3 = cos(u3) ;

s1 = sin(u1) ; s2 = sin(u2) ; s3 = sin(u3) ;

Q  = [ c2*c3-s1*s2*s3, -c1*s3, s2*c3+s1*c2*s3 ; 
       c2*s3+s1*s2*c3,  c1*c3, s2*s3-s1*c2*c3 ;
           -c1*s2    ,    s1 ,       c1*c2     ] ;


