TITLE: Distance between two points in spherical coordinates
QUESTION [21 upvotes]: 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?

REPLY [4 votes]: 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||$.