Uit Hack42
ratchet.scad
module tooth(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 = 0.01 + (diam - diam * cos(180/nrteeth)); //make sure tooth's height is not lower than down movement if (height <= down) { ratchet2(diam, nrteeth, down, tipl, tiph, width, down); } else { ratchet2(diam, nrteeth, height, tipl, tiph, width, down); } } module ratchet2(diam, nrteeth, height, tipl, tiph, width, down) { // calculate tooth's base base = 2 * sin(180/nrteeth) * 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-2*down), 0]) // check the .25 tooth(base, height, tipl, tiph, width); } } } ratchet(10,6,3,5,7,1); |