use <gears/gears.scad>

// Am oberen Brett befestigter Zahnkranz (TODO: 206 oder 201 Zähne?)
module zahnkranz(tooth_number, laser_h, gear_modul = 0.5) {
  screw_d = 3;
  rim_width = 8;
  screw_a = gear_modul * (tooth_number + 77 / 30) / 2 + rim_width / 2;

  difference() {
    ring_gear(modul = gear_modul, tooth_number = tooth_number, width = laser_h,
              rim_width = rim_width);
    translate([ screw_a, 0, 0 ]) cylinder(d = screw_d, h = laser_h);
    translate([ -screw_a, 0, 0 ]) cylinder(d = screw_d, h = laser_h);
    translate([ 0, screw_a, 0 ]) cylinder(d = screw_d, h = laser_h);
    translate([ 0, -screw_a, 0 ]) cylinder(d = screw_d, h = laser_h);

    translate([ 1 / sqrt(2) * screw_a, 1 / sqrt(2) * screw_a, 0 ])
        cylinder(d = screw_d, h = laser_h);
    translate([ 1 / sqrt(2) * screw_a, -1 / sqrt(2) * screw_a, 0 ])
        cylinder(d = screw_d, h = laser_h);
    translate([ -1 / sqrt(2) * screw_a, 1 / sqrt(2) * screw_a, 0 ])
        cylinder(d = screw_d, h = laser_h);
    translate([ -1 / sqrt(2) * screw_a, -1 / sqrt(2) * screw_a, 0 ])
        cylinder(d = screw_d, h = laser_h);
  }
}