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

543 Views Asked by At

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?

1

There are 1 best solutions below

2
On BEST ANSWER

You need to use the arctan2 function, which takes all 4 quadrants into account.