I want to understand how to convert from Cartesian coordinates to spherical coordinates. I have the following definitions:

\begin{align} x & =r\sin\theta\cos\phi \\[6pt] y & =r\sin\theta\sin\phi \\[6pt] z & =r\cos\theta \\[6pt] \rho & =r\sin\theta \end{align}

In written terms: $r$ is the distance from the origin to the point, $\phi$ is the angle needed to rotate around $z$ to get to the point, $\theta$ is the angle from the positive $z$-axis, $\rho$ is the distance between the point and the $z$-axis.

On the basis that $(x,y,z)=(r,\theta,\phi)$ I have,


using Pythagoras' Theorem gives


Next take $z=r\cos\theta$ which gives

$$\theta=\arccos\left(\frac{z}{r}\right).$$ Both of these agree with what I have found on wikipedia, however I can't understand how the last coordinate $\phi$ is reached. This is what I get:

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

from here I use the relationship that $\rho=\sqrt{x^2+y^2}=r\sin\theta$ and write

$$\frac{y}{\rho}=\sin\phi$$ $$\arcsin\left(\frac{y}{\rho}\right)=\phi.$$

Have I gone wrong somewhere? Can it be explained to me how my last result differs from that provided by wikipedia?



In most texts, $\theta$ is the angle in the $xy$ plane and $\phi$ is the angle down from the $z$ axis. That is, I think you (and wiki) have things not as usual. Nevertheless, using their definitions, both answers are correct.

The wiki terms for $y$ and $x$, when one computes $y/x$ the $r \sin(\theta)$ cancels and the result is $\sin(\phi)/\cos(\phi) = \tan(\phi)$. so you can say $\phi = \tan^{-1}(y/x)$ as wiki does.

For your version, you use the extra symbol $\rho$, which is really $r \sin(\theta)$. So using the same formulas from wiki gives $y/\rho = y/(r \sin(\theta) )$. This time the $y$ in wiki is $r\sin(\theta)\sin(\phi)$, so things cancel and you get $y/\rho = \sin(\phi)$. Thus you can also say that $\phi = \arcsin(y/\rho)$. But note that $\rho$ is not one of the spherical coordinates, but is just $r\sin(\theta)$ in terms of the spherical coordinates. It's not usual to give the inverse in terms of other symbols than the direct variables.

| cite | improve this answer | |
  • 1
    $\begingroup$ In both the wiki version and yours, care must be taken as to which quadrant one is in, because of the arctan and arcsin functions not automatically returning the original angles. $\endgroup$ – coffeemath Oct 12 '12 at 16:51
  • $\begingroup$ Thanks for help explaining this in the terms I am using and I understand now that I really don't want to be using $\rho$ in my final conversions. Could you help explain why I would divide y/x in order to obtain tan? $\endgroup$ – Aesir Oct 12 '12 at 17:20
  • 1
    $\begingroup$ In the wiki formulas, y is r sin theta sin phi and x is r sin theta cos phi. By dividing y by x we will have a cancel of the common factor r sin theta, arriving at simply sin phi / cos phi, which is tan phi. $\endgroup$ – coffeemath Oct 12 '12 at 17:31
  • $\begingroup$ Ah yes, I see so it's just common sense to do that, or not in my case! Thanks, I understand now. $\endgroup$ – Aesir Oct 12 '12 at 17:40

Your formula for $\phi$ is correct for $x>0$, but gives the wrong angle when $x<0$: in this case $\phi\in(\pi/2,3\pi/2)$, but $\arcsin$ gives a result in $[-\pi/2,\pi/2]$.

The formula shown by Wikipedia is obtained from

$$ \sin\phi=y/\rho\\ \cos\phi=x/\rho $$

and dividing the two's (when possible)

$$ \tan\phi=y/x. $$

From here it comes out $\arctan$, with all the warning of the case, leading to the atan2 function.

| cite | improve this answer | |
  • $\begingroup$ Thanks for taking the time to answer, could you provide some more clarification on why I would divide $y$ by $x$? I can see now that, that would give me $\tan$ which is what I need but I don't understand why I would do this. $\endgroup$ – Aesir Oct 12 '12 at 17:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.