Compare commits

...

2 commits

Author SHA1 Message Date
adrianVmariano
a95916b39e
Merge pull request #1530 from xloem/gears
spur_gear: fix negative helix angles
2024-12-18 21:17:02 -05:00
John Doe
db8236dbed 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.
2024-12-18 16:36:38 -07:00

View file

@ -1013,7 +1013,7 @@ module spur_gear(
: assert(false,"atype must be one of \"root\", \"tip\" or \"pitch\""); : assert(false,"atype must be one of \"root\", \"tip\" or \"pitch\"");
circum = 2 * PI * pr; circum = 2 * PI * pr;
twist = 360*thickness*tan(helical)/circum; 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) { default_tag("remove", internal) {
attachable(anchor,spin,orient, r=anchor_rad, l=thickness) { attachable(anchor,spin,orient, r=anchor_rad, l=thickness) {
zrot(gear_spin) zrot(gear_spin)