chiark / gitweb /
3c60f532ab71708e5b3099b198d7d0785db3509a
[reprap-play.git] / poster-tube-lid.scad
1 // -*- C -*-
2
3 main_dia = 71.2 + 0.50;
4 top_thick = 4;
5
6 main_cnr = 4.0;
7
8 rivet_posn = 6.0;
9 rivet_thick = 1.67;
10 rivet_width = 4.15 + 1.0;
11 rivet_tall = 5.51 + 0.49;
12
13 over_rivet_wall = 0.5;
14 side_rivet_gap = 1.5;
15
16 bayo_interf = 0.75;
17 bayo_behind = 3.5;
18 bayo_interf_width = 2.0;
19 bayo_interf_slope = 0.75;
20
21 seal_thick = 0.1;
22 seal_recess = [ 2.0, 2.0 ]; // recess depth, recess height
23
24 side_taper = 1.0;
25
26 bayo_above_gap = 1.0;
27
28 bayo_entry = bayo_behind/3;
29
30 bayo_slice_size = 1;
31
32 brace_hole_width = 1.0;
33 brace_above_below = 1.2;
34
35 // calculated
36
37 bayo_entry_x = bayo_entry;
38 bayo_entry_z = bayo_entry;
39 bayo_inramp_x = bayo_entry;
40 bayo_inramp_z = bayo_entry;
41
42 side_height = rivet_posn + bayo_behind + rivet_thick/2;
43 side_thick = rivet_tall + over_rivet_wall;
44
45 top_z = top_thick + seal_thick;
46
47 bayo_entry = bayo_behind / 3.0;
48 bayo_top_z = bayo_behind + rivet_thick + bayo_above_gap;
49 bayo_entry_ramp = bayo_entry + bayo_interf;
50
51 rivet_entry_width = rivet_width + side_rivet_gap;
52
53 $fs=0.5;
54 $fa=1;
55
56 // bayonet definition
57
58 bayo_a = [ bayo_entry_x, 0 ];
59 bayo_p = [ 0, bayo_entry_z ];
60 bayo_n = [ 0, bayo_behind-bayo_inramp_z ];
61 bayo_m = [ bayo_inramp_x, bayo_behind ];
62 bayo_l = bayo_m + bayo_interf * [ 1/bayo_interf_slope,  1 ];
63 bayo_k = bayo_l + [ bayo_interf_width, 0 ];
64 bayo_j = bayo_k + bayo_interf * [ 1/bayo_interf_slope, -1 ];
65 bayo_i = bayo_j + [ rivet_width, 0 ];
66 bayo_h = [ bayo_i[0], bayo_behind + rivet_thick + bayo_above_gap ];
67 bayo_g = [ bayo_m[0] - rivet_width, bayo_h[1] ];
68
69 bayo_e = [-bayo_p[0], bayo_p[1]] - [rivet_entry_width,0];
70 bayo_d = [-bayo_a[0], bayo_a[1]] - [rivet_entry_width,0];
71 bayo_c = bayo_d + [0,-5];
72 bayo_b = bayo_a + [0,-5];
73
74 bayo_f = [ bayo_e[0], bayo_g[1] + (bayo_e[0] - bayo_g[0]) ];
75
76 bayo_polygon = [ bayo_a,
77                  bayo_b,
78                  bayo_c,
79                  bayo_d,
80                  bayo_e,
81                  bayo_f,
82                  bayo_g,
83                  bayo_h,
84                  bayo_i,
85                  bayo_j,
86                  bayo_k,
87                  bayo_l,
88                  bayo_m,
89                  bayo_n,
90                  bayo_p ];
91
92 echo(bayo_polygon);
93
94 module MainProfile(){
95   main_cnr_pos = [ side_thick, top_z ] - [1,1]*main_cnr;
96   translate(main_cnr_pos){
97     intersection(){
98       difference(){
99         circle(r = main_cnr);
100         circle(r = main_cnr * 0.5);
101       }
102       square([10,10]);
103     }
104   }
105   polygon([[ -1,                    seal_thick        ],
106            [ -1,                    top_z             ],
107            [ main_cnr_pos[0],       top_z             ],
108            [ side_thick,            main_cnr_pos[1]   ],
109            [ side_thick,            -side_height      ],
110            [ side_taper,            -side_height      ],
111            [ 0,                     -rivet_posn       ],
112            [ 0,                     -(seal_recess[0] + seal_recess[1]) ],
113            [ seal_recess[0],        -(seal_recess[0]) ],
114            [ seal_recess[0],        seal_thick        ],
115            ]);
116 }
117
118 module RotateProjectSlice(offset, slice_size, nom_rad, real_rad){
119   // nom_rad > real_rad
120   rotate([0,0, atan2(offset, nom_rad) ]){
121     intersection(){
122       translate([-offset, -10, 0])
123         rotate([90,0,0])
124         linear_extrude(height= nom_rad*2)
125         children(0);
126       translate([0,0, -25])
127         cylinder(h=50, r= real_rad);
128       translate([0,0, -25])
129         linear_extrude(height= 50)
130         polygon([ [ 0,0 ],
131                   [ -slice_size, -real_rad*2 ],
132                   [ +slice_size, -real_rad*2 ] ]);
133     }
134   }
135 }
136
137 module RotateProject(x_min, x_max, slice_size, nom_rad, real_rad){
138   offs = [ for (i=[ x_min :
139                     slice_size :
140                     x_max + slice_size ]) i ];
141   echo (offs);
142   for (off=offs)
143     RotateProjectSlice(off, slice_size, nom_rad, real_rad)
144     children(0);
145 }
146
147 module BayonetCutout(){
148   RotateProject(bayo_c[0], bayo_i[0], bayo_slice_size,
149                 main_dia/2 + side_thick, 
150                 main_dia/2 + rivet_tall)
151     polygon(bayo_polygon);
152 }
153
154 module ProfilesDemo(){
155   translate([-20,0]) MainProfile();
156   polygon(bayo_polygon);
157 }
158
159 module Cover(){
160   difference(){
161     union(){
162       rotate_extrude()
163         translate([main_dia/2, 0])
164         MainProfile();
165       translate([0,0, seal_thick])
166         cylinder(h= top_thick, r = main_dia/2);
167     }
168     for (r=[0,180])
169       rotate([0,0, r])
170         translate([0,0, -side_height])
171         BayonetCutout();
172     for (r=[0 : 60 : 179]) {
173       rotate([0,0, r]) {
174         height = top_thick - brace_above_below*2;
175         translate([0,0, seal_thick + brace_above_below + height/2 ])
176         cube(center=true, [ main_dia, brace_hole_width, height ]);
177       }
178     }
179   }
180 }
181
182 //ProfilesDemo();
183 //BayonetCutout();
184 //MainProfile();
185 Cover();