From ac6cc1977561a8e3c84972fff601f3d02ced3b1b Mon Sep 17 00:00:00 2001 From: Adrian Mariano Date: Tue, 8 Aug 2023 19:33:03 -0400 Subject: [PATCH] fix backlash for gear_dist on internal gears --- gears.scad | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gears.scad b/gears.scad index eab8a1b..aef65a6 100644 --- a/gears.scad +++ b/gears.scad @@ -3233,6 +3233,7 @@ function gear_dist( assert(teeth1>0 || teeth2>0, "One of the teeth counts must be nonzero") assert(is_bool(internal1)) assert(is_bool(internal2)) + assert(is_finite(helical)) assert(!(internal1&&internal2), "Cannot specify both gears as internal") assert(!(internal1 || internal2) || (teeth1>0 && teeth2>0), "Cannot specify internal gear with rack (zero tooth count)") let( @@ -3254,7 +3255,8 @@ function gear_dist( pa_eff = _working_pressure_angle(teeth1,profile_shift1,teeth2,profile_shift2,pressure_angle,helical), pa_transv = atan(tan(pressure_angle)/cos(helical)) ) - mod*(teeth1+teeth2)*cos(pa_transv)/cos(pa_eff)/cos(helical)/2 + backlash*cos(helical)/tan(pressure_angle); + mod*(teeth1+teeth2)*cos(pa_transv)/cos(pa_eff)/cos(helical)/2 + + (internal1||internal2?-1:1) * backlash*cos(helical)/tan(pressure_angle); function _invol(a) = tan(a) - a*PI/180;