The following drawing shows how to convert from Cartesian coordinates to spherical coordinates. This is a short post, but these three equations are pretty useful.

I am going to use the end of this post to define the cosine and sine functions:

$\sin\phi \equiv \frac{opp}{hyp}$

$\cos\phi \equiv \frac{adj}{hyp}$.

Here, $hyp$ is the length of the hypotenuse of a right triangle, $opp$ is the length of the side that is opposite to the angle $\phi$, and $adj$ is the length of the side that is adjacent to the angle $\phi$. Note that $\phi$ must be less than 90 degrees if $\phi$ is an angle of a right triangle. In case it wasn’t clear, these statements are for Euclidean geometry.