How to Calculate Distance on a Sphere with Earth-like Coordination System? – Spherical Trigonometry

spherical trigonometrytrigonometry

This is probably a too simple question for this site, but I would really appreciate any answers.

Lets say I've got a sphere with radius $r = 70$ meters. This sphere has an Earth-like reference system in which coordinates are given as: (longitude, latitude). The coordinate system is exactly like the Earth's, so zero degrees latitude is on the "equator" of the sphere with $90$ degrees being the top or "North pole" of the sphere, and $-90$ degrees being the bottom or "South pole" of the sphere. Also, I've got one vertical line on which positive numbers go "East" and negative numbers go "West". On this sphere I've got two points with their location, both depicted in degrees:
$$
\begin{gather}
(1, 1)\\
(3, 3)
\end{gather}
$$

Both points are drawn in the image I've drawn below. In this image, I've also drawn some "help-lines".

enter image description here

I now need to find the length of $d$ (the distance between the two points). So far I can calculate the variables $a$ and $b$, and I know that $D$ (the corner opposite of $d$) is 90 degrees.

To calculate the distance of $d$ I use the Spherical law of cosines (wiki here):
$$
\cos(d) = \cos(a) * \cos(b) + \sin(a) * \sin(b) * \cos(D)
$$

Since we are using an Earth like reference system, however, the latitude range is $[-\frac{\pi}{2}, \frac{\pi}{2}]$ instead of $[0, \pi]$ and the longitude range is $[-\pi, \pi]$ instead of $[0, 2\pi]$. I read that we therefore need to translate this law to the following:
$$
\cos(d) = \sin(a) * \sin(b) + \cos(a) * \cos(b) * \cos(D)
$$

Since the spherical law of cosines needs all variables in radians but our points on the sphere are given in degrees, I first transform the degrees to radians:
$$
\begin{align}
a &= (3 – 1) * \frac{\pi}{180} = 0.0349065850399\\
b &= (3 – 1) * \frac{\pi}{180} = 0.0349065850399\\
D &= 90 * \frac{\pi}{180} = 1.5707963267948966
\end{align}
$$

Filling this into the formula I get the following:
$$
\begin{gather}
\cos(d) = \sin(a) * \sin(b) + \cos(a) * \cos(b) * \cos(D) = 0.00121797487009\\
d \text{ in radians} = 1.56957835162\\
\text{distance in meters} = d * 70 = 109.870484614
\end{gather}
$$

The python code with which I calculate this can be found here: http://pastebin.com/U3qvXxRZ

The answer I get here seems to be incorrect though. First of all, a distance of 109 meters between two points which are only two degrees apart on a sphere with a diameter of 140 meters seems like a lot to me. Second of all, if I move the points closer to each other, the distance_in_meters seems to increase. Thirdly, I found this little piece of python code (here), in which they seem to do it differently. They simply take the latitude of the first and second point as the variables 'a' and 'b', instead of the difference between the latitudes as 'a'.

So my question. What am I doing wrong here? What is the mistake I make?

Best Answer

The spherical law of cosines is about spherical triangles with side lengths $a$, $b$, $c$ (measured along arcs of great circles), and angles $\alpha$, $\beta$, $\gamma$. Your $a$, in whatever units it is measured, is not such a side.

Instead of the triangle in your figure you should consider the spherical triangle with vertices $A=(\phi_1,\theta_1)$ ($(1^\circ,1^\circ)$ in your example), $B=(\phi_2,\theta_2)$ ($(3^\circ,3^\circ)$ in your example), and the north pole $D$. The sides $a$ and $b$ of this triangle (which are not the $a$, $b$ of yours) lie on meridians, i.e., great circles, and you know their lengths, namely $a={\pi\over2}-\theta_2$ and $b={\pi\over2}-\theta_1$. Furthermore you know the angle $\delta=\phi_2-\phi_1$ at $D$ (this is the "real" $a$ of yours!). These data suffice to compute the side $d$ by means of one of the spherical cosine laws. The formula in question is $$\cos d=\cos a\ \cos b+\sin a\ \sin b\ \cos\delta\ .$$ Finally we express $a$, $b$, and $\delta$ by the given quantities $\phi_i$, $\theta_i$: $$\cos d=\sin\theta_1\ \sin\theta_2+\cos\theta_1\ \cos\theta_2\ \cos(\phi_2-\phi_1)\ .$$