Uit Hack42
ratchet.scad
module tooth2(base, height, tipl, tiph, width) {
difference() {
intersection() {
translate([-(base+tipl)/2,0,0]) cube([base+tipl,height,width], center = false);
scale(v=[1,(height/(base+tipl))*2,0]) cylinder(r=(base+tipl)/2,h=width, $fs=0.01);
}
translate([-(base/2+tipl/2),0,0])
polyhedron( points = [ [0,0,0],[0,0,width],[0,tiph,0],[0,tiph,width],[tipl,0,0],[tipl,0,width] ],
triangles = [ [1,3,5],[0,4,2],[0,2,1],[2,3,1],[0,1,4],[4,1,5],[2,4,5],[2,5,3] ]);
}
}
//tooth2(7,7,5,5,1);
module ratchet(diam, nrteeth, height, tipl, tiph, width) {
//moves teeth down by this distance
down = diam - diam * cos(180/nrteeth);
//make sure tooth's height is not lower than down movement
/* if (height <= down) {
nheight = down + 0.01;
} else {
nheight = height;
}
*/
// calculate tooth's base
base = 2 * sin(180/nrteeth) * diam;
echo(down);
echo(diam);
union() {
cylinder(h=width,r=diam);
//teeth
for ( i = [0 : (nrteeth-1)] ) {
rotate( i * 360 / nrteeth, [0, 0, 1])
translate([-(0.25*base), (diam-down), 0])
tooth2(base, height, tipl, tiph, width); //height should become nheight
}
}
}
ratchet(10,6,2,5,7,1);