Version: 1.0
Type: Function
Category: Algorithms
License: BSD License
Description: Determines the distance in miles between two latitude/longitude pairs (in degrees) with a slightly modified Haversine formula (from R.W. Sinnott, “Virtues of the Haversine”,
Sky and Telescope, vol. 68, no. 2, 1984, p. 159). See http://earth.uni-muenster.de/~eicksch/GMT-Help/msg00147.html for more info. It was modified for speed.
# Where: # $l1 ==> latitude1 # $o1 ==> longitude1 # $l2 ==> latitude2 # $o2 ==> longitude2 function haversine ($l1, $o1, $l2, $o2) { $l1 = deg2rad ($l1); $sinl1 = sin ($l1); $l2 = deg2rad ($l2); $o1 = deg2rad ($o1); $o2 = deg2rad ($o2); return (7926 - 26 * $sinl1) * asin (min (1, 0.707106781186548 * sqrt ((1 - (sin ($l2) * $sinl1) - cos ($l1) * cos ($l2) * cos ($o2 - $o1))))); }