function [LIB]=lib(omega)
% lib acepta un vector de tres angulos (en radianes) que describen un giro 3-dimensional.
% produce una matriz de rotacion de 3x3
% Ref. UTIAS Simulador de 6DOF,  L. D. Reid and Nahon. 1985, U of Toronto.

sinpsi=sin(omega(1));
sinth=sin(omega(2));
sinphi=sin(omega(3));
cospsi=cos(omega(1));
costh=cos(omega(2));
cosphi=cos(omega(3));

LIB= [	cospsi*costh 				cospsi*sinth*sinphi-sinpsi*cosphi			cospsi*sinth*cosphi+sinpsi*sinphi
   		sinpsi*costh				sinpsi*sinth*sinphi+cospsi*cosphi			sinpsi*sinth*cosphi-cospsi*sinphi
         -sinth   					costh*sinphi										costh*cosphi
      ] ;
      
%LIB(1,1)=cospsi*costh;
%LIB(2,1)=sinpsi*costh;
%LIB(3,1)=-sinth;
%LIB(1,2)=cospsi*sinth*sinphi-sinpsi*cosphi;
%LIB(2,2)=sinpsi*sinth*sinphi+cospsi*cosphi;
%LIB(3,2)=costh*sinphi;
%LIB(1,3)=cospsi*sinth*cosphi+sinpsi*sinphi;
%LIB(2,3)=sinpsi*sinth*cosphi-cospsi*sinphi;
%LIB(3,3)=costh*cosphi;
return
