]> www.fi.muni.cz Git - things.git/blob - pet-bottle-opener.scad
switch holder.scad
[things.git] / pet-bottle-opener.scad
1 eps = 0.01;
2 infty = 200;
3
4 // lid_diam = 40; // w/o the protrusions
5 body_diam = 7;
6 body_l = 110;
7 body_h1 = 7;
8 body_h2 = 12;
9 wall = 4;
10
11 w_to_h = 0.2;
12
13 $fn = 128;
14
15 module cyl_with_round_top(r, h, w_to_h) {
16         cylinder(r = r, h = h);
17         translate([0, 0, h]) scale([1, 1, w_to_h])
18                 sphere(r = r);
19 }
20
21 module cyl4(r1, h1, d1, r2, h2, d2, w_to_h) {
22         hull() {
23                 for (y = [-1, 1]) scale([1, y, 1])
24                         translate([0, d1, 0])
25                                 cyl_with_round_top(r=r1, h=h1, w_to_h = w_to_h);
26                 for (y = [-1, 1]) scale([1, y, 1])
27                         translate([0, d2, 0])
28                                 cyl_with_round_top(r=r2, h=h2, w_to_h = w_to_h);
29         }
30 }
31
32 params = [
33         [7, body_h1, body_l/2],
34         [11, body_h1 + 1*(body_h2-body_h1)/5, body_l/3],
35         [14, body_h1 + 2*(body_h2-body_h1)/5, body_l/4],
36         [19, body_h1 + 3*(body_h2-body_h1)/5, body_l/7],
37         [22, body_h1 + 4*(body_h2-body_h1)/5, body_l/12],
38         [26, body_h2, 0],
39 ];
40
41 module body() {
42         for (i = [0:len(params)-2]) {
43                 cyl4(params[i][0], params[i][1], params[i][2],
44                         params[i+1][0], params[i+1][1], params[i+1][2],
45                         w_to_h);
46         }
47 }
48
49 difference() {
50         body();
51         difference() {
52                 translate([0, 0, -eps])
53                         cylinder(r1 = 43/2, r2 = 41/2, h = body_h2 + 44*w_to_h);
54                 for (angle = [0:360/30:360]) rotate([0, 0, angle]) hull() {
55                         translate([-43/2, 0, -2*eps])
56                                 cylinder(r=1.5, h=eps, $fn = 3);
57                         translate([-41/2, 0, body_h2+46*w_to_h+2*eps])
58                                 cylinder(r=1.5, h=eps, $fn = 3);
59                 }
60         }
61 }
62