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