chiark / gitweb /
93577660b677b8ffe7bceb31cd5b94aeb4664cab
[reprap-play.git] / poster-tube-lid.scad
1 // -*- C -*-
2
3 main_dia = 71.2 + 0.50 - 2.26;
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 jig_thick = 1.4;
36 jig_hole_dia = 3.0;
37 jig_rim = 5;
38 jig_mark = 5;
39
40 // calculated
41
42 bayo_entry_x = bayo_entry;
43 bayo_entry_z = bayo_entry;
44 bayo_inramp_x = bayo_entry;
45 bayo_inramp_z = bayo_entry;
46
47 side_height = rivet_posn + bayo_behind + rivet_thick/2;
48 side_thick = rivet_tall + over_rivet_wall;
49
50 top_z = top_thick + seal_thick;
51
52 bayo_entry = bayo_behind / 3.0;
53 bayo_top_z = bayo_behind + rivet_thick + bayo_above_gap;
54 bayo_entry_ramp = bayo_entry + bayo_interf;
55
56 rivet_entry_width = rivet_width + side_rivet_gap;
57
58 jig_mark_rad = jig_mark + main_dia/2 + jig_thick;
59
60 $fs=0.5;
61 $fa=1;
62
63 // bayonet definition
64
65 bayo_a = [ bayo_entry_x, 0 ];
66 bayo_p = [ 0, bayo_entry_z ];
67 bayo_n = [ 0, bayo_behind-bayo_inramp_z ];
68 bayo_m = [ bayo_inramp_x, bayo_behind ];
69 bayo_l = bayo_m + bayo_interf * [ 1/bayo_interf_slope,  1 ];
70 bayo_k = bayo_l + [ bayo_interf_width, 0 ];
71 bayo_j = bayo_k + bayo_interf * [ 1/bayo_interf_slope, -1 ];
72 bayo_i = bayo_j + [ rivet_width, 0 ];
73 bayo_h = [ bayo_i[0], bayo_behind + rivet_thick + bayo_above_gap ];
74 bayo_g = [ bayo_m[0] - rivet_width, bayo_h[1] ];
75
76 bayo_e = [-bayo_p[0], bayo_p[1]] - [rivet_entry_width,0];
77 bayo_d = [-bayo_a[0], bayo_a[1]] - [rivet_entry_width,0];
78 bayo_c = bayo_d + [0,-5];
79 bayo_b = bayo_a + [0,-5];
80
81 bayo_f = [ bayo_e[0], bayo_g[1] + (bayo_e[0] - bayo_g[0]) ];
82
83 bayo_polygon = [ bayo_a,
84                  bayo_b,
85                  bayo_c,
86                  bayo_d,
87                  bayo_e,
88                  bayo_f,
89                  bayo_g,
90                  bayo_h,
91                  bayo_i,
92                  bayo_j,
93                  bayo_k,
94                  bayo_l,
95                  bayo_m,
96                  bayo_n,
97                  bayo_p ];
98
99 echo(bayo_polygon);
100
101 module MainProfile(){
102   main_cnr_pos = [ side_thick, top_z ] - [1,1]*main_cnr;
103   translate(main_cnr_pos){
104     intersection(){
105       difference(){
106         circle(r = main_cnr);
107         circle(r = main_cnr * 0.5);
108       }
109       square([10,10]);
110     }
111   }
112   polygon([[ -1,                    seal_thick        ],
113            [ -1,                    top_z             ],
114            [ main_cnr_pos[0],       top_z             ],
115            [ side_thick,            main_cnr_pos[1]   ],
116            [ side_thick,            -side_height      ],
117            [ side_taper,            -side_height      ],
118            [ 0,                     -rivet_posn       ],
119            [ 0,                     -(seal_recess[0] + seal_recess[1]) ],
120            [ seal_recess[0],        -(seal_recess[0]) ],
121            [ seal_recess[0],        seal_thick        ],
122            ],
123           convexity=10);
124 }
125
126 module RotateProjectSlice(offset, slice_size, nom_rad, real_rad){
127   // nom_rad > real_rad
128   rotate([0,0, atan2(offset, nom_rad) ]){
129     intersection(){
130       translate([-offset, -10, 0])
131         rotate([90,0,0])
132         linear_extrude(height= nom_rad*2)
133         children(0);
134       translate([0,0, -25])
135         cylinder(h=50, r= real_rad);
136       translate([0,0, -25])
137         linear_extrude(height= 50)
138         polygon([ [ 0,0 ],
139                   [ -slice_size, -real_rad*2 ],
140                   [ +slice_size, -real_rad*2 ] ]);
141     }
142   }
143 }
144
145 module RotateProject(x_min, x_max, slice_size, nom_rad, real_rad){
146   offs = [ for (i=[ x_min :
147                     slice_size :
148                     x_max + slice_size ]) i ];
149   echo (offs);
150   for (off=offs)
151     RotateProjectSlice(off, slice_size, nom_rad, real_rad)
152     children(0);
153 }
154
155 module BayonetCutout(){
156   RotateProject(bayo_c[0], bayo_i[0], bayo_slice_size,
157                 main_dia/2 + side_thick, 
158                 main_dia/2 + rivet_tall)
159     polygon(bayo_polygon, convexity=10);
160 }
161
162 module ProfilesDemo(){ ////toplevel
163   translate([-20,0]) MainProfile();
164   polygon(bayo_polygon, convexity=10);
165 }
166
167 module Cover(){ ////toplevel
168   render() difference(){
169     union(){
170       rotate_extrude(convexity=10)
171         translate([main_dia/2, 0])
172         MainProfile();
173       translate([0,0, seal_thick])
174         cylinder(h= top_thick, r = main_dia/2);
175     }
176     for (r=[0,180])
177       rotate([0,0, r])
178         translate([0,0, -side_height])
179         BayonetCutout();
180     for (r=[0 : 60 : 179]) {
181       rotate([0,0, r]) {
182         height = top_thick - brace_above_below*2;
183         translate([0,0, seal_thick + brace_above_below + height/2 ])
184         cube(center=true, [ main_dia, brace_hole_width, height ]);
185       }
186     }
187   }
188 }
189
190 module SavingHole(){
191   translate([0,0, -10])
192     cylinder(r= main_dia/2 - jig_rim, h=20);
193 }
194
195 module Jig(){ ////toplevel
196   difference(){
197     union(){
198       translate([0,0, -side_height]){
199         cylinder(r= main_dia/2 + jig_thick, h= side_height + jig_thick);
200       }
201       translate([-jig_mark_rad, 0, jig_thick - jig_mark])
202         cube([jig_mark_rad*2, jig_mark, jig_mark]);
203     }
204     translate([0,0, -side_height-1])
205       cylinder(r= main_dia/2, h= side_height + 1);
206     SavingHole();
207     translate([0,0, -rivet_posn])
208       rotate([90, 0,0])
209       translate([0,0, -100])
210       cylinder(r= jig_hole_dia/2, h = 200);
211   }
212 }
213
214 module CoverTest2(){ ////toplevel
215   difference(){
216     Cover();
217     SavingHole();
218   }
219 }
220
221 module CoverTest1(){ ////toplevel
222   difference(){
223     CoverTest2();
224     translate([0,0, -10])
225       cube([ main_dia*3, main_dia * .85, 20], center=true);
226   }
227 }
228
229 //ProfilesDemo();
230 //BayonetCutout();
231 //MainProfile();
232 //Cover();
233 //Jig();
234 //CoverTest();