Hi there programmers, I am trying to write as part of a package a routine that will find bearing and distance from a given latitude and longitude.
I have found this formula but am unable to make it work, is there anybody out there who maybe able to help me with this problem?
Thanks Chris
minchin@mailme.ae
Worked Examples:
Suppose point 1 is LAX: (33deg 57min N, 118deg 24min W)
Suppose point 2 is JFK: (40deg 38min N, 73deg 47min W)
In radians LAX is
lat1=(33+57/60)*pi/180=0.592539, lon1=(118+24/60)*pi/180=2.066470
and JFK is
(lat2=0.709186,lon2=1.287762)
The distance from LAX to JFK is
d = 2*asin(sqrt((sin((lat1-lat2)/2))^2+
cos(lat1)*cos(lat2)*(sin((lon1-lon2)/2)^2))
= 2*asin(sqrt((sin(0.592539-0.709186)/2))^2+
cos(0.592539)*cos(0.709186)*(sin((2.066470-1.287762)/2)^2))
= 2*asin(sqrt((-0.05829)^2 +0.829525*0.758893*0.379591^2))
= 2*asin(0.306765)
= 0.623585 radians
= 0.623585*180*60/pi=2144nm
or
d = acos(sin(lat1)*sin(lat2)+cos(lat1)*cos(lat2)*cos(lon1-lon2))
= acos(sin(0.592539)*sin(0.709186)+
cos(0.592539)*cos(0.709186)*cos(0.778708))
= acos(0.811790)
= 0.623585 radians
= 0.623585*180*60/pi=2144nm