chiark / gitweb /
973ec8d3bd49478493628caf3a4558351e539874
[reprap-play.git] / ksafe-base.scad
1 // -*- C -*-
2
3 // xxx from actual ksafe, needs slop adding
4 bolt_above = 14.30;
5 bolthole_height = 4.24;
6 wall_thick = 4.50;
7 bolthole_width = 16.62;
8 main_sz = 150.56;
9 cnr_rad = 13.5; // approx
10 lidinner_thick_allow = 20.78;
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 BaseProfile(){
155   polygon([ $xppI,
156             $xppF,
157             [ hsz+1, $xppF[1] ],
158             [ hsz+1, $xppI[1] ] ]);
159 }
160
161 module SWalls(ymin, ymax, t_bevel) {
162   upp_app_Vars(t_bevel) {
163     translate([0,ymin,0])
164       mirror([0,1,0])
165       rotate([90,0,0])
166       linear_extrude(height= ymax-ymin, convexity=10)
167       for (xm=[0,1])
168         mirror([xm,0])
169           translate([-hsz, 0])
170             children();
171   }
172 }
173
174 module KsafeBase(){
175   /// corners
176   for (xm=[0,1]) for (ym=[0,1]) {
177     mirror([xm,0,0]) mirror([0,ym,0])
178     translate((hsz - cnr_rad) * [1,1])
179     intersection(){
180       rotate_extrude(convexity=10)
181         translate([-cnr_rad,0])
182         UsualProfile();
183       translate([0,0,-250])
184         cube([50,50,500]);
185     }
186   }
187
188   // side walls and base
189   SWalls(yw6 , yw4 , bevel  ) { UsualProfile();      BaseProfile(); }
190   SWalls(yw5 , yw4 , a_bevel) { AnchorWallProfile(); BaseProfile(); }
191   SWalls(yw5 , yw12, a_bevel) { NearAnchorProfile(); BaseProfile(); }
192   SWalls(yw3 , yw2 , a_bevel) { AnchorProfile();     BaseProfile(); }
193   SWalls(yw11, yw12, a_bevel) { AnchorWallProfile(); BaseProfile(); }
194   SWalls(yw11, yw13, bevel  ) { UsualProfile();      BaseProfile(); }
195 }
196
197 module DemoProfiles(){
198   translate([0,0,-2]) color("yellow") AnchorWallProfile();
199   color("red") AnchorProfile();
200   translate([0,0,2]) color("black") NearAnchorProfile();
201   translate([0,0,4]) color("blue") UsualProfile();
202   translate([0,0,-4]) color("pink") WebProfile();
203 }
204
205 //DemoProfiles();
206 KsafeBase();