English

# How To: Calculate an azimuth in degrees

## Summary

The sample script in this article measures the azimuth in degrees between two point locations.

## Procedure

`Code:Private Function ReturnAzimuth(pt1 As MapObjects2.Point, _                               pt2 As MapObjects2.Point) _                               As Double'-- Enter two points.  Function returns the azimuth'-- in degrees from Point 1 to Point 2.  Dim x1 As Double, y1 As Double  Dim x2 As Double, y2 As Double  x1 = pt1.X  y1 = pt1.Y  x2 = pt2.X  y2 = pt2.Y  Select Case True    Case ((x1 = x2) And (y1 < y2))      ReturnAzimuth = 0    Case ((x1 = x2) And (y1 > y2))      ReturnAzimuth = 180    Case ((y1 = y2) And (x1 < x2))      ReturnAzimuth = 90    Case ((y1 = y2) And (x1 > x2))      ReturnAzimuth = 270    Case ((x1 < x2) And (y1 < y2))      ReturnAzimuth = 180 * ((Atn(Abs(x1 - x2) / Abs(y1 - y2))) / 3.14159)    Case ((x1 < x2) And (y1 > y2))      ReturnAzimuth = 180 * ((Atn(Abs(y1 - y2) / Abs(x1 - x2))) / 3.14159) + 90    Case ((x1 > x2) And (y1 > y2))      ReturnAzimuth = 180 * ((Atn(Abs(x1 - x2) / Abs(y1 - y2))) / 3.14159) + 180    Case ((x1 > x2) And (y1 < y2))      ReturnAzimuth = 180 * ((Atn(Abs(y1 - y2) / Abs(x1 - x2))) / 3.14159) + 270  End SelectEnd Function`