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