7578dbc7493611c5a467dcd89fe9d7c927ce256c
[clinton/3d-models.git] / etc / canister.scad
1 // super simple canister
2 // 2018 Clinton Ebadi
3
4 inner_d = 20;
5 inner_h = 20;
6 cap_inner_h = 12;
7 cap_overlap = 10;
8 cap_tolerance = 0.5;
9
10 wall = 2;
11 base = 1;
12 sides = 6;
13
14
15 // calculated
16 outer_d = inner_d + wall*2;
17 outer_h = inner_h + wall - cap_inner_h + cap_overlap;
18
19 cap_outer_d = outer_d + wall*2;
20 cap_outer_h = cap_inner_h + base;
21
22 cap_bump_size = wall/2;
23 cap_bump_h = cap_bump_size * 2;
24 cap_bump_offset = cap_bump_h + 2;
25
26 echo (cap_bump_offset);
27
28
29 // other asserts, if I care enough...
30 assert (cap_inner_h > cap_overlap);
31 assert (cap_outer_h - cap_bump_offset > base);
32
33
34 //$fa = 0.1;
35 //$fs = 0.1;
36
37 canister_base ();
38 translate ([cap_outer_d + 1, 0, 0,]) canister_cap ();
39
40 //cap_bump ();
41
42 // inner
43 /* module cap_bump () { */
44 /* $fn = sides; */
45 /* cap_bump_d = outer_d+cap_bump_size*2; */
46
47 /* difference () { */
48 /* circle (d=cap_bump_d); */
49 /* circle (d=outer_d); */
50 /* } */
51
52 /* /\* difference () { *\/ */
53 /* /\* cylinder (h=cap_bump_h, d=cap_bump_d, center=true); *\/ */
54 /* /\* cylinder (h=cap_bump_h+1, d=outer_d, center=true); *\/ */
55 /* /\* } *\/ */
56
57 /* /\* rotate_extrude () *\/ */
58 /* /\* union () { *\/ */
59 /* /\* translate ([cap_bump_d/2, 0, 0]) *\/ */
60 /* /\* rotate ([0, 180, 0]) circle (cap_bump_size, $fn=3); *\/ */
61 /* /\* } *\/ */
62 /* } */
63
64 module cap_bump () {
65 cap_bump_d = outer_d+cap_bump_size/2;
66 hull () {
67 translate ([0, 0, 0])
68 cylinder (d = cap_bump_d, h = cap_bump_h/3, $fn = sides);
69 translate ([0, 0, cap_bump_h/3])
70 cylinder (d = cap_bump_d + cap_bump_size, h = cap_bump_h/3, $fn = sides);
71 translate ([0, 0, cap_bump_h/3*2])
72 cylinder (d = cap_bump_d, h = cap_bump_h/3, $fn = sides);
73 }
74 /* cylinder (d = cap_bump_d + cap_bump_size, h = cap_bump_h, $fn = sides); */
75 /* translate ([0, 0, -cap_bump_h]) cylinder (d = inner_d, h = cap_bump_h*2+0.1, $fn = sides); */
76 /* } */
77 /* sphere_d = (cap_bump_h+0.1); */
78 /* translate ([cap_bump_d/2-cap_bump_size, 0, cap_bump_h/2]) sphere (d = sphere_d); */
79 /* } */
80
81 /* minkowski () { */
82 /* cylinder (d = outer_d, h = cap_bump_size*2, $fn = sides); */
83 /* sphere (d = cap_bump_size); */
84 /* } */
85 /* rotate_extrude () { */
86 /* translate ([inner_d/2, 0, 0]) circle (cap_bump_size); */
87 /* } */
88 }
89
90 module canister_base () {
91 difference () {
92 union () {
93 cylinder (d = outer_d, h = outer_h, $fn = sides);
94 translate ([0, 0, outer_h - cap_overlap + cap_bump_offset]) cap_bump ();
95 }
96 translate ([0, 0, base]) cylinder (d = inner_d, h = outer_h + 1, $fn = sides);
97 }
98 }
99
100 module canister_cap () {
101 tolerance_pct = 1.05;
102 difference () {
103 cylinder (d = cap_outer_d, h = cap_outer_h, $fn = sides);
104 translate ([0, 0, base]) cylinder (d = outer_d + cap_tolerance, h = cap_outer_h+1, $fn = sides);
105 translate ([0, 0, cap_outer_h - cap_bump_offset]) scale ([tolerance_pct, tolerance_pct, tolerance_pct]) cap_bump ();
106 }
107 }