# Determine the angle between two intersecting lines - Counter-Clockwise direction

Question asked by jdavid05 on Aug 2, 2016
Latest reply on Aug 2, 2016 by jdavid05

Hey everyone:

I am trying to determine the angle between two intersecting lines. However, I need the angle to be from the start point of line1 to the start- or end-point of line2 - whichever is the next point going in a counter-clockwise direction around the circle's perimeter (see diagram at bottom of question).

My steps so far have been:

1) I found the intersection points and saved them to a point file

2) I created a 10cm buffer around the points (0.1 metres)

3) I clipped line1 and line2 to the buffer

4) I calculated the start- and end-points of line1 and line2 as:

with arcpy.da.UpdateCursor("line", ('X0a','Y0a','X1a','Y1a', "SHAPE@")) as cursor:

for row in cursor:

row = row.firstPoint.X

row = row.firstPoint.Y

row = row.lastPoint.X

row = row.lastPoint.Y

cursor.updateRow(row)

5) I created separate fields and calculated their values as:

dx = !X1a!-!X0a!

dy = !Y1a!-!Y0a!

dxa= !X1b!-!X0b!

dya= !Y1b!-!Y0b!

r = math.sqrt(math.pow(!dx!, 2) + math.pow(!dy!, 2))

ra = math.sqrt(math.pow(!dxa!, 2) + math.pow(!dya!, 2))

c = math.asin(abs((dxdya - dydxa))/(r*ra)) / math.pi * 180

c is the angle between the points, however, it is not always the angle I need. I need the angle from a point on line1 to the nearest point on line2 going counter-clockwise around the circle's perimeter.

There is probably a really easy  solution for this, but, I just haven't been able to figure it out. Any help is greatly appreciated.

I am using ArcGIS 10.2. 