function a=kart2bas(u);

% mechanische Konstanten
% für Robotik-Übung

bein_ay=0;
bein_az=0;
bein_b=50;
bein_c=110;
bein_d=200;
bein_c2_d2=52100;

% Transformation

h3=u(1,:);

h4=u(2,:) - bein_ay;
h5=-u(3,:) - bein_az;  % Achtung: Unkehrung der Z-Achse
h6=sqrt(h3 .* h3 + h4 .* h4) - bein_b;
h7=0.5 * (h6 .* h6 + h5 .* h5 - bein_c2_d2) / bein_c;


for i=1:size(h7,2)
   if h7(i) > bein_d
      h7(i) = bein_d;
   end
end

a(3,:)=acos(h7 / bein_d);
h8=bein_d * sin(a(3,:));

a(2,:)=atan2(((bein_c + h7) .* h5 - h6 .* h8),(((bein_c + h7) .* h6 + h5 .* h8)));
a(1,:)=atan2(h3,h4);






