Draft: fix geometry.py findDistance function

The findDistance function did not work properly for arcs that crossed the 9 o'clock point.
This commit is contained in:
Roy-043
2021-07-05 10:12:48 +02:00
committed by Bernd Hahnebach
parent 1d439ce0a6
commit f2b7d863af

View File

@@ -165,11 +165,17 @@ def findDistance(point, edge, strict=False):
return None
if strict and ve2:
# Note 1: DraftVecUtils.angle(App.Vector(1, 1, 0)) => -0.7854
# Note 2: Angles are in the +pi to -pi range.
ang1 = DraftVecUtils.angle(ve1.sub(center))
ang2 = DraftVecUtils.angle(ve2.sub(center))
angpt = DraftVecUtils.angle(newpoint.sub(center))
if ((angpt <= ang2 and angpt >= ang1)
or (angpt <= ang1 and angpt >= ang2)):
if ang1 >= ang2: # Arc does not cross the 9 o'clock point.
if ang1 >= angpt and angpt >= ang2:
return dist
else:
return None
elif ang1 >= angpt or angpt >= ang2:
return dist
else:
return None