# Going from cartesian to cylindrical coordinates - how to handle division with $0$

I have three point charges with the cartesian coordinates:

$$q_1(a,0,0) \: \: \: q_2(0,a,0) \: \: \: q_3(0,0,a)$$,

I want to convert these into both cylindrical and spherical coordinates.

The cartesian coordinates are written like this: $$(x,y,z)$$

The cylindrical coordinates are written like this: $$(r,\theta,z)$$

The spheircal coordinates are written like this: $$(\rho,\theta,\phi)$$

From https://en.wikipedia.org/wiki/List_of_common_coordinate_transformations I found these conversion formulas going form cartesian to cylindrical:

$$r=\sqrt{x^2+y^2}$$

$$\theta=\arctan(\frac{x}{y})$$

$$z=z$$

My Problem

Now, I want to convert the cartesian coordinates $$(a,0,0)$$ into cylindrical. We go like this $$r=\sqrt{a^2+0^2}=a$$ $$\theta=\arctan(\frac{a}{0})=???$$ $$z=z$$

My problem is that I don't how to handle the $$\theta$$ calculation when the y-coordinate is $$0$$. Can somebody help me here, or maybe I'm using a wrong formula?

• Thank you for your answer. But what do I do for the point $(0,0,a)$? The arctan2 function is not defined when $x = 0$ and $y = 0$. Is the cylindrical coordinates then just $(0,0,a)$?
• @Carl You mean when $r = 0$? In that case, you can choose any angle $\theta$. Sep 13, 2020 at 18:25