17
$\begingroup$

I want to find the distance between two points in spherical coordinates, so I want to express $||x-x'||$ where $x=(r,\theta, \phi)$ and $x' = (r', \theta',\phi')$ by the respective components. Is this possible? I just know that this is $\sqrt{r^2+r'^2-2rr'\cos(\theta- \theta')}$ if $\phi,\phi'$ is the same, but what is the most general distance?

$\endgroup$
  • $\begingroup$ Probably the most easy thing to do would be to convert both points to Cartesian co-ordinates, subtract them and take the length of that vector. $\endgroup$ – Thomas Russell Jun 13 '14 at 15:39
  • 3
    $\begingroup$ yes, but i really don't want to do this. $\endgroup$ – user66906 Jun 13 '14 at 15:41
  • $\begingroup$ Why not? Surely if it's easier and more efficient then there's no reason to do otherwise? $\endgroup$ – Thomas Russell Jun 13 '14 at 15:41
  • 2
    $\begingroup$ No, it is not more efficient, cause I need to integrate over this and use this spherical symmetry. $\endgroup$ – user66906 Jun 13 '14 at 15:51
  • 1
    $\begingroup$ @Hippalectryon, I understand that the OP is interested in the distance along a straight line but your link explains how to calculate the distance along a great-circle. $\endgroup$ – toliveira Mar 11 '17 at 1:39
25
$\begingroup$

The expression of the distance between two vectors in spherical coordinates provided in the other response is usually expressed in a more compact form that is not only easier to remember but is also ideal for capitalizing on certain symmetries when solving problems.

$$\begin{align} \|\mathbf{r}-\mathbf{r}^\prime\| &=\sqrt{(x-x')^2+(y-y')^2+(z-z')^2}\\ &=\sqrt{r^2+r'^2-2rr'\left[\color{red}{\sin(\theta)\sin(\theta')}\color{blue}{\cos(\phi)\cos(\phi')}+\color{red}{\sin(\theta)\sin(\theta')}\color{blue}{\sin(\phi)\sin(\phi')}+\cos(\theta)\cos(\theta')\right]}\\ &=\sqrt{r^2+r'^2-2rr'\left[\color{red}{\sin(\theta)\sin(\theta')}\color{blue}{\left(\cos(\phi)\cos(\phi')+\sin(\phi)\sin(\phi')\right)}+\cos(\theta)\cos(\theta')\right]}\\ &=\sqrt{r^2+r'^2-2rr'\left[\color{red}{\sin(\theta)\sin(\theta')}\color{blue}{\cos(\phi-\phi')}+\cos(\theta)\cos(\theta')\right]}.\\ \end{align}$$

This form makes it fairly transparent how azimuthal symmetry allows you to automatically eliminate some of the angular dependencies in certain integration problems. Another advantage of this form is that you now have at least two variables, namely $\phi$ and $\phi'$, that appear in the equation only once, which can make finding series expansions w.r.t. these variables a little less of a pain than the others.

$\endgroup$
  • 1
    $\begingroup$ It should be noted that this formula uses phi as the azimuthal angle and theta as the polar angle (as there also exists the convention where the are swapped). $\endgroup$ – buckminst Jun 15 '18 at 3:14
6
$\begingroup$

You have simply to write it in Cartesian coordinates and change variables: $x=r\sin(\theta)\cos(\phi)$, $y=r\sin(\theta)\sin(\phi)$, $z=r\cos(\theta)$ $$\sqrt{(x-x')^2+(y-y')^2+(z-z')^2}=$$$$=\sqrt{r^2+r'^2-2rr'\left[\sin(\theta)\sin(\theta')\cos(\phi)\cos(\phi')+\sin(\theta)\sin(\theta')\sin(\phi)\sin(\phi')+\cos(\theta)\cos(\theta')\right]}$$ But I don't see a way to really improve this mess.

$\endgroup$
4
$\begingroup$

Building on the answer from @[David H], I wrote the distance in a way that highlights the difference in angles: $$ ||\vec r_1 - \vec r_2|| = \sqrt{ {r_1}^2 + {r_2}^2 - 2\, r_1 r_2 \cos(\theta_1 - \theta_2) - 2\, r_1 r_2 \sin \theta_1 \sin \theta_2 \left( \cos(\phi_1 - \phi_2) - 1 \right) } $$ It highlights the contributions from the difference in polar angle $\theta$ and the difference in the azimuthal angle $\phi$, (third and fourth terms, respectively, under the square root symbol). Note the intuitive scaling of the azimuthal contribution by $\sin \theta_1 \sin \theta_2$. Of course, when the angular differences are both $0$, the distance reduces to $||r_1-r_2||$.

$\endgroup$

Your Answer

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