'---------------------------------------------------------------- 'SCRIPT: avu-Line2Azimuth 'PROJECT: gavos.apr, avcsus 'DATE: 03-18-96 'AUTHOR: John Ganter, Sandia National Labs, jganter@sandia.gov 'DESC: converts xy,xy to an azimuth angle 'DESC2: azimuths (0 or 360=North, 180=South, etc.) let you do ' easy trigonometry in any Cartesian quadrant (I to IV). 'CALLED BY: 'CALL AS: av.Run("avu-Line2Azimuth", ) 'ARG01: List: {Ax, Ay, Bx, By} 'RETURNS: number 'EXPECTS: 'CALLS TO: ''''2---------------------------------------------------------------- 'get the coordinates AAx = SELF.Get(0) AAy = SELF.Get(1) BBx = SELF.Get(2) BBy = SELF.Get(3) 'calc the hypoteneuse numH = ( ((BBx - AAx)^2) + ((BBy - AAy)^2) ).Sqrt 'calc angle numOp = (AAx - BBx).Abs angrThe = (numOp / numH).ASin If ( (BBx >= AAx) AND (BBy >= AAy) ) then quad = "NE" angdThe = angrThe.AsDegrees elseif ( (BBx >= AAx) AND (BBy <= AAy) ) then quad = "SE" angdThe = 180 - angrThe.AsDegrees elseif ( (BBx <= AAx) AND (BBy <= AAy) ) then quad = "SW" angdThe = 180 + angrThe.AsDegrees elseif ( (BBx <= AAx) AND (BBy >= AAy) ) then quad = "NW" angdThe = 360 - angrThe.AsDegrees else MsgBox.Error("The arguments are invalid","") end 'MsgBox.Info(quad ++ numH.AsString ++ numOp.AsString ++ angdThe.AsString,"") Return angdThe '----end of script---------------------------------------------------