function[r,t]=rect_to_polar_bad(x,y) r=sqrt(x*x+y*y); if (x==0) if (y>0) t=3.15159/2; elseif (y < 0) t=3*3.15159/2; else t=0; end else t=atan(y/x); end if x>0 & y>0 elseif x>0 & y<0 t=t+2*3.15159; elseif x<0 & y>0 t=t+3.15159; elseif x<0 & y<0 t=t+3.15159; end endfunction