'Name: rhumb-bearing.ave 'Function: Calculate rhumb bearing from one point to another basing on a sphere. 'Author: Maxim Dubinin ' sim@gis-lab.info 'Created 31.05.2006 'Last Update: 26.10.2006 'Notes: This script is also used in Argos-tools (http://gis-lab.info/programs/argos. pnts = SELF pi = 3.14159265358979 lat1 = pnts.get(3)*pi/180 lat2 = pnts.get(2)*pi/180 long1 = -1*pnts.get(1)*pi/180 long2 = -1*pnts.get(0)*pi/180 dlon_W = (long2 - long1) - (2*pi*(((long2 - long1)/(2*pi)).floor)) dlon_E = (long1 - long2) - (2*pi*(((long1 - long2)/(2*pi)).floor)) dphi = ((((lat2/2) + (pi/4)).tan)/(((lat1/2) + (pi/4)).tan)).ln if ((lat2 - lat1).abs < 0.00000001) then q = lat1.cos else q = (lat2 - lat1)/dphi end pi2 = Pi / 2 if (dlon_W < dlon_E) Then dlon_W = -1*dlon_W 'get sign if (dlon_W >= 0) then sign = 1 else sign = -1 end If ((dlon_W.abs) >= (dphi.abs)) Then Atn2 = (sign * pi2) - (dphi / dlon_W).atan Else If (dphi > 0) Then Atn2 = (dlon_W / dphi).atan Else If ((-1*dlon_W) >= 0) Then Atn2 = Pi + (dlon_W / dphi).atan Else Atn2 = (-1*Pi) + (dlon_W / dphi).atan End End End dlon = -1*dlon_W else 'get sign if (dlon_W >= 0) then sign = 1 else sign = -1 end If ((dlon_E.abs) >= (dphi.abs)) Then Atn2 = sign * pi2 - (dphi / (dlon_E)).atan Else If (dphi > 0) Then Atn2 = ((dlon_E) / dphi).atan Else If ((dlon_E) >= 0) Then Atn2 = Pi + ((dlon_E) / dphi).atan Else Atn2 = (-1*Pi) + ((dlon_E) / dphi).atan End End End dlon = dlon_E end tc = atn2 - (2*pi*(((atn2)/(2*pi)).floor)) dist = ((q^2)*(dlon^2) + ((lat2-lat1)^2)).sqrt 'result - angle in degrees tcdeg = (tc*180)/pi 'result - dist in meters distm = dist*6372795 reslist = {tcdeg, distm} return reslist