chiark / gitweb /
248119ca0199a0b012f435fb766df96d9666dfd4
[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 = 5;
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           convexity=10);
65 }
66
67
68 module UsualProfile(){
69   upp_app_Vars(bevel) upp_app_Profile();
70 }
71
72 module NearAnchorProfile(){
73   upp_app_Vars(a_bevel) upp_app_Profile();
74 }
75
76 module AnchorProfile(){
77   upp_app_Vars(a_bevel) {
78
79     upp_app_Profile();
80
81     difference(){
82       hull(){
83         polygon([ $xppE,
84                   $xppF,
85                   $xppF + [0,1],
86                   $xppE + [1,0] ],
87           convexity=10);
88         translate(appM) circle(r= anchor_b);
89       }
90       translate(appM) circle(r= anchor_rad);
91     }
92   }
93 }
94
95 module AnchorWallProfile(){
96   UsualProfile();
97   NearAnchorProfile();
98   hull(){
99     for (bev = [bevel, a_bevel]) {
100       upp_app_Vars(bev) {
101         polygon([ $xppE,
102                   $xppF,
103                   $xppI,
104                   $xppJ ],
105           convexity=10);
106       }
107     }
108   }
109 }
110
111 module WebProfile(){
112   upp_app_Vars(a_bevel){
113     if ($gppR[1] <= $gppP[1]) {
114       polygon([ $gppP,
115                 $xppE,
116                 $gppT,
117                 $gppQ ]);
118       polygon([ $gppP,
119                 $xppE,
120                 $xppF,
121                 $gppS,
122                 $gppR ],
123           convexity=10);
124     } else {
125       polygon([ $gppP,
126                 $xppE,
127                 $xppF,
128                 $gppS,
129                 $gppP + web_height * [1,0] ],
130           convexity=10);
131     }
132     polygon([ $gppS,
133               $xppF,
134               $xppF + [1,0],
135               $gppS + [1,0] ],
136           convexity=10);
137   }
138 }
139
140 module DemoProfiles(){
141   translate([0,0,-2]) color("yellow") AnchorWallProfile();
142   color("red") AnchorProfile();
143   translate([0,0,2]) color("black") NearAnchorProfile();
144   translate([0,0,4]) color("blue") UsualProfile();
145   translate([0,0,-4]) color("pink") WebProfile();
146 }
147
148 DemoProfiles();