MapBasic Code. Copy/Paste if needed.
|
include "GC_Coordinates.def" '====================================================================== sub GreatCircleCoords ( byval fLon0 as float, 'Origin longitude byval fLat0 as float, 'Origin latitude byval fAzimuth as float, 'Azimuth byval fDistance as float, 'Distance byval fRadius as float, 'Radius of sphere fLon1 as float, 'Destination longitude fLat1 as float) 'Destination latitude 'Calculates lat/lon coords from origin, azimuth and distance from 'origin. Returned coordinates are in decimal degrees. fDistance and 'fRadius must be in the same units. '---------------------------------------------------------------------- dim c as float dim lat0, lon0 as float dim Az as float dim a, b as float 'convert to radians Az = fAzimuth * DEG2RAD lat0 = fLat0 * DEG2RAD lon0 = fLon0 * DEG2RAD 'calculate great circle arc for this distance c = ((fDistance / (2 * PI * fRadius)) * 360.0) * DEG2RAD fLat1 = asin( sin(lat0) * cos(c) + cos(lat0) * sin(c) * cos(Az)) * RAD2DEG a = sin(c) * sin(Az) b = cos(lat0) * cos(c) - sin(lat0) * sin(c) * cos(Az) if b = 0 then fLon1 = fLon0 exit sub end if fLon1 = fLon0 + atn(a/b) * RAD2DEG end sub |