chiark / gitweb /
a4e51c4cee596611523f695f977270a7079914bc
[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 SWalls(ymin, ymax, t_bevel) {
155   upp_app_Vars(t_bevel) {
156     translate([0,ymin,0])
157       mirror([0,1,0])
158       rotate([90,0,0])
159       linear_extrude(height= ymax-ymin, convexity=10)
160       union(){
161         for (xm=[0,1]) {
162           mirror([xm,0])
163             translate([-hsz, 0])
164             children();
165         }
166       }
167   }
168 }
169
170 module KsafeBase(){
171   /// corners
172   for (xm=[0,1]) for (ym=[0,1]) {
173     mirror([xm,0,0]) mirror([0,ym,0])
174     translate((hsz - cnr_rad) * [1,1])
175     intersection(){
176       rotate_extrude(convexity=10)
177         translate([-cnr_rad,0])
178         UsualProfile();
179       translate([0,0,-250])
180         cube([50,50,500]);
181     }
182   }
183
184   // side walls
185   SWalls(yw6 , yw4 , bevel  ) UsualProfile();
186   SWalls(yw5 , yw4 , a_bevel) AnchorWallProfile();
187   SWalls(yw5 , yw12, a_bevel) NearAnchorProfile();
188   SWalls(yw3 , yw2 , a_bevel) AnchorProfile();
189   SWalls(yw11, yw12, a_bevel) AnchorWallProfile();
190   SWalls(yw11, yw13, bevel  ) UsualProfile();
191 }
192
193 module DemoProfiles(){
194   translate([0,0,-2]) color("yellow") AnchorWallProfile();
195   color("red") AnchorProfile();
196   translate([0,0,2]) color("black") NearAnchorProfile();
197   translate([0,0,4]) color("blue") UsualProfile();
198   translate([0,0,-4]) color("pink") WebProfile();
199 }
200
201 //DemoProfiles();
202 KsafeBase();