summaryrefslogtreecommitdiffabout
path: root/snapper.scad
Unidiff
Diffstat (limited to 'snapper.scad') (more/less context) (ignore whitespace changes)
-rw-r--r--snapper.scad27
1 files changed, 27 insertions, 0 deletions
diff --git a/snapper.scad b/snapper.scad
new file mode 100644
index 0000000..0c258ca
--- a/dev/null
+++ b/snapper.scad
@@ -0,0 +1,27 @@
1/* d - diameter, o - overlap (fraction) */
2function snapper_apart(d,o) = d*(1-o);
3module snapper(d,o,l=-1,side=0) {
4 snapper_apart = d*(1-o);
5 l_ = (l<0) ? d : l;
6 lw = d/2;
7 sfn = 8*d;
8 module lm() {
9 translate([-lw/2,0,0]) hull() {
10 cube(size=[lw,l_-d/2,d]);
11 translate([lw/2,l_,0]) cylinder(d=d/8,h=d,$fn=sfn);
12 }
13 }
14 if(side==0) {
15 translate([0,l_,d/2]) sphere(d=d,$fn=sfn);
16 lm();
17 }else if(side==1) {
18 difference() {
19 for(x=[-1,1]) translate([x*snapper_apart(d,o),0,0]) {
20 translate([0,l_,d/2]) sphere(d=d,$fn=sfn);
21 lm();
22 }
23 translate([0,l_,d/2]) sphere(d=d,$fn=sfn);
24 }
25 }else
26 echo("ERROR: what side?");
27}