]> www.fi.muni.cz Git - things.git/blob - sponge-holder.scad
switch holder.scad
[things.git] / sponge-holder.scad
1 eps = 0.01;
2 infty = 200;
3
4 v_tube_d = 28.2 - 1;
5 h_tube_d = 45;
6 x_off = 25;
7
8 sponge_l = 55; // original size is 85 + 5;
9 sponge_w = 58 + 5;
10 sponge_h = 30 + 5;
11
12 wall = 0.90;
13
14 clip_h = 20;
15 clip_w = 3.5;
16
17 module clip() {
18         difference() {
19                 cylinder(r = v_tube_d/2 + clip_w, h = clip_h, $fn = 128);
20                 translate([0, 0, -eps])
21                 cylinder(r = v_tube_d/2, h = clip_h+2*eps);
22                 intersection() {
23                         rotate([0, 0, -20])
24                                 translate([-infty/2, 0, -eps]) cube(infty);
25                         rotate([0, 0, 40])
26                                 translate([-infty/2, 0, -eps]) cube(infty);
27                 }
28         }
29         // for (angle = [-1.5*72:72:1.5*72]) rotate([0, 0, angle])
30         // translate([v_tube_d/2 + wall, 0, 0])
31         //      cylinder(r = wall, h = clip_h);
32 }
33
34 module perf_wall(w, h, d, hx, hy, dx, dy, side) {
35         difference() {
36                 translate([-w/2, -h/2, -d/2])
37                         cube([w, h, d]);
38                 for (y = [0:1:1 + h/(hy+dy)])
39                 for (y1 = [-1,1]) scale([1, y1, 1])
40                 for (x1 = [-1,1]) scale([x1, 1, 1]) {
41                         for (x = [0:1:1 + w/(hx+dx)]) {
42                                 translate([x*(hx+dx), y*(hy+dy), -d/2-eps])
43                                         scale([1, hy/hx, 1])
44                                         cylinder(r = hx/2, h = d + 2*eps, $fn = 4);
45                         }
46                         for (x = [0.5:1:1 + w/(hx+dx)]) {
47                                 translate([x*(hx+dx), (y+0.5)*(hy+dy), -d/2-eps])
48                                         scale([1, hy/hx, 1])
49                                         cylinder(r = hx/2, h = d + 2*eps, $fn = 4);
50                         }
51                 }
52         }
53         for (x = [-1, 1]) scale ([x, 1, 1])
54         translate([w/2-side, -h/2, -d/2])
55                 cube([side, h, d]);
56         for (y = [-1, 1]) scale ([1, y, 1])
57         translate([-w/2, h/2-side, -d/2])
58                 cube([w, side, d]);
59 }
60
61 round_aspect = 0.5;
62 module round_side(h, w, wall) {
63         difference() {
64                 scale([1, round_aspect, 1])
65                         cylinder(r = w/2 + wall , h = h, $fn = 128);
66                 translate([0, 0, -eps])
67                         scale([1, (w/2)*round_aspect/(w/2+wall), 1])
68                         cylinder(r = w/2, h = h + 2*eps, $fn = 128);
69                 translate([-infty/2, -infty, -infty/2]) cube(infty);
70         }
71 }
72
73 module box() {
74         for (x = [0, sponge_h + wall]) translate([x + wall/2, 0, (sponge_l+wall)/2])
75         rotate([0, 90, 0])
76         perf_wall(h = sponge_w + 2*wall, w = sponge_l + wall, d = wall,
77                 hx = 20, hy = 10, dx = 10, dy = 10, side=3);
78
79         for (y = [-1, 1]) scale ([1, y, 1])
80         translate([sponge_h/2+wall, sponge_w/2+wall/2, 0])
81         round_side(h = sponge_l+wall, w = sponge_h, wall = wall);
82 /*
83         for (y = [-1, 1]) scale ([1, y, 1])
84         translate([sponge_h/2+wall, sponge_w/2+wall/2, (sponge_l+wall)/2])
85         rotate([90, 0, 0])
86         perf_wall(w = sponge_h + 2*wall, h = sponge_l + wall, d = wall,
87                 hy = 20, hx = 10, dx = 10, dy = 10, side=3);
88 */
89
90         for (y = [-sponge_w/4, 0, sponge_w/4])
91         translate ([0, y, 0])
92         // translate ([0, y, sponge_l])
93                 cube([sponge_h + 2*wall, 0.86, 3]);
94 }
95
96 module side_handlers() {
97         for (y=[-1,1]) scale([1, y, 1])
98         hull() {
99                 translate([0, sponge_w/2-wall, 0])
100                         cube([wall, 2*wall, clip_h]);
101                 translate([-x_off-v_tube_d/2, 0, 0])
102                 rotate([0, 0, 34])
103                 translate([v_tube_d/2+clip_w-2*wall, -wall, 0])
104                         cube([2*wall, 2*wall, clip_h]);
105         }
106
107 /*
108         hull() {
109                 translate([0, -sponge_w/2-wall, 0])
110                         cube([wall, 2*wall, clip_h]);
111                 translate([-x_off-v_tube_d/2, -v_tube_d/2-clip_w, 0])
112                         cube([wall, wall, clip_h]);
113         }
114 */
115
116 }
117
118 translate([-v_tube_d/2-x_off, 0, 0])
119         clip();
120
121 side_handlers();
122
123 box();
124