Origin
Latitude : ° ' '' N S Longitude : ° ' '' E W
Destination
Results
Initial Course : ° true Great Circle Distance : kilometers
This calculator computes the great circle distance between two points on the earth's surface.
The program is operated by entering two geographic points and then pressing the Calculate button. The entry form allows you to enter geographic position in degrees, minutes, and seconds. The calculator computes distance in kilometers and also computes the true bearing from the origin to the destination. All entries are cleared by pressing the Clear button.
Return to Contents
The Java Script source code for this program can be viewed by using the View|Source command of your web browser.
You may use or modify this source code in any way you find useful, provided that you agree that the author has no warranty, obligations or liability. You must determine the suitablility of this source code for your use.
A great circle is the intersection of a sphere with a plane passing through the center of the sphere. Arcs of great circles represent the shorest route between two points on the surface of the sphere. The equator is a great circle as are all meridians of longitude.
The great circle distance and bearing between two points can be calculated easily given the latitudes and longitudes of the origin and destination using the following formula from spherical trigonometry:
cos(D) = sin(lata)·sin(latb) + cos(lata)·cos(latb)·cos(lonb - lona) cos(C) = [sin(latb) - sin(lata)·cos(D)] / [cos(lata)·sin(D)] a - origin b - destination D = angular distance along path C = true bearing from the the origin to the destination measured from north. If the value for sin(lonb - lona) is positive; otherwise, the true bearing is 360° - C.
cos(D) = sin(lata)·sin(latb) + cos(lata)·cos(latb)·cos(lonb - lona)
cos(C) = [sin(latb) - sin(lata)·cos(D)] / [cos(lata)·sin(D)]
a - origin
b - destination
D = angular distance along path
C = true bearing from the the origin to the destination measured from north. If the value for sin(lonb - lona) is positive; otherwise, the true bearing is 360° - C.
In applying the above formula, south latitudes and west longitudes are treated as negative angles. Note: When the origin is exactly at a pole, the bearing or course to the destination cannot be determined, why?
The formulas above assume that the earth is spherical. To obtain more accurate distances, this calculator implements a method shown in chapter 10 of [1]. I've used the WGS 1984 parameters for the earth's equatorial radius and ellipsoid flattening given in [2].
AbCd Classics - free on-line books