chiark / gitweb /
5937a94a0e96334845fccd9397631c7135afbb8a
[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 = 3;
40
41 // calculated
42
43 ins_irad = openingcnr_dia/2 + gap;
44 ins_orad = openingcnr_dia/2 + opening_height - gap;
45 ins_th = ins_orad - ins_irad;
46
47 handle_x0 = ins_irad + hgap_empir_adjust;
48 handle_h = bot_overlap + ins_th;
49 handle_y0 = -ins_orad-bot_overlap;
50 handle_y1 = handle_y0 + handle_h;
51
52 handle_x1 = handle_x0 + bot_w + handle_w;
53
54 topprotr_y = -ins_irad + opening_topprotr;
55
56 retain_mxy = [handle_x0 - retain_rad - retain_hgap_adjust,
57               -ins_orad + retain_rad - retain_protr];
58
59 retain_cutout_h = retain_rad * 2 + retain_bend_gap;
60
61 overret_gaplen = retain_cutout_h / cos(retain_empir_angle);
62
63 peg_space_width = retain_stalk_len -
64   (handle_x0 - retain_mxy[0]) / cos(retain_empir_angle);
65
66 peg_height = retain_cutout_h - (retain_rad + retain_stalk_h)
67   + retain_pushmore_adj;
68
69 retain1_len = retain_len + retain_stalk_len;
70 retain1_base = total_len - retain1_len;
71
72 module InsertSection(){
73   hull(){
74     translate([-ins_irad, -ins_irad])
75       mirror([1, 0])
76       square([opening_depth - ins_irad, 0.1]);
77     translate([-ins_irad - topprotr_rad,
78                topprotr_y - topprotr_rad])
79       circle(r=topprotr_rad, $fn=10);
80   }
81   translate([0, -ins_orad]) square([ins_irad+1, ins_th]);
82   intersection(){
83     translate([0, -ins_irad])
84       mirror([1,1])
85       square([100, opening_depth]);
86     difference(){
87       circle(r= ins_orad);
88       circle(r= ins_irad, $fn=20);
89     }
90   }
91 }
92
93 module HandleSection(){
94   difference(){
95     hull(){
96       translate([handle_x0, handle_y0])
97         square([bot_w, handle_h]);
98       for (y= [handle_y1 - handle_rh/2,
99                handle_y1 - ins_th + handle_rh/2]) {
100         translate([handle_x1 - handle_rh/2, y])
101           circle(r= handle_rh/2, $fn=20);
102       }
103     }
104     hull(){
105       for (x= [handle_x0 + bot_w + handle_rcut/2,
106                handle_x1 - handle_rh/2 - handle_rcut/2]) {
107         translate([x, handle_y1])
108           circle(r = handle_rcut/2, $fn=20);
109       }
110     }
111   }
112   hull(){
113     for (y= [handle_y1 -   handle_rh/2,
114              handle_y1 - 3*handle_rh/2])
115       translate([handle_x1 - handle_rh/2, y])
116         circle(r = handle_rh/2, $fn=20);
117   }
118   translate([ handle_x1 - handle_rh*2,
119               handle_y1 - handle_rh/2 ])
120     circle(r = handle_rh/2, $fn=20);
121 }
122
123 module RetainSection(){
124   translate(retain_mxy) {
125     rotate(retain_empir_angle) {
126       circle(r=retain_rad, $fn=20);
127       translate([0, -retain_pushmore_adj])
128         square([retain_stalk_len + 1, retain_stalk_h]);
129     }
130   }
131 }
132
133 module PegSection(delta){
134   square([peg_width,
135           peg_height + delta]);
136 }
137
138 module PegSectionForDemo(delta){
139   translate(retain_mxy)
140     rotate(retain_empir_angle)
141     translate([retain_stalk_len - peg_space_width,
142                retain_stalk_h - retain_pushmore_adj])
143     PegSection(delta);
144 }
145
146 module RetainCutout(gapping=false){
147   translate(retain_mxy) {
148     rotate(retain_empir_angle) {
149       translate([-50, -retain_rad]) {
150         square([50 + retain_stalk_len,
151                 retain_cutout_h]);
152       }
153     }
154   }
155 }  
156
157 module GappingSection(){
158   difference(){
159     union(){
160       InsertSection();
161       HandleSection();
162     }
163     RetainCutout(true);
164   }
165 }
166
167 module WithRetainSection(){
168   difference(){
169     union(){
170       InsertSection();
171       HandleSection();
172     }
173     RetainCutout();
174   }
175   RetainSection();
176 }
177
178 module BasicSection(){
179   InsertSection();
180   HandleSection();
181 }
182
183 module Handle(){
184   bs1 = retain_len + overret_gaplen + 4;
185
186   translate([0,0,0])
187     linear_extrude(height= retain_len)
188     WithRetainSection();
189
190   translate([0,0, bs1])
191     linear_extrude(height= basics_len)
192     BasicSection();
193
194   translate([0,0, bs1+0.1]) mirror([0,0,1]) {
195     intersection_for (sl=[0,1]) {
196       multmatrix([[1,0,0,0],
197                   [0,1,sl,0],
198                   [0,0,1,0],
199                   [0,0,0,1]])
200         linear_extrude(height= overret_gaplen + 10, convexity=100)
201         BasicSection();
202     }
203   }
204   
205   linear_extrude(height=total_len, convexity=100) GappingSection();
206
207   translate([0,0, retain1_base]) {
208     intersection(){
209       linear_extrude(height=retain1_len, convexity=100)
210         WithRetainSection();
211       translate([retain_mxy[0], retain_mxy[1], 0])
212         rotate([0,0, retain_empir_angle])
213         translate([retain_stalk_len, -30, 0])
214         multmatrix([[1,0,-1,0],
215                     [0,1,0,0],
216                     [0,0,1,0],
217                     [0,0,0,1]])
218         cube([50, 60, 50]);
219     }
220   }
221 }
222
223 module Demo(){
224   color("red") translate([0,0,-3]) BasicSection();
225   color("blue") translate([0,0,3]) WithRetainSection();
226   color("orange") translate([0,0,7]) PegSectionForDemo(0);
227 }
228
229 module Test(){
230   linear_extrude(height=2) {
231     WithRetainSection();
232     translate([0, -handle_y0 + topprotr_y + 10])
233       BasicSection();
234   }
235 }
236
237 Demo();
238 //HandleSection();
239 //InsertSection();
240 //WithRetainSection();
241 //BasicSection();
242 //GappingSection();
243 //Test();
244 //Demo();
245 //Handle();