summaryrefslogtreecommitdiffabout
path: root/snapper.scad
blob: 0c258ca9fff3117bba742f083aea34264205181c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/* d - diameter, o - overlap (fraction) */
function snapper_apart(d,o) = d*(1-o);
module snapper(d,o,l=-1,side=0) {
 snapper_apart = d*(1-o);
 l_ = (l<0) ? d : l;
 lw = d/2;
 sfn = 8*d;
 module lm() {
  translate([-lw/2,0,0]) hull() {
   cube(size=[lw,l_-d/2,d]);
   translate([lw/2,l_,0]) cylinder(d=d/8,h=d,$fn=sfn);
  }
 }
 if(side==0) {
  translate([0,l_,d/2]) sphere(d=d,$fn=sfn);
  lm();
 }else if(side==1) {
  difference() {
   for(x=[-1,1]) translate([x*snapper_apart(d,o),0,0]) {
    translate([0,l_,d/2]) sphere(d=d,$fn=sfn);
    lm();
   }
   translate([0,l_,d/2]) sphere(d=d,$fn=sfn);
  }
 }else
  echo("ERROR: what side?");
}