chiark / gitweb /
87a603180b52e77ffbfd06e307eb8839637f1e85
[reprap-play.git] / ksafe-base.scad
1 // -*- C -*-
2
3 // from actual ksafe
4 bolt_above = 8.50 - 0.50;
5 bolthole_height = 4.24 + 1.00;
6 wall_thick = 4.50;
7 bolthole_width = 16.62 + 2.00;
8 main_sz = 150.56 + 0.75;
9 cnr_rad = 13.5; // approx
10 lidinner_thick_allow = 20.78 + 0.50;
11
12 // other parameters
13 web_thick = 4;
14 web_height = 20; // excluding wall and base thick
15 bolthole_rhs = 20;
16 bolthole_lhs = 20;
17 boltreinf_thick = 6;
18 anchor_wall_space = 25;
19 base_thick = 4;
20 space = 25;
21 anchor_thick = 4;
22 anchor_rad = 4;
23 bevel = 8;
24
25 // ----- calculated -----
26
27 hsz = main_sz/2;
28
29 gppA = [0,0];
30 gppB = gppA - [ wall_thick, 0 ];
31
32 gppL = [ gppB[0], -(lidinner_thick_allow + space + base_thick) ];
33
34 yw1 = -web_thick/2;
35 yw2 = yw1 - bolthole_rhs;
36 yw3 = yw2 - anchor_thick;
37 yw4 = yw3 - anchor_wall_space;
38 yw5 = yw4 - wall_thick;
39 yw6 = -(hsz - cnr_rad + 0.1);
40
41 yw10 = web_thick/2;
42 yw11 = yw2 + anchor_wall_space;
43 yw12 = yw11 + wall_thick;
44 yw13 = -yw6;
45
46 // anchor
47
48 anchor_b = anchor_thick + anchor_rad;
49 appM = gppL + anchor_b * [1,1];
50
51 a_bevel = 2 * anchor_b * (1 + sqrt(0.5));
52
53 module upp_app_Vars(t_bevel){
54   $xppE = gppL + t_bevel * [0,1];
55   $xppF = gppL + t_bevel * [1,0];
56
57   $xppJ = $xppE + wall_thick * [ 1, tan(22.5) ];
58   $xppI = $xppF + base_thick * [ tan(22.5), 1 ];
59
60   // must pass a_bevel for t_bevel for these to be valid
61   $gppP = gppA + [0,-1] * lidinner_thick_allow;
62   $gppQ = $gppP + [1,-1] * web_height;
63   $gppR = $xppJ + [ 1, tan(22.5) ] * web_height;
64   $gppS = $xppI + [ tan(22.5), 1 ] * web_height;
65   $gppT = [ $gppQ[0], $xppE[1] ];
66
67   children();
68 }
69
70 module upp_app_Profile(){
71   polygon([ gppA,
72             gppB,
73             $xppE,
74             $xppF,
75             $xppF + [1,0],
76             $xppI + [1,0],
77             $xppJ ],
78           convexity=10);
79 }
80
81
82 module UsualProfile(){
83   upp_app_Vars(bevel) upp_app_Profile();
84 }
85
86 module NearAnchorProfile(){
87   upp_app_Vars(a_bevel) upp_app_Profile();
88 }
89
90 module AnchorProfile(){
91   upp_app_Vars(a_bevel) {
92
93     upp_app_Profile();
94
95     difference(){
96       hull(){
97         polygon([ $xppE,
98                   $xppF,
99                   $xppF + [0,1],
100                   $xppE + [1,0] ],
101           convexity=10);
102         translate(appM) circle(r= anchor_b);
103       }
104       translate(appM) circle(r= anchor_rad);
105     }
106   }
107 }
108
109 module AnchorWallProfile(){
110   UsualProfile();
111   NearAnchorProfile();
112   hull(){
113     for (bev = [bevel, a_bevel]) {
114       upp_app_Vars(bev) {
115         polygon([ $xppE,
116                   $xppF,
117                   $xppI,
118                   $xppJ ],
119           convexity=10);
120       }
121     }
122   }
123 }
124
125 module WebProfile(){
126   upp_app_Vars(a_bevel){
127     if ($gppR[1] <= $gppP[1]) {
128       polygon([ $gppP,
129                 $xppE,
130                 $gppT,
131                 $gppQ ]);
132       polygon([ $gppP,
133                 $xppE,
134                 $xppF,
135                 $gppS,
136                 $gppR ],
137           convexity=10);
138     } else {
139       polygon([ $gppP,
140                 $xppE,
141                 $xppF,
142                 $gppS,
143                 $gppP + web_height * [1,0] ],
144           convexity=10);
145     }
146     polygon([ $gppS,
147               $xppF,
148               $xppF + [1,0],
149               $gppS + [1,0] ],
150           convexity=10);
151   }
152 }
153
154 module SomeBaseProfile(I, F){
155   polygon([ I,
156             F,
157             [ hsz+1, F[1] ],
158             [ hsz+1, I[1] ] ]);
159 }
160
161 module BaseProfile(){
162   SomeBaseProfile($xppI, $xppF);
163 }
164
165 module SWalls(ymin, ymax, t_bevel) {
166   upp_app_Vars(t_bevel) {
167     translate([0,ymin,0])
168       mirror([0,1,0])
169       rotate([90,0,0])
170       linear_extrude(height= ymax-ymin, convexity=10)
171       for (xm=[0,1])
172         mirror([xm,0])
173           translate([-hsz, 0])
174             children();
175   }
176 }
177
178 module AtTwoCorners(){
179   for (xm=[0,1]) {
180     mirror([xm,0,0]) 
181     translate((hsz - cnr_rad) * [1,1])
182     intersection(){
183       rotate_extrude(convexity=10)
184         translate([-cnr_rad,0])
185         children();
186       translate([0,0,-250])
187         cube([50,50,500]);
188     }
189   }
190 }
191
192 module Box(){
193   /// corners, and front and back of base
194   for (ym=[0,1]) mirror([0,ym,0]) {
195     AtTwoCorners(){
196       UsualProfile();
197     }
198     hull() AtTwoCorners(){
199       upp_app_Vars(bevel){
200         polygon([ $xppI,
201                   $xppF,
202                   $xppF + [0.1, 0],
203                   $xppI + [0.1, 0]
204                   ]);
205       }
206     }
207   }
208
209   // side walls and base
210   SWalls(yw6 , yw4 , bevel  ) { UsualProfile();      BaseProfile(); }
211   SWalls(yw5 , yw4 , a_bevel) { AnchorWallProfile(); BaseProfile(); }
212   SWalls(yw5 , yw12, a_bevel) { NearAnchorProfile(); BaseProfile(); }
213   SWalls(yw3 , yw2 , a_bevel) { AnchorProfile();     BaseProfile(); }
214   SWalls(yw11, yw12, a_bevel) { AnchorWallProfile(); BaseProfile(); }
215   SWalls(yw11, yw13, bevel  ) { UsualProfile();      BaseProfile(); }
216   SWalls(yw1,  yw10, a_bevel) { WebProfile(); SomeBaseProfile($gppS, $xppF); }
217
218   // front and rear walls
219   rotate([0,0,90]) SWalls(yw6, yw13, bevel) UsualProfile();
220 }
221
222 module KsafeBase(){
223   difference(){
224     Box();
225
226     // bolt holes
227     translate([0,0, -bolt_above -0.5 * bolthole_height])
228       cube(center=true, [ main_sz + 20, bolthole_width, bolthole_height ]);
229   }
230 }
231
232 module DemoProfiles(){
233   translate([0,0,-2]) color("yellow") AnchorWallProfile();
234   color("red") AnchorProfile();
235   translate([0,0,2]) color("black") NearAnchorProfile();
236   translate([0,0,4]) color("blue") UsualProfile();
237   translate([0,0,-4]) color("pink") WebProfile();
238 }
239
240 //DemoProfiles();
241 //Box();
242 KsafeBase();