chiark / gitweb /
flyscreen-handle: peg bases from v10
[reprap-play.git] / flyscreen-handle.scad
1 // -*- C -*-
2
3 opening_height = 7.84 - 0.3 + 0.60;
4 opening_depth = 6.0; // 7.88;
5 openingcnr_dia = 2.75;
6 opening_topprotr = 1.54 + 0.2;
7
8 gap = 0.25;
9
10 retain_rad = 1.65;
11 retain_protr = 0.25;
12 retain_hgap_adjust = 1.5;
13
14 retain_stalk_len = 8.0;
15 retain_stalk_h = 1.5;
16 retain_bend_gap = 2.0;
17 retain_empir_angle = -10;
18 retain_pushmore_adj = 0.0;
19
20 hgap_empir_adjust = -0.5 -2.50;
21
22 topprotr_rad = 0.35;
23
24 bot_overlap = 5;
25 top_w = 3;
26 bot_w = 6;
27
28 handle_w = 7;
29 handle_rh = 3;
30 handle_rcut = 3;
31
32 cutout_gap = 1.5;
33
34 total_len = 40;
35 retain_len = 8;
36 basics_len = 8;
37
38 overret_hch = 5;
39
40 peg_width_slop = 0.5;
41 peg_inner_thick = 1.0;
42
43 peg_wedge_less = 1.0;
44 peg_wedge_more = 2.0;
45 peg_len = 16;
46
47 peg_base_w = 10;
48 peg_base_th = 1.5;
49
50 // calculated
51
52 ins_irad = openingcnr_dia/2 + gap;
53 ins_orad = openingcnr_dia/2 + opening_height - gap;
54 ins_th = ins_orad - ins_irad;
55
56 handle_x0 = ins_irad + hgap_empir_adjust;
57 handle_h = bot_overlap + ins_th;
58 handle_y0 = -ins_orad-bot_overlap;
59 handle_y1 = handle_y0 + handle_h;
60
61 handle_x1 = handle_x0 + bot_w + handle_w;
62
63 topprotr_y = -ins_irad + opening_topprotr;
64
65 retain_mxy = [handle_x0 - retain_rad - retain_hgap_adjust,
66               -ins_orad + retain_rad - retain_protr];
67
68 retain_cutout_h = retain_rad * 2 + retain_bend_gap;
69
70 overret_gaplen = retain_cutout_h / cos(retain_empir_angle);
71
72 peg_width = retain_stalk_len -
73   (handle_x0 - retain_mxy[0]) / cos(retain_empir_angle)
74   - peg_width_slop;
75
76 peg_height = retain_cutout_h - (retain_rad + retain_stalk_h)
77   + retain_pushmore_adj;
78
79 retain1_len = retain_len + retain_stalk_len;
80 retain1_base = total_len - retain1_len;
81
82 module InsertSection(){
83   hull(){
84     translate([-ins_irad, -ins_irad])
85       mirror([1, 0])
86       square([opening_depth - ins_irad, 0.1]);
87     translate([-ins_irad - topprotr_rad,
88                topprotr_y - topprotr_rad])
89       circle(r=topprotr_rad, $fn=10);
90   }
91   translate([0, -ins_orad]) square([ins_irad, ins_th]);
92   intersection(){
93     translate([0, -ins_irad])
94       mirror([1,1])
95       square([100, opening_depth]);
96     difference(){
97       circle(r= ins_orad);
98       circle(r= ins_irad, $fn=20);
99     }
100   }
101 }
102
103 module HandleSection(){
104   difference(){
105     hull(){
106       translate([handle_x0, handle_y0])
107         square([bot_w, handle_h]);
108       for (y= [handle_y1 - handle_rh/2,
109                handle_y1 - ins_th + handle_rh/2]) {
110         translate([handle_x1 - handle_rh/2, y])
111           circle(r= handle_rh/2, $fn=20);
112       }
113     }
114     hull(){
115       for (x= [handle_x0 + top_w + handle_rcut/2,
116                handle_x1 - handle_rh/2 - handle_rcut/2]) {
117         translate([x, handle_y1])
118           circle(r = handle_rcut/2, $fn=20);
119       }
120     }
121   }
122   hull(){
123     for (y= [handle_y1 -   handle_rh/2,
124              handle_y1 - 3*handle_rh/2])
125       translate([handle_x1 - handle_rh/2, y])
126         circle(r = handle_rh/2, $fn=20);
127   }
128   translate([ handle_x1 - handle_rh*2,
129               handle_y1 - handle_rh/2 ])
130     circle(r = handle_rh/2, $fn=20);
131 }
132
133 module RetainSection(){
134   translate(retain_mxy) {
135     rotate(retain_empir_angle) {
136       circle(r=retain_rad, $fn=20);
137       translate([0, -retain_pushmore_adj])
138         square([retain_stalk_len + 1, retain_stalk_h]);
139     }
140   }
141 }
142
143 module PegSection(delta){
144   hull(){
145     translate([0, -delta/2])
146       square([0.1,
147               peg_height + delta]);
148     translate([peg_width - 0.1,
149                peg_height/2 - peg_inner_thick/2])
150       square([0.1, peg_inner_thick]);
151   }
152 }
153
154 module PegSectionForDemo(delta){
155   translate(retain_mxy)
156     rotate(retain_empir_angle)
157     translate([retain_stalk_len - peg_width - peg_width_slop/2,
158                retain_stalk_h - retain_pushmore_adj])
159     PegSection(delta);
160 }
161
162 module RetainCutout(gapping=false){
163   translate(retain_mxy) {
164     rotate(retain_empir_angle) {
165       translate([-50, -retain_rad]) {
166         square([50 + retain_stalk_len,
167                 retain_cutout_h]);
168       }
169     }
170   }
171 }  
172
173 module GappingSection(){
174   difference(){
175     union(){
176       InsertSection();
177       HandleSection();
178     }
179     RetainCutout(true);
180   }
181 }
182
183 module WithRetainSection(){
184   difference(){
185     union(){
186       InsertSection();
187       HandleSection();
188     }
189     RetainCutout();
190   }
191   RetainSection();
192 }
193
194 module BasicSection(){
195   InsertSection();
196   HandleSection();
197 }
198
199 module PegSectionSlice(lambda) {
200   delta = peg_wedge_more * (1-lambda) + -peg_wedge_less * lambda;
201   z = peg_len * lambda;
202   translate([0,0, z])
203     linear_extrude(height=0.1)
204     PegSection(delta);
205 }  
206
207 module Peg(){
208   iters = 20;
209   for (i = [0 : iters-1]) {
210     lambda = i/iters;
211     hull(){
212       PegSectionSlice(lambda);
213       PegSectionSlice(lambda + 1/iters);
214     }
215   }
216   translate([0, -peg_base_w/2 + peg_height/2, 0])
217     cube([peg_height, peg_base_w, peg_base_th]);
218 }
219
220 module PegPrintL(){
221   rotate([0,-90,0]) Peg();
222 }
223
224 module PegPrintR(){
225   mirror([1,0,0]) PegPrintL();
226 }
227
228 module Handle(){
229   bs1 = retain_len + overret_gaplen + 4;
230
231   translate([0,0,0])
232     linear_extrude(height= retain_len)
233     WithRetainSection();
234
235   translate([0,0, bs1])
236     linear_extrude(height= basics_len)
237     BasicSection();
238
239   translate([0,0, bs1+0.1]) mirror([0,0,1]) {
240     intersection_for (sl=[0,1]) {
241       multmatrix([[1,0,0,0],
242                   [0,1,sl,0],
243                   [0,0,1,0],
244                   [0,0,0,1]])
245         linear_extrude(height= overret_gaplen + 10, convexity=100)
246         BasicSection();
247     }
248   }
249   
250   linear_extrude(height=total_len, convexity=100) GappingSection();
251
252   translate([0,0, retain1_base]) {
253     intersection(){
254       linear_extrude(height=retain1_len, convexity=100)
255         WithRetainSection();
256       translate([retain_mxy[0], retain_mxy[1], 0])
257         rotate([0,0, retain_empir_angle])
258         translate([retain_stalk_len, -30, 0])
259         multmatrix([[1,0,-1,0],
260                     [0,1,0,0],
261                     [0,0,1,0],
262                     [0,0,0,1]])
263         cube([50, 60, 50]);
264     }
265   }
266 }
267
268 module Demo(){
269   color("red") translate([0,0,-3]) BasicSection();
270   color("blue") translate([0,0,3]) WithRetainSection();
271   color("orange") translate([0,0,7]) PegSectionForDemo(0);
272 }
273
274 module Test(){
275   linear_extrude(height=2) {
276     WithRetainSection();
277     translate([0, -handle_y0 + topprotr_y + 10])
278       BasicSection();
279   }
280 }
281
282 module PegTestKit(){
283   PegPrintL();
284   translate([2,0,0]) PegPrintR();
285   translate([0,-8,0])
286     linear_extrude(height=retain_len, convexity=100) WithRetainSection();
287 }
288
289 //Demo();
290 //HandleSection();
291 //InsertSection();
292 //WithRetainSection();
293 //BasicSection();
294 //GappingSection();
295 //Test();
296 //Peg();
297 //PegPrintR();
298 PegTestKit();
299 //Demo();
300 //Handle();