Given two points on a unit sphere in spherical coordinates representation ($\theta$ is longitude, $\phi$ is latitude in $[0,\pi]$), I want to express their angular difference in spherical coordinates.

In detail: given two points $p_1,p_2$ on the meridian, the first is under the second. Making the first the new north pole but leaving the meridian at $\theta =0°$ should give me a spherical coordinate with $\phi = |\phi_1 - \phi_2| $ which seems obvious, but the new longitude $\theta$ needs to become $180°$ although $\theta_1 = \theta_2 = 0$ (meridian).

If the answer is to convert both coordinates to Euclidian (X,Y,Z), then subtract and then reconvert to spherical coordinates I would not be surprised. But I would be very glad, if you could state why such a difference as in $ \mathbb{R}^{3}$ is not possible in spherical coordinates. What property do they miss?

Edit: these images should clarify my intentions. Difference of angles on a sphere. A becomes the new north pole.

The left image shows an angular difference. But I understand that a coordinate-wise difference is not sufficient. To show an example, please look at the right image.

$A$ becomes the new north pole. Thereby $B's$ polar coordinate changes to $\theta(B-A)$. But additionally the azimuthal angle of $B'$ becomes $\phi(B)=$ 180°. Imagine another extreme case where $\phi(B)$ started with 90°. It would end up at the same 90° after making $A$ the new north pole.

  • $\begingroup$ Do you want the angle, of two general points, relative to the center of the sphere ? $\endgroup$ Aug 6 '17 at 10:24
  • $\begingroup$ I think yes. The north pole in spherical coordinates (where $\phi=0$) should be identified with the new point $p_1$, the sphere center should remain the same. $\endgroup$
    – VisorZ
    Aug 6 '17 at 10:30
  • $\begingroup$ The original question says "θ is longitude, ϕ is latitude in [0,π]", but in the associated diagram, θ is shown as colatitude, and ϕ as longitude. Which is correct for the following discussion? $\endgroup$
    – KeithB
    Jun 22 '20 at 10:10

Given two points on a sphere $(x_1,y_1,z_1)=(\sin \phi_1 \cos \theta_1,\sin \phi_1 \sin \theta_1,\cos \phi_1 )$ and $(x_2,y_2,z_2)=(\sin \phi_2 \cos \theta_2,\sin \phi_2 \sin \theta_2,\cos \phi_2 )$. Take the dot product of these to obtain the cosine of the angle $\alpha$ between them relative to the center of the sphere. We have \begin{eqnarray*} \cos \alpha = \cos \phi_1 \cos \phi_2 +\sin \phi_1 \sin \phi_2 ( \cos \theta_1 \cos \theta_2 +\sin \theta_1 \sin \theta_2) \\ \cos \alpha = \cos \phi_1 \cos \phi_2 +\sin \phi_1 \sin \phi_2 \cos (\theta_1 - \theta_2 ). \end{eqnarray*} \begin{eqnarray*} \alpha = \color{blue}{\cos^{-1} \left( \cos \phi_1 \cos \phi_2 +\sin \phi_1 \sin \phi_2 \cos (\theta_1 - \theta_2 )\right)}. \end{eqnarray*}

  • $\begingroup$ Now I understand what you asked me, I am sorry that I mislead you. Although your answer is correct in itself, the angle between them is not sufficient. Their relative position on the unit sphere expressed in one difference spherical coordinate is needed. $\endgroup$
    – VisorZ
    Aug 6 '17 at 10:58
  • $\begingroup$ Let $ \Delta \theta = \theta_1 - \theta_2$ and $ \Delta \phi = \phi_1 - \phi_2$. The formula above shows that $\alpha$ cannot be expressed in terms of just $ \Delta \theta$ and $ \Delta \phi$. Indeed the angle is highly dependent on the latitude. $\endgroup$ Aug 6 '17 at 11:07

The case you described is a change from one spherical coordinates system to another by exchanging the former zenith axis with a new direction expressed as a point on the sphere.

You might want to have a look at the solution of these questions:

Another method that worked for me is to do two rotations:

sphere axes

  1. Rotate point $B$ on the sphere around the zenith axis for $\phi(\,A\,)$ degrees. This positions $A$ on the meridian and makes $\phi(\,B\,)=\phi(\,B-A\,)$. This is a normal difference operation.
  2. Rotate $B$ on the sphere along the meridian around the $(\theta=90°,\phi=90°)$ axis for $\theta(\,A\,)$ degrees. This rotates $A$ along the meridian and puts it in place of the north pole. The relation between $A$ and $B$ will be preserved and your example cases are all covered. I cannot offer a formula for that, maybe others can.

If you need to implement the rotation of a point around an arbitrary axis, it is necessary to use quaternions which should be provided by your language's libraries. For C/C++ I recommend glm. I computed the rotation in XYZ-coordinates and transformed the resulting unit vector back to spherical coordinates.


The original question says "θ is longitude, ϕ is latitude in [0,π]", but in the associated diagram, θ is shown as colatitude, and ϕ as longitude.

Which is correct for the following discussion?

  • $\begingroup$ The meridian is in range [0, pi] and although its line in the diagrams is a vertical line, a point moving on the meridian has a fixed longitude and a changing latitude. That means such a point has one direction of freedom and this freedom is different latitudes. I am certain, that the first image corresponds exactly with the text. $\endgroup$
    – VisorZ
    Aug 1 '20 at 17:45

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.