In 3D Euclidean space, we know that distance between 2 points: $a=(x_1,y_1,z_1)$ and $b=(x_2,y_2,z_2)$ is $s^2=(x_2-x_1)^2+(y_2-y_1)^2+(z_2-z_1)^2)$from metric $ds^2=dx^2+dy^2+dz^2$. But I was thinking if we have the misfortune of working in spherical coordinates, i.e. only given $a=(r_1,\theta_1,\phi_1)$ and $b=(r_2,\theta_2,\phi_2)$, how can I work out $s^2$?

I suppose I need to do the integration $$\int_a^b (dr)^2+r^2(d\theta)^2+r^2\sin^2\theta(d\phi)^2$$which I tried and got $$\left(\int_a^b dr\right)^2+\left(\int_a^b rd\theta\right)^2+\left(\int_a^b r\sin\theta d\phi\right)^2=(r_2-r_1)^2+(r_2\theta_2-r_1\theta_1)^2+(r_2\sin\theta_2\phi_2-r_1\sin\theta_1\phi_1)^2$$

Is this correct??

  • $\begingroup$ Nope. When $r_1=r_2$ you must get something that depends only on $r$ and $\cos(\theta_1-\theta_2)$ and $\cos(\phi_1-\phi_2)$, by en.wikipedia.org/wiki/Spherical_law_of_cosines. $\endgroup$ Dec 23, 2014 at 0:21
  • $\begingroup$ Why not just to convert $(r_i,\theta_i,\phi_i)$ into cartesian coordinates and compute the distance by the usual way? $\endgroup$ Dec 23, 2014 at 0:22
  • $\begingroup$ well, yes I suppose we can just convert to cartesian but I was just wondering if there was a way to do the integral just using spherical polar $\endgroup$
    – Tobyhas
    Dec 23, 2014 at 0:24
  • $\begingroup$ For sure. But just notice that the integral of the square is not the square of the integral. $\endgroup$ Dec 23, 2014 at 0:26
  • $\begingroup$ @JackD'Aurizio yeh I was a bit suspicious about doing the square of integral...but I was thinking: in cartesian coordinates, $s^2=\int_a^b (dx)^2+(dy)^2+(dz)^2$ and in order to recover from this the familiar $s^2=(x_2-x_1)^2+(y_2-y_1)^2+(z_2-z_1)^2$ I did $(\int_{x_1}^{x_2} dx)^2+(\int_{y_1}^{y_2} dy)^2+(\int_{z_1}^{z_2} dz)^2$ and used the similar method in the case of the spherical polar coordinates $\endgroup$
    – Tobyhas
    Dec 23, 2014 at 0:35

1 Answer 1


Assuming that $\theta$ is the latitude and $\phi$ is the longitude we have that the cartesian coordinates of the first point are: $$ (r_1 \cos\theta_1 \cos\phi_1, r_1 \cos\theta_1 \sin\phi_1, r_1\sin\theta_1),$$ so the distance between the two points is given by: $$ \sqrt{r_1^2+r_2^2-2r_1r_2\left(\cos\theta_1\cos\theta_2\cos(\phi_1-\phi_2)+\sin\theta_1\sin\theta_2\right)}.$$


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .