Cartesian to polar using movemesh

movemesh.edp (148 Bytes)
I am trying to transfer cartesian coordinate to polar by using movemesh, I am getting error due to inverse tan function for (0,0). How to resolve the issue? Please help.
Shall I need to define atan(y/x) for (0,0) and (0,y) separately? If so how?

int n=64;
border C(t=0,2*pi){x=cos(t);y=sin(t);}
mesh Th=buildmesh(C(n));
mesh Sh=movemesh(Th,[atan(y/x), sqrt(x^2+y^2)]);

This method will not work because of the branch cut in the atan function. I suggest just using a rectangular grid on [0,R]x[0,2*pi] and interpreting x and y as r and theta. Then enforce periodic conditions on the azimuthal coordinate…