chiark / gitweb /
fairphone-case: slant keeper
[reprap-play.git] / sprinkler-spike-receptacle.scad
1 // -*- C -*-
2
3 main_height = 95;
4
5 spike_web_thick = 2.52 + 0.75;
6
7 spike_top_width = 21.04 + 1.5;
8
9 spike_botpos_height = 9.5;
10 spike_botpos_width = 11.68 + 0.00;
11
12 topwall_width = 1.5;
13
14 mount_dist = 20;
15 mount_width = 10;
16 mount_height = 5;
17 mount_hole_dia = 4.5;
18 mount_head_dia = 7.5;
19 mount_hole_th = 2.5;
20
21 strap_height = main_height * 0.5;
22
23 strap_width = 5.5;
24 strap_thick = 2.5;
25 strap_around = 2.5;
26 strap_fixing_height = 4.0;
27 strap_fixing_slope = 1.0;
28
29 // calculated
30
31 main_width = spike_top_width + topwall_width*2;
32
33 pos_web_thick = spike_web_thick + topwall_width*2;
34
35 module NegativePlan(){
36   x4z =
37     (spike_top_width - spike_botpos_width) /
38     (main_height - spike_botpos_height);
39
40   x0 = (spike_botpos_width - x4z * spike_botpos_height)/2;
41   x1 =  spike_top_width/2;
42   z1 = main_height;
43
44   polygon([[ x0, -5],
45            [ x0, 0],
46            [ x1, z1],
47            [ x1, z1+5],
48            [-x1, z1+5],
49            [-x1, z1],
50            [-x0, 0],
51            [-x0, -5]]);
52 }
53
54 module SomeMidRounding(sq_size, z_extra) {
55   translate([0,0,-z_extra])
56     linear_extrude(height= main_height + z_extra*2)
57     rotate(45)
58     square( sq_size, center=true );
59 }
60
61 module PositiveMidRounding(){
62   SomeMidRounding(pos_web_thick*2, 0);
63 }
64
65 module NegativeMidRounding(){
66   SomeMidRounding(spike_web_thick*2.5, 5);
67 }
68
69 module PositivePlan(){
70   w = main_width;
71   translate([ -w/2, 0 ])
72     square([ w, main_height ]);
73 }
74
75 module MultiplySolidifyPlan(th){
76   for (r=[0,90]) {
77     rotate([0,0,r])
78       rotate([90,0,0])
79       translate([0,0,-th/2])
80       linear_extrude(height=th)
81       children(0);
82   }
83 }
84
85 module MultiplyForFixings(){
86   for (r=[0:90:270])
87     rotate([0,0,r])
88     children(0);
89 }
90
91 module FixingsPositive(){
92   // mount
93   translate([ -1,
94               -mount_width/2,
95               0 ])
96     cube([ mount_dist + mount_width/2 + 1,
97            mount_width,
98            mount_height ]);
99
100   // strap
101   for (m=[0,1]) mirror([0,m,0]) {
102       translate([main_width/2, 0, strap_height]) {
103         hull(){
104           translate([ -strap_around,
105                       -pos_web_thick/2,
106                       -(strap_thick + strap_around) / strap_fixing_slope ])
107             cube([ strap_around,
108                    pos_web_thick/2 - strap_width/2,
109                    0.5 ]);
110           translate([ -strap_around,
111                       -(strap_around + strap_width/2),
112                       0 ])
113             cube([ strap_around*2 + strap_thick,
114                    strap_around,
115                    strap_fixing_height ]);
116         }
117         mirror([0,1,0])
118           translate([ strap_thick,
119                       -strap_width/2,
120                       0 ])
121           cube([ strap_around,
122                  strap_around + strap_width,
123                  strap_fixing_height ]);
124       }
125     }
126 }
127
128 module FixingsNegative(){
129   // mount hole
130   translate([ mount_dist, 0,0 ]) {
131     translate([0,0, -1])
132       cylinder(r= mount_hole_dia/2, h= 20, $fn=20);
133     translate([0,0, mount_hole_th])
134       cylinder(r = mount_head_dia/2, h=20, $fn=20);
135   }
136 }
137
138 module Main(){
139   difference(){
140     union(){
141       MultiplySolidifyPlan(pos_web_thick) PositivePlan();
142       PositiveMidRounding();
143       MultiplyForFixings() FixingsPositive();
144     }
145     MultiplySolidifyPlan(spike_web_thick) NegativePlan();
146     NegativeMidRounding();
147     MultiplyForFixings() FixingsNegative();
148   }
149 }
150
151 module PlanTest(){
152   linear_extrude(height=2.0){
153     difference(){
154       PositivePlan();
155       NegativePlan();
156     }
157     difference(){
158       circle(r = spike_botpos_width/2 + 5);
159       circle(r = spike_botpos_width/2);
160       translate([-50, 0]) square([100,50]);
161     }
162   }
163   linear_extrude(height=4.0){
164     difference(){
165       translate([ -main_width/2, 0 ]) square([ main_width, 2 ]);
166       NegativePlan();
167     }
168   }
169 }
170
171 module MainFitTest(){
172   for (top = [0,1]) {
173     translate([ top * (mount_dist*2 + mount_width), 0,0 ]){
174       intersection(){
175         translate([0, 0, (-main_height + 0.5) * top])
176           Main();
177         translate([-50,-50,0])
178           cube([100,100, spike_botpos_height + 1.5]);
179       }
180     }
181   }
182 }
183
184 module Tests(){
185   translate([-mount_dist*3, 0,0])
186     PlanTest();
187   MainFitTest();
188 }
189
190 module StrapFixingTest(){
191   intersection(){
192     Main();
193     translate([ -10, -10, 40 ])
194       cube([ 20, 40, 15 ]);
195   }
196 }
197
198 //Tests();
199 //StrapFixingTest();
200 Main();