function [Qr] = ang2orth(theta) 
% ANG2ORTH generate orthogonal matrix from given angles
Qr = eye(3);
n = 1;
for i = 2 : -1 : 1
   for j = 3 : -1 : i + 1
      t = theta(n); 
      s = sin(t); c = cos(t);
      U = eye(3);
      U(i,i) =  c; U(i,j) = s; 
      U(j,i) = -s; U(j,j) = c;
      Qr = U * Qr; n = n + 1;
   end
end

