function [ang1,ang2,ang3] = CinInv3R(xe,ye,inclinacao,l1,l2,l3)

%-- Junta do tornozelo e joelho -------------------------------------------
for k=1:length(xe),
   
  k1_1 = 2*l1*ye(k);						k1_2 = 0;
  k2_1 = 2*l1*xe(k);						k2_2 = 2*l1*l2;
  k3_1 = xe(k)^2+ye(k)^2+l1^2-l2^2;	        k3_2 = xe(k)^2+ye(k)^2-l1^2-l2^2;

  k1_aux = k1_1^2+k2_1^2-k3_1^2; k2_aux = k2_2^2-k3_2^2;
  if k1_aux < 0 | k2_aux < 0,
     disp('ERROR MSG: function CinInv3R'), k1_aux, k2_aux, pause
     return
  end
      
  ang1(k) = atan2(k1_1,k2_1)-atan2(sqrt(k1_1^2+k2_1^2-k3_1^2),k3_1);
  ang2(k) = atan2(sqrt(k2_2^2-k3_2^2),k3_2);
  
  %-- Ângulos entre -pi e pi ---------------------------------------------
   if ang1(k) >  pi,    ang1(k) = ang1(k)-2*pi;   end
   if ang1(k) < -pi,    ang1(k) = ang1(k)+2*pi;   end
   
  %-- Junta da anca ------------------------------------------------------   
   ang3(k) = inclinacao(k)-ang1(k)-ang2(k); 
   
end  
%-------------------------------------------------------------------------
