/* include */ module ccube(x, y, z) { cube([x, y, z], center=true); } module ccyldr(r, h) { cylinder(r=r, h=h, center=true); } module ccone(rb, h, rt) { cylinder(h, rb, rt, center=true); } module csquare(x, y) { square([x, y], center=true); } module gear(n, r, t,) { radii = [0.995*r-t, 0.995*r+0.10*t, 0.995*r+t, 0.995*r+t, 0.995*r+0.10*t, 0.995*r-t]; num = n*len(radii); // len(radii) = 6 function r(a) = (floor(a/ 10) % 2) ? 10:8; polygon([ for (i=[0:num-1], a=i*360/num, r=radii[i%len(radii)]) [r*cos(a), r*sin(a)] ]); } module bevelgear(xtr, r, n, t) { intersection() { linear_extrude(xtr, scale=(r-xtr)/r, center=true, convexity=3) gear(n, r, t); rotate([180, 0, 0]) ccone(r-(1.3*sqrt(2))+xtr, xtr+t/2, r-(t*sqrt(2))-t/2); }} module rectchamfer(ch, sqx, sqy, off) { linear_extrude(+ch, scale=[(1-2/sqx*ch), (1-2/sqy*ch)]) offset(off) square([sqx, sqy], center=true); } module elliptogon(n, R, r) { rotate([0, 0, 360/n/4]) polygon([ for(i = [0:2:360]) [R*sin(i)+r*cos((n-1)*i), R*cos(i)+r*sin((n-1)*i)], ]); } module ring(r, h) { rotate_extrude() translate([r, 0]) csquare(h, h); } // Cylinder with filet at foot module cylfoot(r, o, h) { difference() { cylinder(r=r+o, h=h); rotate_extrude() offset(o) translate([r+o, o]) square([1, h-o]); }} module bbearg(ir, rotshaft) scale([ir/10, ir/10, ir/10]) { // Inner race rotate([0, 0, 0]) rotate_extrude() difference() { translate([10*(1+1.5/10), 0]) offset(1) csquare(1, 6); translate([10+4.5, 0]) circle(2.5); } // Outer race rotate([0, 0, -$t*rotshaft]) rotate_extrude() difference() { translate([10*(1+7.5/10), 0]) offset(1) csquare(1, 6); translate([10+4.5, 0]) circle(2.5); } // Balls rotate([0, 0, -0.5*$t*rotshaft]) for (i=[0:11]) rotate(i*360/12) translate([10*(1+4.5/10), 0]) sphere(2.5); } module rbearg(ir, rotshaft) scale([ir/10, ir/10, ir/10]) { // Inner race rotate([0, 0, 0]) rotate_extrude() difference() { translate([11.6, 0]) offset(1) csquare(1.2, 6); translate([13.15, 0]) csquare(2, 5); } // Outer race rotate([0, 0, -$t*rotshaft]) rotate_extrude() difference() { translate([17.4, 0]) offset(1) csquare(1.2, 6); translate([15.85, 0]) csquare(2, 5); } // Rollers rotate([0, 0, -0.5*$t*rotshaft]) for (i=[0:11]) rotate(i*360/12) translate([14.5, 0]) { rotate_extrude() translate([2.7/2, 0]) offset(0.3) csquare(2.0-0.6, 5-0.6); ccyldr(1, 5); }}