
function [r,delta] = CarttoPol(x,y)

r=sqrt(x^2+y^2);

if x>0
    delta = atan(y/x);
elseif x<0 && y >=0
    delta = atan(y/x) + pi;
elseif x<0 && y<0
    delta = atan(y/x) - pi;
elseif x==0 && y>0
    delta = pi/2;
else
    delta = -pi/2;
end
