revarbat / BOSL

The Belfry OpenScad Library - A library of tools, shapes, and helpers to make OpenScad easier to use.
https://github.com/revarbat/BOSL/wiki
BSD 2-Clause "Simplified" License
571 stars 62 forks source link

pitch_radius for beveled gears #68

Open Equidamoid opened 4 years ago

Equidamoid commented 4 years ago

Is your feature request related to a problem? Please describe. I want to use beveled gears. How do I space them? pitch_radius doesn't support bevelang argument and without it the gears are too far apart.

Describe the solution you'd like Extend pitch_radius to support beveled gears. The obvious offset:

diff --git a/involute_gears.scad b/involute_gears.scad
index 66eddfb..45e07a2 100644
--- a/involute_gears.scad
+++ b/involute_gears.scad
@@ -91,8 +91,8 @@ function dedendum(mm_per_tooth=5, clearance=undef) =
 // Arguments:
 //   mm_per_tooth = Distance between teeth around the pitch circle, in mm.
 //   number of teeth = The number of teeth on the gear.
-function pitch_radius(mm_per_tooth=5, number_of_teeth=11) =
-       mm_per_tooth * number_of_teeth / PI / 2;
+function pitch_radius(mm_per_tooth=5, number_of_teeth=11, bevelang=0, thickness=0) =
+       mm_per_tooth * number_of_teeth / PI / 2 - sin(bevelang) * thickness / 2;

 // Function: outer_radius()

seems to produce something that looks reasonable in preview, but I have no clue about the proper way to calculate this offset.

Need someone who knows the gear kung-fu to check the formula.

Describe alternatives you've considered Don't see reasonable alternatives.

Example Code

union() {
    gear(bevelang = 45, hole_diameter = 6, mm_per_tooth = 3, number_of_teeth = 30, thickness = 3.5000000000);
    translate(v = [
    pitch_radius(bevelang = 45, hole_diameter = 6, mm_per_tooth = 3, number_of_teeth = 30, thickness = 3.5000000000), 0, 
    pitch_radius(bevelang = 45, hole_diameter = 1, mm_per_tooth = 3, number_of_teeth = 10, thickness = 3.5000000000)]) {
        rotate(a = [0, -90, 0]) {
            gear(bevelang = 45, hole_diameter = 1, mm_per_tooth = 3, number_of_teeth = 10, thickness = 3.5000000000);
        }
    }
}
revarbat commented 4 years ago

It has become apparent to me recently that beveled gears in BOSL1 are just plain broken. I finally got them fixed in BOSL2, but back porting it to BOSL1 will be a pain.