chiark / gitweb /
poster-tube-lid-parametric: wip, makes a file which has right syntax
[reprap-play.git] / flyscreen-handle.scad
1 // -*- C -*-
2
3 opening_height = 7.84;
4 opening_depth = 7.88;
5 openingedge_dia = 2.00;
6 opening_protrh = 2.00;
7
8 pivot_x = 6;
9 inside_len = 4;
10
11 pivoting_gap = 0.1;
12
13 outside_gap = 3;
14 outside_len = 13;
15 outend_height = 3;
16
17 outside_len_bot = 23;
18
19 outside_pushh = 4;
20 outside_pushslope = 1.4;
21 outside_push_inadj = 0.82;
22
23 ourcirc_r = 0.5 / 2;
24
25 ribble_dia = 2.2;;
26
27 opening_protr_slop = 0.1;
28
29 intooth_top_slop = 0.1;
30 inside_h_xgap = 1;
31
32 pivot_r = 2;
33 pivot_slop = 0.25;
34
35 strap_above = 0.1;
36 strap_th = 2.5;
37 strap_below = 3;
38 strap_width = 5;
39
40 width = 35;
41 nstraps = 2;
42
43 test_width = 5;
44
45 // calculated
46
47 inside_h = opening_height/2 - opening_protrh - inside_h_xgap/2;
48
49 edge_or = openingedge_dia/2 + opening_protr_slop;
50
51 Q0 = [ openingedge_dia/2,
52        openingedge_dia/2 + opening_height/2 ];
53
54 p4p5d = [edge_or + ourcirc_r, 0];
55
56 P0 = [ pivot_x, pivoting_gap ];
57 P4 = Q0 - p4p5d;
58 P3t = [ P4[0], Q0[1] - openingedge_dia/2 + opening_protrh
59         - intooth_top_slop - ourcirc_r ];
60 P2 = P4 + [ -(inside_len - ourcirc_r*2), 0 ];
61 P1 = [ P2[0], P3t[1] - (inside_h + ourcirc_r*2) ];
62
63 P5 = Q0 + p4p5d;
64
65 P8t = [ outside_len - ourcirc_r, P5[1] ];
66 P9t = P8t + [ 0, -(strap_above + strap_th + strap_below - ourcirc_r*2) ];
67
68 P9b = [ P9t[0], -P9t[1] + outside_gap ];
69 P8b = P9b + [ 0, outend_height ];
70
71 P89eadj = [ outside_len_bot - outside_len, 0 ];
72 P8eb = P8b + P89eadj;
73 P9eb = P9b + P89eadj;
74
75 P6t = P5 + [ 0, outside_pushh - ourcirc_r*2 ];
76 P7 = [ P6t[0] + (P6t[1] - P1[1]) / outside_pushslope,
77        P1[1] ];
78
79 P3a = P3t + [ -outside_push_inadj, 0 ];
80 P6a = P6t + [ -outside_push_inadj, 0 ];
81
82 outside_push_inadj_slope = (P3t[1]-P4[1]) / (P6a[1]-P5[1]);
83
84 ribble_rad = ribble_dia/2;
85
86 kit_adj_shift = -opening_height - 2.0;
87
88 module ExtrusionSect(){
89   cr = openingedge_dia/2;
90   toph = opening_height/2 + opening_protrh;
91
92   for (my=[0,1]) {
93     mirror([0,my]) {
94       translate(Q0) {
95         hull(){
96           circle(r=cr, $fn=20);
97           translate([-cr,10]) square([cr*2, 1]);
98         }
99       }
100     }
101   }
102   translate([-opening_depth, -toph]) {
103     difference(){
104       translate([-5,-5])
105         square([opening_depth+6, toph*2+10]);
106       square([opening_depth+2, toph*2]);
107     }
108   }
109 }
110
111 module PsHull(ps) {
112   hull(){
113     for (p = ps) {
114       translate(p)
115         circle(r = ourcirc_r, $fn=10);
116     }
117   }
118 }
119
120 module LeverSect(top, inadj=false){
121   P3 = inadj ? P3a : P3t;
122   P6 = inadj ? P6a : P6t;
123   P8 = top ? P8t : P8b;
124   P9 = top ? P9t : P9b;
125   difference(){
126     union(){
127       PsHull([P2,P3,P4]);
128       PsHull([P0,P1,P2,P5,P8,P9]);
129     }
130     hull(){
131       for (dp = [ [0,0],
132                   (P6-P5),
133                   (P3-P4)
134                   ]) {
135         translate(Q0 + 5*dp) circle(r=edge_or, $fn=20);
136       }
137     }
138   }
139 }
140
141 module StrapSectTop(){
142   translate(P9t + ourcirc_r * [+1,-1]) {
143     difference(){
144       circle(r = strap_below + strap_th, $fn=40);
145       circle(r = strap_below,            $fn=40);
146     }
147   }
148 }
149
150 module StrapSectBot(){
151   mirror([0,1]){
152     for (dx = [ -(strap_below + strap_th),
153                 0 ]) {
154       translate(P9b + [ ourcirc_r + dx, -10 ]) {
155         square([strap_th, 20]);
156       }
157     }
158   }
159 }
160
161 module Ribbles(xmax, xmin, y){
162   for (x = [ xmax + ourcirc_r - ribble_rad :
163              -ribble_rad * 4 :
164              xmin ]) {
165     translate([x, y])
166       circle(r = ribble_rad, $fn=20);
167   }
168 }
169
170 module LeverSectTop(){
171   difference(){
172     union(){
173       LeverSect(true, false);
174       Ribbles(P8t[0],
175               Q0[0] + edge_or + ribble_rad*2,
176               P5[1] + ourcirc_r);
177     }
178     translate([pivot_x,0]) circle(r= pivot_r + pivot_slop, $fn=20);
179   }
180 }
181
182 module LeverSectBot(inadj=false){
183   P6 = inadj ? P6a : P6t;
184   mirror([0,1]) {
185     LeverSect(false, inadj);
186     PsHull([P5,P6,P7]);
187     PsHull([P8b,P8eb,P9eb,P9b]);
188     Ribbles(P8eb[0],
189             P9b[0],
190             P8eb[1]);
191     translate([pivot_x,0]) circle(r=pivot_r, $fn=20);
192   }
193 }
194
195 module Demo(){
196   translate([0,0,-5]) color("white") ExtrusionSect();
197   LeverSectTop();
198   translate([0,0,5]) LeverSectBot();
199   color("black") LeverSectBot(true);
200   color("blue") translate([0,0,10]) StrapSectTop();
201   color("purple") translate([0,0,-10]) StrapSectBot();
202 }
203
204 module SomeLever() {
205   // SomeLever(){ LeverBot(inadj); LeverSectBot(); }
206   difference(){
207     linear_extrude(height=width, convexity=100) children(0);
208     for (i = [ 0 : nstraps - 1 ]) {
209       translate([0,0, (i + 0.5) / nstraps * width - strap_width/2])
210         linear_extrude(height=strap_width, convexity=10)
211         children(1);
212     }
213   }
214 }
215
216 module Test(){
217   linear_extrude(height=test_width, convexity=100) {
218     translate([0,2,0]) LeverSectTop();
219     LeverSectBot();
220     translate([0,kit_adj_shift]) LeverSectBot(true);
221   }
222 }
223
224 module LeverTop(){ ////toplevel
225   SomeLever(){
226     LeverSectTop();
227     StrapSectTop();
228   }
229 }
230 module LeverBot(){ ////toplevel
231   SomeLever(){
232     LeverSectBot();
233     StrapSectBot();
234   }
235 }
236 module LeverBotAdj(){ ////toplevel
237   SomeLever(){
238     LeverSectBot(true);
239     StrapSectBot(true);
240   }
241 }
242
243 module Kit(){ ////toplevel
244   translate([0,2,0]) LeverTop();
245   LeverBot();
246 }
247
248 module KitAdj(){ ////toplevel
249   translate([0,2,0]) LeverTop();
250   LeverBotAdj();
251 }
252
253 //LeverSectBot(true);
254 //Demo();
255 //LeverTop();
256 //Test();
257 //Kit();
258 //KitAdj();