function Q = CinInvHip_Liv( ang1,P,L )

 %-- L=[l0 l1 l2 l3 l4 l5 l5h l5t l6] -------------------------------------
  l0 = L(1); l1 = L(2); l2 = L(3); l3 = L(4); l4 = L(5); 
  l5 = L(6); l5h = L(7); l5t = L(8); l6 = L(9);
     
 %-- Juntas da anca -------------------------------------------------------
  ang7 = 0;
  ang8 = 0;

 %-- Restriçao cinematica -------------------------------------------------  
  xh  = P(1);  yh  = P(2);     zh  = P(3); 
  x10 = P(4);  y10 = yh+l6/2;  z10 = P(6)+l1+l0;  % y10 nao usado!
 %-- Junta da anca --------------------------------------------------------
  A = ( z10-zh+l5+l5h/2+l4 );
  K1 = 2*l3*(x10-xh);
  K2 =-2*l3*A;
  K3 = (x10-xh)^2+A^2+l3^2-l2^2;
  KK_aux = K1^2+K2^2-K3^2;
  if KK_aux < 0, disp('ERROR MSG: function CinInv12R'), pause, return, end
  ang9 = atan2(K1,K2)+atan2(sqrt(K1^2+K2^2-K3^2),K3);
  %-- Ângulo entre -pi e pi -----------------------------------------------
  if ang9 >  pi,    ang9 = ang9-2*pi;   end
  if ang9 < -pi,    ang9 = ang9+2*pi;   end
  
 %-- Junta do joelho ------------------------------------------------------
  K1 = 0;
  K2 = 2*l2*l3;
  K3 = (x10-xh)^2+A^2-l3^2-l2^2;
  KK_aux = K2^2-K3^2;
  if KK_aux < 0, disp('ERROR MSG: function CinInv12R'), pause, return, end
  ang10 = -atan2(sqrt(K2^2-K3^2),K3);
 
 %-- Juntas do tornozelo --------------------------------------------------
  ang11 = -ang9-ang10;
  ang12 = 0;
%-- Vector de juntas ------------------------------------------------------
  Q = [ ang7 ang8 ang9 ang10 ang11 ang12 ];
%-----------------------------------------------------------------------end
