// (c)2013 Felipe Sanches // licensed under the terms of the GNU GPL version 3 (or later) function normalize(v) = v/(sqrt(v[0]*v[0] + v[1]*v[1])); module voronoi(points, L=200, thickness=1, round=6, nuclei=true){ for (p=points){ difference(){ minkowski(){ intersection_for(p1=points){ if (p!=p1){ translate((p+p1)/2 - normalize(p1-p) * (thickness+round)) assign(angle=90+atan2(p[1]-p1[1], p[0]-p1[0])){ rotate([0,0,angle]) translate([-L,-L]) square([2*L, L]); } } } circle(r=round, $fn=20); } if (nuclei) translate(p) circle(r=1, $fn=20); } } } module random_voronoi(n=20, nuclei=true, L=200, thickness=3, round=6, min=0, max=100, seed=42){ x = rands(min, max, n, seed); y = rands(min, max, n, seed+1); for (i=[0:n-1]){ difference(){ minkowski(){ intersection_for(j=[0:n-1]){ if (i!=j){ assign(p=[x[i],y[i]], p1=[x[j],y[j]]){ translate((p+p1)/2 - normalize(p1-p) * (thickness+round)) assign(angle=90+atan2(p[1]-p1[1], p[0]-p1[0])){ rotate([0,0,angle]) translate([-L,-L]) square([2*L, L]); } } } } circle(r=round, $fn=20); } if (nuclei) translate([x[i],y[i]]) circle(r=1, $fn=20); } } } // Some nice voronoi patterns //translate([-50, -120, 0]) random_voronoi(n=64, round=6, min=0, max=300, nuclei=false); //random_voronoi(n=64, L=20, round=1, min=0, max=50, nuclei=false); module legs(length, width, depth=7/16, pad=2, 3D=false){ offset = 1.3; difference(){ union(){ difference(){ union(){ square([length-pad+1, width-pad+1], true); translate([offset* length, 0]) square([length-pad+1, width-pad+1], true);} translate([-5, -15, 0]) random_voronoi(n=64, L=20, thickness=.3, round=.6, min=0, max=30, nuclei=false); } union(){ border(length, width, pad); translate([offset*length, 0]) border(length, width, pad); } } // Joint stuff here joint_height = depth*4; right = (length-pad/2)/2; left = -(length-pad/2)/2; for ( i = [-40 : 8 : 40] ){ translate([right, depth*i]) side_joint(depth, joint_height); translate([left, depth*i]) rotate([0, 180, 0]) side_joint(depth,joint_height); } for ( i = [-40 : 8 : 40] ){ translate([offset*length+right, depth*i+joint_height]) side_joint(depth, joint_height); translate([offset*length+left, depth*i+joint_height]) rotate([0, 180, 0]) side_joint(depth,joint_height); } } } module legs_3D(length, width, depth=7/16, pad=2){ offset = 1.3; difference(){ union(){ difference(){ union(){ square([length-pad+1, width-pad+1], true); translate([offset* length, 0]) square([length-pad+1, width-pad+1], true);} translate([-5, -15, 0]) random_voronoi(n=64, L=20, thickness=.3, round=.6, min=0, max=30, nuclei=false); } union(){ border(length, width, pad); translate([offset*length, 0]) border(length, width, pad); } } // Joint stuff here joint_height = depth*4; right = (length-pad/2)/2; left = -(length-pad/2)/2; * for ( i = [-40 : 8 : 40] ){ translate([right, depth*i]) side_joint(depth, joint_height); translate([left, depth*i]) rotate([0, 180, 0]) side_joint(depth,joint_height); } * for ( i = [-40 : 8 : 40] ){ translate([offset*length+right, depth*i+joint_height]) side_joint(depth, joint_height); translate([offset*length+left, depth*i+joint_height]) rotate([0, 180, 0]) side_joint(depth,joint_height); } } } module border(length, width, pad=2){ difference(){ square([length, width], true); square([length-pad, width-pad], true); } } // module side_joint(thickness, padding, joint_length, bit_size=.5){ module side_joint(thickness, joint_length, bit_size=.5){ r = bit_size/2; union(){ translate([0,+r]) circle(r, $fn=50); translate([0, joint_length-r]) circle(r, $fn=50); square([2*thickness, joint_length]); } } module top(side, pad=2){ difference(){ square([side, side], center=true); *union(){ thickness = 7/16; joint_height = thickness*4; translate([side/2-thickness, thickness*4]) side_joint(thickness, pad, joint_height); rotate([180, 180])translate([side/2-thickness, thickness*4]) side_joint(thickness, pad, joint_height); rotate([0, 180]) translate([side/2-thickness, thickness*4]) side_joint(thickness, pad, joint_height); rotate([180, 0]) translate([side/2-thickness, thickness*4]) side_joint(thickness, pad, joint_height); } } } // 1/4 inch end mill module flat_print(){ thickness = 7/16; legs(width,height); translate([0, -height-5]) legs(width,height); scaling = 72; width = 12; // (in inches) height = 30; // (in inches) translate([-15,-40]) top(width+2*thickness); } module show_3D(){ scaling = 72; width = 12; // (in inches) height = 30; // (in inches) thickness = 7/16; legs_3D(width,height, 3D=true); //legs(width,height, 3D=true); //translate([0, -height-5]) legs(width,height); } //show_3D(); //flat_print(); //offset = scale_factor = 25.4*3.77; width = 12; height = 9; offset = 1; difference(){ scale([scale_factor, scale_factor]) polygon([[0,0], [width, 0], [(width+1), height], [-1, height]]); scale([scale_factor, scale_factor]) polygon([[.5,.5], [width-.5, .5], [width+.4, height-.5], [-.4, height-.5]]);} difference(){ scale([scale_factor, scale_factor]) polygon([[0,0], [width, 0], [(width+1), height], [-1, height]]); scale([scale_factor, scale_factor]) random_voronoi(n=64, L=20, thickness=.3, round=.6, min=0, max=30, nuclei=false); } * polygon([[0,0], [width*scale_factor, 0], [(width+3)*scale_factor, height*scale_factor], [-3*scale_factor, height*scale_factor]]);