chiark / gitweb /
ksafe-base: adjust bevel
[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 = 45;
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 // anchor
35
36 anchor_b = anchor_thick + anchor_rad;
37 appM = gppL + anchor_b * [1,1];
38
39 a_bevel = 2 * anchor_b * (1 + sqrt(0.5));
40
41 module upp_app_Vars(t_bevel){
42   $xppE = gppL + t_bevel * [0,1];
43   $xppF = gppL + t_bevel * [1,0];
44
45   $xppJ = $xppE + wall_thick * [ 1, tan(22.5) ];
46   $xppI = $xppF + base_thick * [ tan(22.5), 1 ];
47
48   // must pass a_bevel for t_bevel for these to be valid
49   $gppP = gppA + [0,-1] * lidinner_thick_allow;
50   $gppQ = $gppP + [1,-1] * web_height;
51   $gppR = $xppJ + [ 1, tan(22.5) ] * web_height;
52   $gppS = $xppI + [ tan(22.5), 1 ] * web_height;
53   $gppT = [ $gppQ[0], $xppE[1] ];
54
55   children();
56 }
57
58 module upp_app_Profile(){
59   polygon([ gppA,
60             gppB,
61             $xppE,
62             $xppF,
63             $xppF + [1,0],
64             $xppI + [1,0],
65             $xppJ ],
66           convexity=10);
67 }
68
69
70 module UsualProfile(){
71   upp_app_Vars(bevel) upp_app_Profile();
72 }
73
74 module NearAnchorProfile(){
75   upp_app_Vars(a_bevel) upp_app_Profile();
76 }
77
78 module AnchorProfile(){
79   upp_app_Vars(a_bevel) {
80
81     upp_app_Profile();
82
83     difference(){
84       hull(){
85         polygon([ $xppE,
86                   $xppF,
87                   $xppF + [0,1],
88                   $xppE + [1,0] ],
89           convexity=10);
90         translate(appM) circle(r= anchor_b);
91       }
92       translate(appM) circle(r= anchor_rad);
93     }
94   }
95 }
96
97 module AnchorWallProfile(){
98   UsualProfile();
99   NearAnchorProfile();
100   hull(){
101     for (bev = [bevel, a_bevel]) {
102       upp_app_Vars(bev) {
103         polygon([ $xppE,
104                   $xppF,
105                   $xppI,
106                   $xppJ ],
107           convexity=10);
108       }
109     }
110   }
111 }
112
113 module WebProfile(){
114   upp_app_Vars(a_bevel){
115     if ($gppR[1] <= $gppP[1]) {
116       polygon([ $gppP,
117                 $xppE,
118                 $gppT,
119                 $gppQ ]);
120       polygon([ $gppP,
121                 $xppE,
122                 $xppF,
123                 $gppS,
124                 $gppR ],
125           convexity=10);
126     } else {
127       polygon([ $gppP,
128                 $xppE,
129                 $xppF,
130                 $gppS,
131                 $gppP + web_height * [1,0] ],
132           convexity=10);
133     }
134     polygon([ $gppS,
135               $xppF,
136               $xppF + [1,0],
137               $gppS + [1,0] ],
138           convexity=10);
139   }
140 }
141
142 module KsafeBase(){
143   for (xm=[0,1]) for (ym=[0,1]) {
144     mirror([xm,0]) mirror([0,ym])
145     translate((hsz - cnr_rad) * [1,1])
146     intersection(){
147       rotate_extrude(convexity=10)
148         translate([-cnr_rad,0])
149         UsualProfile();
150       translate([0,0,-250])
151         cube([50,50,500]);
152     }
153   }
154 }
155
156 module DemoProfiles(){
157   translate([0,0,-2]) color("yellow") AnchorWallProfile();
158   color("red") AnchorProfile();
159   translate([0,0,2]) color("black") NearAnchorProfile();
160   translate([0,0,4]) color("blue") UsualProfile();
161   translate([0,0,-4]) color("pink") WebProfile();
162 }
163
164 //DemoProfiles();
165 KsafeBase();