One approach would be to make the following assumptions:
- The earth is a sphere.
- We are interested in the distance along the earth's surface.
- Altitude can be ignored.
- The distance from the equator to either pole is 10,000 km.
If we have two points A and B, with coordinates
then we can use a 3 dimensional version of the Pythagorean theorem to determine (d) the straight-line distance between the points using the equation:
We let the angle between the points be
Looking at the diagram above we can see that:
Now it is time to try out some numbers:
Inputs | ||
Latitude | Longitude | |
Point A | ||
Point B | ||
| ||
Result | ||
Distance | 2,925.18 | km |
If you change one of the inputs above and hit enter, then the result will be updated.
The latitude figures are degrees north of the equator. For degrees south, use a negative.
The longitude figures are the degrees west of the prime meridian. For degrees east use a negative number.
If you're interested in the javascript code used to do the calculation, then have a look at this in github.
An alternative approach is to use the Haversine formula.
No comments:
Post a Comment