2
Calculate distance, bearing and more between two l Distance This page helps you to calculate great-circle distances between two points The formula assumes that the earth is a sphere, (we know that it is "egg" s Enter the coordinates into the text boxes to try it out. It accepts a varie deg-min-sec suffixed with N/S/E/W (e.g. 40°44′55″N, 73 59 11W), or signed decimal degrees without compass direction, where negative indic Lat 1: Long 1: Lat 2: Long 2: And you can see it on a map (thanks to Google Maps) Haversine formula: R = earth’s radius (mean radius = 6,371km) Δlat = lat 2 − lat 1 Δlong = long 2 − long 1 a = sin²(Δlat/2) + cos(lat 1 ).cos(lat 2 ).sin²(Δlong/2) c = 2.atan2(√a, √(1−a)) d = R.c (Note that angles need to be in radians to pass to trig functions). The Haversine formula remains particularly well-conditioned for numerical computation even at small distances Spherical law of cosines: d = acos(sin(lat 1 ).sin(lat 2 )+cos(lat 1 ).cos(lat 2 ).cos(long 2 −long 1 )) R

Calculate Distance & Bearing

Embed Size (px)

DESCRIPTION

Calculate Distance & Bearing

Citation preview

Calculate distance, bearing and more between two latitude/longitude points

Top of FormDistanceThis page helps you to calculate great-circle distances betweentwo pointsusing the Haversine formula.The formula assumes that theearth is a sphere, (we know that it is "egg" shaped) but it is accurate enough*for our purposes.Enter the coordinates into the text boxes to try it out. It accepts a variety of formats: deg-min-sec suffixed with N/S/E/W (e.g. 404455N, 73 59 11W), or signed decimal degrees without compass direction, where negative indicates west/south (e.g. 40.7486, -73.9864):Lat 1:Long 1:Lat 2:Long 2:And you cansee it on a map(thanks to Google Maps)Haversine formula:R = earths radius (mean radius = 6,371km)lat = lat2 lat1long = long2 long1a = sin(lat/2) + cos(lat1).cos(lat2).sin(long/2)c = 2.atan2(a, (1a))d = R.c(Note that angles need to be in radians to pass to trig functions).

TheHaversineformula remains particularly well-conditioned for numerical computation even at small distances

Spherical lawof cosines:d = acos(sin(lat1).sin(lat2)+cos(lat1).cos(lat2).cos(long2long1)).R

Excel:=ACOS(SIN(Lat1)*SIN(Lat2)+COS(Lat1)*COS(Lat2)*COS(Lon2-Lon1))*6371

BearingFormula: =atan2(sin(long).cos(lat2),cos(lat1).sin(lat2) sin(lat1).cos(lat2).cos(long) )

Since atan2 returns values in the range - ... +, to normalise the result to a compass bearing, multiply by 180/ then use (+360) % 360, where % is modulo.This is the initial bearing which if followed in a straight line along a great-circle arcwill take you from the start point to the end point; in general, the bearing you are following will have varied by the time you get to the end pointFor final bearing, take the initial bearing from the end point to the start point and reverse it (using = (+180) % 360).

MidpointFormula:Bx = cos(lat2).cos(long)By = cos(lat2).sin(long)latm= atan2(sin(lat1) + sin(lat2), ((cos(lat1)+Bx) + By))lonm= lon1+ atan2(By, cos(lat1)+Bx)

Just as the initial bearing may vary from the final bearing, the midpoint may not be located half-way between latitudes/longitudes.Bottom of Form