From a1117040b3697483bc0b641a3fff0194818300bc Mon Sep 17 00:00:00 2001 From: Markus Lampert Date: Tue, 22 Feb 2022 19:52:00 -0800 Subject: [PATCH] Changed passes for constant tool engagement --- src/Mod/Path/PathScripts/PathThreadMilling.py | 22 ++++++++++++++++--- .../Path/PathTests/TestPathThreadMilling.py | 8 +++---- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathThreadMilling.py b/src/Mod/Path/PathScripts/PathThreadMilling.py index 7e49e1ffba..5dea982a93 100644 --- a/src/Mod/Path/PathScripts/PathThreadMilling.py +++ b/src/Mod/Path/PathScripts/PathThreadMilling.py @@ -74,11 +74,27 @@ def threadRadii(internal, majorDia, minorDia, toolDia, toolCrest): def threadPasses(count, radii, internal, majorDia, minorDia, toolDia, toolCrest): PathLog.track(count, radii, internal, majorDia, minorDia, toolDia, toolCrest) + # the logic goes as follows, total area to be removed: + # A = H * W ... where H is the depth and W is half the width of a thread + # H = k * sin(30) = k * 1/2 -> k = 2 * H + # W = k * cos(30) = k * sqrt(3)/2 + # -> W = (2 * H) * sqrt(3) / 2 = H * sqrt(3) + # A = sqrt(3) * H^2 + # Each pass has to remove the same area + # An = A / count = sqrt(3) * H^2 / count + # Because each successive pass doesn't have to remove the aera of the previous + # passes the result for the height: + # Ai = (i + 1) * An = (i + 1) * sqrt(3) * Hi^2 = sqrt(3) * H^2 / count + # Hi = sqrt(H^2 * (i + 1) / count) + # Hi = H * sqrt((i + 1) / count) minor, major = radii(internal, majorDia, minorDia, toolDia, toolCrest) - dr = float(major - minor) / count + H = float(major - minor) + Hi = [H * math.sqrt((i + 1) / count) for i in range(count)] + PathLog.debug("threadPasses({}, {}) -> H={} : {}".format(minor, major, H, Hi)) + if internal: - return [minor + dr * (i + 1) for i in range(count)] - return [major - dr * (i + 1) for i in range(count)] + return [minor + h for h in Hi] + return [major - h for h in Hi] def elevatorRadius(obj, center, internal, tool): diff --git a/src/Mod/Path/PathTests/TestPathThreadMilling.py b/src/Mod/Path/PathTests/TestPathThreadMilling.py index d393492b81..5823bd23c6 100644 --- a/src/Mod/Path/PathTests/TestPathThreadMilling.py +++ b/src/Mod/Path/PathTests/TestPathThreadMilling.py @@ -57,8 +57,8 @@ class TestPathThreadMilling(PathTestBase): def test10(self): '''Verify internal thread passes.''' self.assertList(PathThreadMilling.threadPasses(1, radii, True, 10, 9, 0, 0), [10]) - self.assertList(PathThreadMilling.threadPasses(2, radii, True, 10, 9, 0, 0), [9.5, 10]) - self.assertList(PathThreadMilling.threadPasses(5, radii, True, 10, 9, 0, 0), [9.2, 9.4, 9.6, 9.8, 10]) + self.assertList(PathThreadMilling.threadPasses(2, radii, True, 10, 9, 0, 0), [9.707107, 10]) + self.assertList(PathThreadMilling.threadPasses(5, radii, True, 10, 9, 0, 0), [9.447214, 9.632456, 9.774597, 9.894427, 10]) def test20(self): '''Verify external radii.''' @@ -72,8 +72,8 @@ class TestPathThreadMilling(PathTestBase): def test30(self): '''Verify external thread passes.''' self.assertList(PathThreadMilling.threadPasses(1, radii, False, 10, 9, 0, 0), [9]) - self.assertList(PathThreadMilling.threadPasses(2, radii, False, 10, 9, 0, 0), [9.5, 9]) - self.assertList(PathThreadMilling.threadPasses(5, radii, False, 10, 9, 0, 0), [9.8, 9.6, 9.4, 9.2, 9]) + self.assertList(PathThreadMilling.threadPasses(2, radii, False, 10, 9, 0, 0), [9.292893, 9]) + self.assertList(PathThreadMilling.threadPasses(5, radii, False, 10, 9, 0, 0), [9.552786, 9.367544, 9.225403, 9.105573, 9]) def test40(self): '''Verify thread commands for a single thread'''