Angle between two lines

I have need the angle between two lines (negative or positive depends of frist line) and
I use this code to get:

import rhinoscriptsyntax as rs
line1 = rs.GetObject(“LINE1”)
line2 = rs.GetObject(“LINE2”)
line1Start = rs.CurveStartPoint(line1);
line1End = rs.CurveEndPoint(line1);
line2Start = rs.CurveStartPoint(line2);
line2End = rs.CurveEndPoint(line2)
ang1=rs.Angle(line1Start,line1End)
ang2=rs.Angle(line2Start,line2End)
print ang2[0]-ang1[0]

So, rs,angle only return until 0º/180º and -180º /0º, the problem is I have a angle Ex: 170 and other
-170, the return is -340 or 340 , and supose return -20 or 20 depend the frist line:

I try convert this on full 360º but this brings another problem, the 0º position can also be 360º, this generates calculation error.

Any idea

rs.Angle2 returns both angle and reflex angle:

import rhinoscriptsyntax as rs
line1 = rs.GetObject("First line")
line2 = rs.GetObject("Second line")
angle = rs.Angle2(line1, line2)
print 'Angle = {}'.format(angle[0])
print 'Reflex angle = {}'.format(angle[1])

Maybe I didn’t exactly get what else you need.

Thanks for your answer, the Angle2 don’t return negative clock.

1 Like
import rhinoscriptsyntax as rs
line1 = rs.GetObject("First line")
line2 = rs.GetObject("Second line")
start1 = rs.CurveStartPoint(line1)
start2 = rs.CurveStartPoint(line2)
end1 = rs.CurveEndPoint(line1)
angle = rs.Angle2(line1, line2)[0]
print rs.Angle2(line1, line2)[0] * rs.CreatePlane(start1, end1-start1, start2-start1)[3][2]

CounterClockwiseAngle.py (336 Bytes)

Thank you @Mahdiyar