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, $\displaystyle \frac{\pi}{4}$, $\displaystyle \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

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

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

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

Going the other way:

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

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

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

Namely:

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

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

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

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

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

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

These values come from elementary trigonometry.