1. ## Cartesian to Spherical

Hi,

I need to convert these coordinates from cartesian to spherical.

(3,4,12)

and these coordinates from spherical to cartesian

(5, $\frac{\pi}{4}$, $\frac{\pi}{6}$)

I've done a bunch of searches, but none of the websites I found were very clear. Could someone explain this to me?

2. You should know that

$x = r\sin{\theta}\cos{\phi}$

$y = r\sin{\theta}\sin{\phi}$

$z = r\cos{\theta}$.

Going the other way:

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

$\theta = \arccos{\frac{z}{x^2 + y^2 + z^2}}$

Finding $\phi$ is more difficult as it depends on the values of $x$ and $y$.

Namely:

$\phi = \arctan{\frac{y}{x}}$ for $x > 0$

$\phi = \pi + \arctan{\frac{y}{x}}$ for $y \geq 0, x < 0$

$\phi = -\pi + \arctan{\frac{y}{x}}$ for $y < 0, x < 0$

$\phi = \frac{\pi}{2}$ for $y > 0, x = 0$

$\phi = -\frac{\pi}{2}$ for $y < 0, x = 0$

$\phi =$ undefined for $y = 0, x = 0$.

These values come from elementary trigonometry.