chiark / gitweb /
lock-inframe-bracket: Add ref to Wolfram
[reprap-play.git] / lock-inframe-bracket.scad
1 // -*- C -*-
2
3 include <funcs.scad>
4
5 tube_dia = 27.5 + 1.625;
6 lock_w = 42.5 + 0.5;
7 lock_d = 28.0 + 0.5;
8 main_h = 45.0;
9 backflange_d = 12;
10 lockshaft_dia = 14.35;
11
12 cliprecess_h = 16;
13 total_h = 45;
14
15 back_gap = 12.5;
16 main_th = 2.75;
17 tube_th = 2.25;
18
19 midweb_d = 3;
20 clip_th = 3.5;
21 clip_gap = 2.5;
22 clip_d = 22.0;
23
24 mountscrew_dia = 4 + 0.5;
25 clipbolt_dia = 5 + 0.1;
26
27 backflange_th = 4.5;
28
29 $fn=50;
30
31 join_cr = 7;
32
33 tube_rear_extra_th = 1;
34
35 // calculated
36
37 lockshaft_r = [1, 1] * lockshaft_dia / 2;
38 front_th = main_th;
39
40 tube_or = tube_dia/2 + tube_th;
41 back_ohw = back_gap/2 + backflange_th;
42 backflange_ymin = tube_or+backflange_d;
43
44 lock_0y = tube_dia/2 + lock_d/2 + midweb_d;
45 lock_0x = lock_w/2 - lock_d/2;
46 lock_0 = [lock_0x,lock_0y];
47
48 lock_or = [lock_w, lock_d]/2 + [front_th,front_th];
49
50 module oval(sz){ // sz[0] > sz[1]
51   xr = sz[0];
52   yr = sz[1];
53   hull(){
54     for (sx=[-1,+1]) {
55       translate([sx * (xr-yr), 0])
56         circle(r=yr);
57     }
58   }
59 }
60
61 module JoinCircs(jr){
62   # http://mathworld.wolfram.com/Circle-CircleIntersection.html
63   R = tube_or + join_cr;
64   r = lock_or[1] + join_cr;
65   d = dist2d( [0,0], lock_0 );
66   x = (d*d - r*r + R*R) / (2*d);
67   y = sqrt( R*R - x*x );
68
69   echo(lock_0x, lock_0y, R,r, d, x,y);
70
71   for (m=[0,1]) {
72     mirror([m,0]) {
73       rotate(atan2(lock_0y, lock_0x)) {
74         translate([x,-y])
75           circle(r= jr);
76       }
77     }
78   }
79 }
80
81 module MainPlan(){
82   difference(){
83     union(){
84       hull(){
85         for (t=[0, tube_rear_extra_th])
86           translate([0, -t])
87             circle(r = tube_or);
88       }
89       translate([-back_ohw,0]) mirror([0,1])
90         square([back_ohw*2, backflange_ymin]);
91
92       translate([0, lock_0y]){
93         oval(lock_or);
94       }
95
96       hull(){
97         JoinCircs(0.01);
98         polygon([[0,0], lock_0, [-lock_0[0], lock_0[1]]]);
99       }
100     }
101
102     circle(r = tube_dia/2);
103     translate([-back_gap/2,1]) mirror([0,1])
104       square([back_gap, backflange_ymin+2]);
105
106     translate([0, lock_0y]){
107       oval([lock_w/2, lock_d/2]);
108     }
109
110     JoinCircs(join_cr);
111   }
112 }
113
114 lockshaft_or = lockshaft_r + [clip_th,clip_th];
115 cliprecess_ymax = cliprecess_h - lockshaft_r[1];
116 clip_ymin = cliprecess_ymax - total_h;
117 clip_ogap = clip_gap + clip_th*2;
118
119 module ClipElevationPositive(){
120   hull(){
121     oval(lockshaft_or);
122     translate([0, -lockshaft_or[1] * sqrt(2)])
123       square(center=true, 0.5);
124   }
125   translate([-lockshaft_or[0], 0])
126     square([lockshaft_or[0]*2, cliprecess_ymax]);
127   translate([-clip_ogap/2, 0]) mirror([0,1]) square([clip_ogap, -clip_ymin]);
128 }
129
130 module ClipElevationNegative(){
131   hull(){
132     for (y=[0, cliprecess_ymax+1])
133       translate([0, y])
134         oval(lockshaft_r);
135   }
136   translate([-clip_gap/2, 1]) mirror([0,1]) square([clip_gap, 2-clip_ymin]);
137 }
138
139 module ClipElevation(){
140   difference(){
141     ClipElevationPositive(1);
142     ClipElevationNegative(0);
143   }
144 }
145
146 module ExtrudeClipElevation(extra=0){
147   translate([0,
148              lock_0y + lock_d/2 + clip_d + extra,
149              -clip_ymin])
150     rotate([90,0,0])
151     linear_extrude(height= clip_d + extra*2, convexity=100)
152     children(0);
153 }
154
155 module ThroughHole(r, y, z) {
156   translate([-50, y, z])
157     rotate([0, 90, 0])
158     cylinder(r=r, h=100, $fn=20);
159 }
160
161 module ThroughHoles(){
162   for (z=[ 1/4, 3/4 ]) {
163     ThroughHole( mountscrew_dia/2,
164                  -tube_or -0.5*backflange_d,
165                  total_h * z );
166   }
167
168   ThroughHole( clipbolt_dia/2,
169                lock_0y + lock_d/2 + clip_d/2 + front_th/2,
170                total_h - cliprecess_h - clip_th - clip_d/2 );
171 }
172
173 module MainPositive(){
174   difference(){
175     union(){
176       linear_extrude(height=total_h, convexity=100) MainPlan();
177       ExtrudeClipElevation() ClipElevationPositive();
178     }
179     ExtrudeClipElevation(1) ClipElevationNegative();
180   }
181 }
182
183 module Bracket(){ //// toplevel
184   difference(){
185     MainPositive();
186     ThroughHoles();
187   }
188 }
189
190 module TestTopEdge(){ //// toplevel
191   intersection(){
192     translate([0,0, -total_h])
193       translate([0,0, 4])
194       Bracket();
195     translate([-200,-200,0])
196       cube([400,400,100]);
197   }
198 }
199
200 module TestClipBoltHole(){ //// toplevel
201   intersection(){
202     union(){
203       translate([0, 0, -5])
204         Bracket();
205       translate([-4, lock_0y + lock_d/2 + 1, 0])
206         cube([8, 4, 1.5]);
207     }
208     translate([-200, lock_0y + lock_d/2 + 0.1])
209       cube([400, 400, total_h-20]);
210   }
211 }
212
213 //MainPlan();
214 //ClipElevationPositive();
215 //ClipElevation();
216 //MainPositive();
217 //%ThroughHoles();
218 //TestTopEdge();
219 //TestClipBoltHole();
220
221 //Bracket();