I want to find the distance between two points in spherical coordinates, so I want to express $xx'$ 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'^22rr'\cos(\theta \theta')}$ if $\phi,\phi'$ is the same, but what is the most general distance?

Probably the most easy thing to do would be to convert both points to Cartesian coordinates, subtract them and take the length of that vector. – Thomas Russell Jun 13 '14 at 15:39

6yes, but i really don't want to do this. – Jun 13 '14 at 15:41

Why not? Surely if it's easier and more efficient then there's no reason to do otherwise? – Thomas Russell Jun 13 '14 at 15:41

2No, it is not more efficient, cause I need to integrate over this and use this spherical symmetry. – Jun 13 '14 at 15:51

http://math.stackexchange.com/questions/231221/greatarcdistancebetweentwopointsonaunitsphere might help you – Hippalectryon Jun 13 '14 at 15:56

1@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 greatcircle. – toliveira Mar 11 '17 at 01:39
3 Answers
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{(xx')^2+(yy')^2+(zz')^2}\\ &=\sqrt{r^2+r'^22rr'\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'^22rr'\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'^22rr'\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.
 27,040
 3
 65
 113

5It 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). – buckminst Jun 15 '18 at 03:14

1This seems interesting, but odd to me. So, on a unit sphere, looking at the point (1,0°,0°), the distance from any point is $\sqrt{22cos\theta '}$? This doesn't seem right somehow, how does the other coordinate not count? – toorelevant May 03 '21 at 11:14

1@toorelevant The point (1,0°,0°) corresponds to the Cartesian point (0,0,1). Think of it as the north pole of the unit sphere. Any points on the same circle of latitude should have the same distance to the north pole. – David H Nov 09 '21 at 17:38

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{(xx')^2+(yy')^2+(zz')^2}=$$$$=\sqrt{r^2+r'^22rr'\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.
 5,656
 2
 22
 36
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_1r_2$.
 141
 3