For 2D or 3D Cartesian coordinate systems, there are simple formulas based on the Pythagorean theorem that allow one to calculate distance between two points. But what if the surface is curved, like that of the Earth? In other words, how do you get the shortest distance between two cities along the surface of the planet?
Instead of x and y coordinates, the only inputs needed are the cities’ latitudes and longitudes in radians.
If city A has (latitude, longitude) of (Φ1 , λ1 ) while city B is
(Φ2 , λ2), the distance, c , between them is given by:
where r = radius of the Earth = an average of 6371 km. (The latitudes and longitudes are normally given in degrees but they can be easily converted by multiplying each by (π/180).)
If there is a third city, how do we get the area of a triangle on a spherical surface?
This involves a few steps. (1) First calculate a and b in the same way we got c by using the appropriate latitudes and longitudes. (2) For each of the three arc lengths, a, b and c—they are arcs effectively because they are on a curved surface—get corresponding central angles in radians. How? If you imagine the vertex of an angle, θ, at a center of the earth, that angle is the same fraction of 2π radians as the arc length is of the circumference. Thus for example, θc/(2π) = c/(2πr), which simplifies to θc = c/r.
(3) Use the following formulas to get the triangle’s angles A , B and C.
(4) The sum of the triangle’s angles on a spherical surface exceeds 180 degrees or π radians. And it turns out that the triangle’s area, T, is directly proportional to the excess, E:
E = A + B + C – π
and T = Er2
We can try an example with Miami=A= (25.76o, 80.19o) = (0.4496R, 1.400R) Montreal = B = ( 45.50o,73.57o) = (0.794, 1.284) , and Rome = (41.90o, -12.50o) = (0.731, -0.2182).
The Montreal-Miami distance =
a = Montreal-Rome distance = 6582 km and b = Rome-Miami distance = 8340 km
θa = a/r = 6582 km/6371 km = 1.033;
θb = b/r = 8340 km/6371 km = 1.309;
θc = c/r = 2273 km/6371 km = 0.35677.
similarly B = 2.40 and C = 0.2469.
E = A + B + C – π = 0.14957
area =T = 0.14957( 6371 km)2 = 6 070 884 km2
There are online apps which do all this for you automatically. I checked the above numbers and they agree closely with those of https://app.measuremaponline.com/ as can be seen from this screen capture:
The area is about 14% bigger than if one assumed that the triangle was on a flat surface, in which case Hero’s formula would apply.
If you don’t appreciate formulas coming out of the blue and are familiar with multivariable calculus, we have been dealing with the “great circle distance” between any to points on Earth. The above formulas are based on the fact that latitudes and longitude angles are related to spherical coordinates. These are very useful to represent points anywhere on a sphere.
Instead of using (x, y, z), we represent a point with (ρ, θ, φ), where ρ is the point’s distance from the center of a sphere. Since we are dealing with the surface of the Earth, in our case ρ will correspond to its radius. θ is related to longitude, but it does not make use of east and west. It measures the angle from the x axis in the xy plane. In the Earth’s case we will imagine the positive x-axis passing through the point where the prime meridian (Greenwich, England) intersects the equator. In essence to convert longitude to θ, we will subtract the longitude from 360o and then convert it to radians with factor π /180. If a longitude is in the Eastern hemisphere, we assign its number a negative before plugging it into the same formula
θ = (360o – longitude)*π /180.
φ is analogous to latitude. But instead of using North and South, we subtract latitudes from 90o and convert to radians again. φ = (90o – latitude)*π /180.
In other words, φ is the angle that deviates from the z axis which runs through the poles. The North pole is at 0o while its antipode is at 180o In other words we assign any southern latitude a negative value.
Using basic trigonometry and those definitions, it is easy to relate spherical coordinates to Cartesian ones.
Using the Earth’s radius and each city’s longitude and latitude, by using the conversion formulas and the x, y, z equivalents we can up with coordinates for them For example, Montreal is at
|x= 1263.596845||y= -4284.304699||z= 4545.677646|
while Miami is at:
If we imagine a vector starting from the center of the Earth to each city, each vector will have the the same components as the coordinates of its point on the surface. Then all we have to do is get the angle,Ψ, formed by the vectors from the dot product relationship:
<x1,y1,z1> . <x2,y2,z2> = |x1,y1,z1||x2,y2,z2|cos Ψ
If your linear algebra is rusty, we can easily compute the left hand side with x1x2 +y1y2 + z1z2. Meanwhile the vertical bars denote the length of a vector. In this case both are 6373 km, the radius of the Earth. Solving for Ψ we obtain 0.3567 radians, which through the relationship arc length = rΨ = 2274 km, essentially the same distance we obtained earlier.