# Cartesian to polar using movemesh

**URL:** https://community.freefem.org/t/cartesian-to-polar-using-movemesh/2874
**Category:** General Discussion
**Created:** [January 10, 2024, 6:17am UTC](https://community.freefem.org/t/cartesian-to-polar-using-movemesh/2874 "2024-01-10T06:17:58Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![RaghunathBandha](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/raghunathbandha/32/1843_2.png) [@RaghunathBandha](https://community.freefem.org/u/RaghunathBandha)
#### Post date: [January 10, 2024, 6:17am UTC](https://community.freefem.org/t/cartesian-to-polar-using-movemesh/2874/1 "2024-01-10T06:17:59Z")

</div>

[movemesh.edp](https://community.freefem.org/uploads/short-url/rITx63W6X568M1XvdHEulyk46qh.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)]);  
plot(Sh,wait=true);

---

<div class="post-metadata">

### Author: ![cmd](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/cmd/32/67_2.png) [@cmd](https://community.freefem.org/u/cmd)
#### Post date: [January 10, 2024, 2:12pm UTC](https://community.freefem.org/t/cartesian-to-polar-using-movemesh/2874/2 "2024-01-10T14:12:01Z")

</div>

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…
