From db8236dbed7d12b988070247dd0e55a2432a7d98 Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 18 Dec 2024 16:36:38 -0700 Subject: [PATCH] spur_gear: fix negative helix angles The helix code previously included an assumption that the angle is positive when calculating the slice count, which caused negative angles to always produce only 1 slice. This fix adds an abs() call around the twist to produce the same slice count for both directions. --- gears.scad | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gears.scad b/gears.scad index dd3a442..2e9c734 100644 --- a/gears.scad +++ b/gears.scad @@ -1013,7 +1013,7 @@ module spur_gear( : assert(false,"atype must be one of \"root\", \"tip\" or \"pitch\""); circum = 2 * PI * pr; twist = 360*thickness*tan(helical)/circum; - slices = default(slices, ceil(twist/360*segs(pr)+1)); + slices = default(slices, ceil(abs(twist)/360*segs(pr)+1)); default_tag("remove", internal) { attachable(anchor,spin,orient, r=anchor_rad, l=thickness) { zrot(gear_spin)