chiark / gitweb /
ksafe-base: fix main_sz
[reprap-play.git] / ksafe-base.scad
1 // -*- C -*-
2
3 // xxx from actual ksafe
4 bolt_above = 4;
5 wall_thick = 4;
6 bolthole_height = 4;
7 bolthole_width = 10;
8 main_sz = 300;
9 cnr_rad = 10;
10 lidinner_thick_allow = 20;
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 = 15;
24
25 // ----- calculated -----
26
27 gppA = [0,0];
28 gppB = gppA - [ wall_thick, 0 ];
29
30 gppL = [ gppB[0], -(lidinner_thick_allow + space + base_thick) ];
31
32 // anchor
33
34 anchor_b = anchor_thick + anchor_rad;
35 appM = gppL + anchor_b * [1,1];
36
37 a_bevel = 2 * anchor_b * (1 + sqrt(0.5));
38
39 module upp_app_Vars(t_bevel){
40   $xppE = gppL + t_bevel * [0,1];
41   $xppF = gppL + t_bevel * [1,0];
42
43   $xppJ = $xppE + wall_thick * [ 1, tan(22.5) ];
44   $xppI = $xppF + base_thick * [ tan(22.5), 1 ];
45
46   // must pass a_bevel for t_bevel for these to be valid
47   $gppP = gppA + [0,-1] * lidinner_thick_allow;
48   $gppQ = $gppP + [1,-1] * web_height;
49   $gppR = $xppJ + [ 1, tan(22.5) ] * web_height;
50   $gppS = $xppI + [ tan(22.5), 1 ] * web_height;
51   $gppT = [ $gppQ[0], $xppE[1] ];
52
53   children();
54 }
55
56 module upp_app_Profile(){
57   polygon([ gppA,
58             gppB,
59             $xppE,
60             $xppF,
61             $xppF + [1,0],
62             $xppI + [1,0],
63             $xppJ ]);
64 }
65
66
67 module UsualProfile(){
68   upp_app_Vars(bevel) upp_app_Profile();
69 }
70
71 module NearAnchorProfile(){
72   upp_app_Vars(a_bevel) upp_app_Profile();
73 }
74
75 module AnchorProfile(){
76   upp_app_Vars(a_bevel) {
77
78     upp_app_Profile();
79
80     difference(){
81       hull(){
82         polygon([ $xppE,
83                   $xppF,
84                   $xppF + [0,1],
85                   $xppE + [1,0] ]);
86         translate(appM) circle(r= anchor_b);
87       }
88       translate(appM) circle(r= anchor_rad);
89     }
90   }
91 }
92
93 module AnchorWallProfile(){
94   UsualProfile();
95   NearAnchorProfile();
96   hull(){
97     for (bev = [bevel, a_bevel]) {
98       upp_app_Vars(bev) {
99         polygon([ $xppE,
100                   $xppF,
101                   $xppI,
102                   $xppJ ]);
103       }
104     }
105   }
106 }
107
108 module WebProfile(){
109   upp_app_Vars(a_bevel){
110     if ($gppR[1] <= $gppP[1]) {
111       polygon([ $gppP,
112                 $xppE,
113                 $gppT,
114                 $gppQ ]);
115       polygon([ $gppP,
116                 $xppE,
117                 $xppF,
118                 $gppS,
119                 $gppR ]);
120     } else {
121       polygon([ $gppP,
122                 $xppE,
123                 $xppF,
124                 $gppS,
125                 $gppP + web_height * [1,0] ]);
126     }
127     polygon([ $gppS,
128               $xppF,
129               $xppF + [1,0],
130               $gppS + [1,0] ]);
131   }
132 }
133
134 module DemoProfiles(){
135   translate([0,0,-2]) color("yellow") AnchorWallProfile();
136   color("red") AnchorProfile();
137   translate([0,0,2]) color("black") NearAnchorProfile();
138   translate([0,0,4]) color("blue") UsualProfile();
139   translate([0,0,-4]) color("pink") WebProfile();
140 }
141
142 DemoProfiles();