Q: Given two points on the globe, how do you figure out the direction and distance to each other?

Physicist: The very short answer is: use the spherical law of cosines so you can do trigonometry on a sphere.

This is a seriously old problem that needed to be solved before we became a routinely globe-trotting species.  If you have the latitude and longitude of your location and a destination, you could just move east/west until you match the destination’s longitude then move north/south until you match the latitude.  But that’s a big waste of time, as the so-intuitively-obvious-it-barely-deserves-a-name “triangle inequality” will tell you.

The “triangle inequality” says that the sum of any two sides of a triangle are longer than any one side.  So if you’re traveling from Nicaragua to Norway, don’t go via Nigeria.

As you may have heard, the shortest distance between two points is a straight line.  For curved surfaces the closest you can get to a straight line is a “geodesic”, which is a straight line on small scales, but it you step back may be going all over the place.  If you wrap a ribbon around a gift (or any manner of festive package) and manage to keep it flat, you’ve found a geodesic, because if the path of the ribbon changes direction, the ribbon kinks.  On a sphere like Earth, where you’re stuck moving along the surface (instead of drilling straight through like some kind of compulsive, fire-proof mole), the geodesics are “great circles”.  If you walk in a straight line, you’re walking on a great circle.

A great circle is the path you’ll follow if you walk in a straight line on a sphere.  Smaller circles result from not-straight-lines (continuously turning a little to the side).

Doing geometry on a sphere is more difficult than geometry on a flat plane, but not by a hell of a lot.  Geometry, despite what some pudunk Greek philosophers may say, is basically just playing with triangles.  A nice, universal rule for any triangle is the Law of Cosines which relates the lengths of the three sides, a, b, and c, with the angle opposite one of those sides, C: c^2=a^2+b^2-2ab\cos(C).

Left: A triangle made from great arcs. Right: A triangle made from straight lines.

Slap that triangle on the side of a sphere and that law becomes the Spherical Law of Cosines:

\cos(c)=\cos(a)\cos(b)+\sin(a)\sin(b)\cos(C)

Here the meaning of a, b, and c has changed a little.  Lengths on a sphere can be described by angles (drawn from the center to the surface).  If you’re using radians (which you always should), those angles are \frac{\textrm{the overland distance}}{\textrm{Earth's radius}}.  This is generally easier to use than the actual distance.  For example, the angle from the north pole to the equator is 90° (obviously) while the physical distance is about 6,200 miles (different on every planet).

Lucky for us, positions on Earth are usually described in terms of angles (latitude and longitude) and not distances, so the spherical law of cosines is ready to go.  Just put the corners at the north pole, where you’re at, and where you’re planning to go.

If you put the corners of the triangle at a pole, your location, and your destination, then you can read off the lengths of two sides (90-latitude) and the angle at the pole (the difference of the longitudes).  From these there’s enough information to find the distance and bearing to the destination.

The law of cosines (either of them) relates four things: all three sides and one of the angles.  If you have any three of those pieces of information you can solve for the forth.  With the latitudes we have two sides and with the difference of the longitudes we got an angle.

First (because you always should) convert your angles from degrees to radians by multiplying by \frac{\pi}{180}: \theta_1=\frac{\pi}{180}(90-latitude1), \theta_2=\frac{\pi}{180}(90-latitude2), and \phi=\frac{\pi}{180}|longitude1-longitude2|.

\cos\left(\frac{\textrm{distance}}{\textrm{Earth's radius}}\right)=\cos\left(\theta_1\right)\cos(\theta_2)+\sin\left(\theta_1\right)\sin(\theta_2)\cos(\phi)

and therefore

\textrm{distance}=(\textrm{Earth's radius})\arccos\left[\cos\left(\theta_1\right)\cos(\theta_2)+\sin\left(\theta_1\right)\sin(\theta_2)\cos(\phi)\right]

Boom!  There’s the distance.  And with three sides in hand (the two given by the latitudes and the distance from, like, two seconds ago) you can find your “bearing”, the angle between north and your destination.

\cos\left(\theta_2\right)=\cos\left(\theta_1\right)\cos\left(\frac{\textrm{distance}}{\textrm{Earth's radius}}\right)+\sin\left(\theta_1\right)\sin\left(\frac{\textrm{distance}}{\textrm{Earth's radius}}\right)\cos\left(\textrm{bearing}\right)

and so

\textrm{bearing}=\arccos\left[\frac{\cos\left(\theta_2\right)-\cos\left(\theta_1\right)\cos\left(\frac{\textrm{distance}}{\textrm{Earth's radius}}\right)}{\sin\left(\theta_1\right)\sin\left(\frac{\textrm{distance}}{\textrm{Earth's radius}}\right)}\right]

For example, if you happen to be traveling from Nueva Guinea, Nicaragua (11.6932° N, 84.4540° W) to Nesflaten, Norway (59.6466° N, 6.7997° E), the angles involved are \theta_1=\frac{\pi}{180}(90-11.6932)\approx1.367, \theta_2=\frac{\pi}{180}(90-59.6466)\approx0.530, and \phi=\frac{\pi}{180}\left|6.7997-(-84.4540)\right|\approx1.593.  So the distance is

\textrm{distance}=(3959miles)\arccos\left[\cos\left(1.367\right)\cos(0.530)+\sin\left(1.367\right)\sin(0.530)\cos(1.593)\right]=(3959miles)(1.406)=5566miles

and the bearing is

\textrm{bearing}=\arccos\left[\frac{\cos\left(0.530\right)-\cos\left(1.367\right)\cos\left(\frac{5566}{3959}\right)}{\sin\left(1.367\right)\sin\left(\frac{5566}{3959}\right)}\right]=0.538rad=30.1^o

If you want to walk in a straight line from downtown Nueva Guinea to uptown Nesflaten, you’d face due north, turn about 30 degrees to the right, and walk in a straight line for about two and a half months, while ignoring the Atlantic Ocean to the best of your ability.

So how do you calculate distance and bearing?  A small bucket of math.  Today if you want to calculate sines and cosines you break out a computer.  So you may be wondering how they did this math back in the days of sailing ships (without GPS).  They didn’t.  Calculating was done once, then written down, then looked up many times.  Once upon a time books were useful!

A very boring book from the 17th century wherein you can look up the values of trig functions.

The people who actually did the calculating were “computers”; pitiable folk who sat in dark rooms and slowly went mad and rarely got to sail around the world.

This entry was posted in -- By the Physicist, Geometry, Math. Bookmark the permalink.

9 Responses to Q: Given two points on the globe, how do you figure out the direction and distance to each other?

  1. Nekko says:

    If all you want to do is calculate the “as the bird flies” distance it is child’s play. Why not postulate how to calculate the ACTUAL travelling distances say, by car, which will not allow you to drive over water or through mountains?
    Just need to apply a bit of fractal geometry!

  2. Leo says:

    Can’t you just stretch a thread between the points on the globe map and measure the thread length?

  3. Error: Unable to create directory uploads/2024/04. Is its parent directory writable by the server? The Physicist says:

    @Leo
    Sure! Just takes a lot of string, and knowing where to take one end of that string.

  4. Hnekko says:

    Yes but you would need a real size globe and a lot of thread.

  5. Leo says:

    Why, you can use any globe you find in shops, just multiply your result by the globe scale.

  6. Thank you. IF only the trig prof had started the course with this example, I could have then been interested in trig and gotten a better grade.
    G

    btw looking for a co author of book with math and physics background
    🙂
    G

  7. Dan says:

    Yet not once mentioning the haversine formula?

  8. Nathan says:

    Since I never learned any spherical geometry, but have been studying 3D graphics, distance is a problem I would have solved with a dot product, and erecting a (very tall) tower at the cross product would give a great landmark for navigational purposes.

    But math being what it is, I imagine all solutions to this problem are really the same solution, underneath their clothing?

  9. MeNotU says:

    The real question is this; what’s the distance between two points (on the surface of a sphere), through the sphere?

Leave a Reply

Your email address will not be published.