From f2b7d863af920df9e2afaf16fb4a0b81d3c5d431 Mon Sep 17 00:00:00 2001 From: Roy-043 <70520633+Roy-043@users.noreply.github.com> Date: Mon, 5 Jul 2021 10:12:48 +0200 Subject: [PATCH] Draft: fix geometry.py findDistance function The findDistance function did not work properly for arcs that crossed the 9 o'clock point. --- src/Mod/Draft/draftgeoutils/geometry.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Mod/Draft/draftgeoutils/geometry.py b/src/Mod/Draft/draftgeoutils/geometry.py index 099fde42c9..0ead657198 100644 --- a/src/Mod/Draft/draftgeoutils/geometry.py +++ b/src/Mod/Draft/draftgeoutils/geometry.py @@ -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