4 include <commitid.scad>
24 interlock_fine = 0.66;
26 interlock_fine_slope = 1.0;
27 interlock_fine_lenslop = 1.0;
33 cutout_l_end_y_front_slop = 0.5;
34 cutout_l_end_y_rear_slop = 0.5;
37 cutout_l_end_curve = 1;
38 cutout_l_end_y_total = cutout_l_end_y
39 + cutout_l_end_y_front_slop + cutout_l_end_y_rear_slop;
43 cutout_tile01_y = 170 - 147 + cutout_l_end_y_front_slop;
44 cutout_tile11_x = 22 + cutout_l_end_curve;
45 cutout_tile11_y = cutout_l_end_y_total - cutout_tile01_y;
51 ply_edge_hole_dist = ply_edge_min + ply_hole_dia/2;
53 echo(str("HOLES IN PLY ctr dist from PLY edge = ", ply_edge_hole_dist));
55 hole_slop = (ply_hole_dia - post_dia)/2;
56 tile_hard_edge_hole_dist = ply_edge_hole_dist + hole_slop;
58 echo(str("HOLES IN PLY ctr dist from TILE HARD edge = ",
59 tile_hard_edge_hole_dist));
61 echo(str("HOLES IN PLY ctr dist from TILE ROUND edge = ",
62 tile_hard_edge_hole_dist + round_edge_rad));
64 thehd = [ tile_hard_edge_hole_dist, tile_hard_edge_hole_dist ];
66 thehd_tl = [ -thehd_tr[0], thehd_tr[1] ];
70 interlock_rad = interlock_dia/2;
71 interlock_negative_rad = interlock_rad + 0.125;
73 interlock_sq_adj = 0.2; // arbitrary
78 cylinder(r= post_dia/2, h= tile_th + ply_th - post_shorter);
79 translate([0,0, tile_th]) {
80 cylinder(r= screw_big_dia/2, h= screw_big_len);
81 cylinder(r= screw_dia/2, h= ply_th, $fn=20);
85 tsz = tile_hard_edge_hole_dist - test_edge + 1;
86 translate([0,0, tile_th/2]) {
87 cube([post_dia, tsz*2, tile_th], center=true);
88 cube([tsz*2, post_dia, tile_th], center=true);
96 translate(concat(p, [0]))
101 module TileBase(botleft, topright){
102 size = topright - botleft;
103 botleft_post = botleft + thehd_tr;
104 topright_post = topright + thehd_bl;
107 translate(concat(botleft, [0]))
108 cube(concat(size, [tile_th]));
110 translate( concat(botleft_post, [ -tile_th ])
111 + 0.5 * [ post_dia, post_dia, 0 ] )
112 Commitid_BestCount_M( topright_post-botleft_post
113 + [-post_dia,-post_dia]
117 translate( concat(botleft + [thehd[0], 0], [0]) )
118 Commitid_BestCount([ size[0] - thehd[0]*2, thehd[1] ]);
121 translate(concat(botleft + [test_edge,test_edge], [test_tile_th]))
122 cube(concat(size - [test_edge,test_edge]*2, [tile_th]));
123 translate(concat(botleft_post, [-1]))
124 cube(concat(topright_post-botleft_post, [tile_th+2]));
128 cube(max(test_edge, tile_hard_edge_hole_dist)*2, center=true);
135 m4_dnl INREFFRAME(left_cnr, right_cnr, morevars) { body; }
136 m4_define(`INREFFRAME',`
137 length_vec = ($2) - ($1);
138 length = dist2d([0,0], length_vec);
139 length_uvec = length_vec / length;
140 ortho_uvec = [ -length_uvec[1], length_uvec[0] ];
141 m = [ [ length_uvec[0], ortho_uvec[0], 0, ($1)[0], ],
142 [ length_uvec[1], ortho_uvec[1], 0, ($1)[1], ],
149 m4_dnl INREFFRAME(left_cnr, right_cnr, morevars)
150 m4_dnl INREFFRAME_EDGE { body; }
151 m4_define(`INREFFRAME_EDGE',`
152 translate([0,0, -round_edge_rad])
155 module RoundEdge(left_cnr, right_cnr) {
156 INREFFRAME(left_cnr, right_cnr)
160 cylinder(r= round_edge_rad, h= length, $fn=50);
161 translate([-1, 0, -20])
162 cube([length+2, 20, 20]);
167 module RoundCornerCut(ci) {
168 // ci should be [this_cnr, right_cnr]
169 // where right_cnr is to the right (ie, anticlockwise)
172 offr= round_cnr_rad - round_edge_rad;
173 INREFFRAME(this_cnr, right_cnr) INREFFRAME_EDGE {
175 cube(offr*2 - 0.1, center=true);
176 translate([offr, offr, 0])
177 cylinder(center=true, h=20, r= offr);
182 module RoundCornerAdd(ci) {
185 bigr = round_cnr_rad - round_edge_rad;
186 INREFFRAME(this_cnr, right_cnr) INREFFRAME_EDGE {
188 cube(bigr*2 + 0.1, center=true);
189 translate([bigr, bigr, 0])
190 rotate_extrude(convexity=10, $fn=50)
193 circle(r= round_edge_rad, $fn=50);
201 module InterlockLobePlan(negative) {
202 r = negative ? interlock_negative_rad : interlock_rad;
203 ymir = negative ? 0 : 1;
207 translate([thehd[0], 0]){
211 translate([-dx, -0.1])
212 square([ dx*2, r/2 + 0.1 ]);
214 translate([ xi*dx, r ])
222 module InterlockEdgePlan(negative, nlobes, length, dosquare=true) {
223 for (lobei = [ 0 : nlobes-1 ]) {
224 lobex = (length - thehd[0]*2) * (lobei ? lobei / (nlobes-1) : 0);
225 translate([lobex, 0, 0]) {
226 InterlockLobePlan(negative);
232 slotshorter = negative ? -0.1 : interlock_fine_lenslop;
233 mirror([0, negative])
234 translate([slotshorter, iadj])
235 square([length - slotshorter*2, interlock_fine + iadj*2]);
239 module InterlockEdge(left_cnr, right_cnr, negative=0, nlobes=2) {
240 plusth = negative * 1.0;
241 protr = interlock_fine + interlock_sq_adj;
244 z1 = -tile_th/2 - protr / interlock_fine_slope;
245 z3 = -tile_th/2 + protr / interlock_fine_slope;
247 negsign = negative ? -1 : +1;
248 yprotr = negsign * protr;
250 INREFFRAME(left_cnr, right_cnr) {
251 for (vsect = [ // zs0 zs1 ys0, ys1
252 [ -tile_th-plusth, plusth, 0, 0],
253 [ z1, z2, 0, yprotr],
254 [ z2, z3, yprotr, 0],
264 [ 0,1, -sl, -ys0 + negsign*interlock_sq_adj ],
268 linear_extrude(height=zsd, convexity=10)
269 InterlockEdgePlan(negative, nlobes, length, !!ysd);
274 function TestPiece_holes2corners(holes) =
275 [ holes[0] + thehd_bl,
278 holes[0] + thehd_tl ];
280 module TestPiece1(){ ////toplevel
284 corners = TestPiece_holes2corners(holes);
285 rcs = [corners[0], corners[1]];
288 TileBase(corners[0], corners[2]);
290 RoundEdge(corners[0], corners[1]);
291 RoundEdge(corners[3], corners[0]);
293 InterlockEdge(corners[1], corners[2], 1, nlobes=1);
299 module TestPiece2(){ ////toplevel
303 corners = TestPiece_holes2corners(holes);
304 TileBase(corners[0], corners[2]);
306 RoundEdge(corners[0], corners[1]);
307 InterlockEdge(corners[3], corners[0], 0, nlobes=1);
310 module TestDemo(){ ////toplevel
311 translate([ -thehd[0], 0 ])
314 translate([ +thehd[0] + demo_slop, 0 ])
318 module Machine_Arm(){
319 ysz = cutout_l_end_y_total;
320 // assume the round end is arc of a circle
323 translate([0,0,-30]) linear_extrude(height=60) {
324 translate(tile01_tr + [0, (-cutout_tile01_y + cutout_tile11_y)/2]) {
326 translate([-100, -ysz/2])
338 function Rectangle_corners(c0, sz) =
339 // returns the corners of a rectangle from c0 to c0+sz
340 // if sz is positive, the corners are anticlockwise starting with c0
343 c0 + [ sz[0], sz[1] ],
346 function Rectangle_corners2posts(c) =
352 module Rectangle_TileBase(c) { TileBase(c[0], c[2]); }
354 function Posts_interpolate_one(c0,c1) = [c0, (c0+c1)/2, c1];
357 m4_dnl c is from Rectangle_corners and
358 m4_dnl ix is a corner number
359 m4_dnl expands to two comma-separated corners:
360 m4_dnl that denoted by ix, and the next one anticlockwise
361 m4_define(`R_EDGE',`$1[$2],$1[(($2)+1)%4]')
363 module Tile02(){ ////toplevel
366 c = Rectangle_corners(c0, sz);
367 posts = Rectangle_corners2posts(c);
371 Rectangle_TileBase(c);
373 RoundEdge(R_EDGE(c,0));
374 RoundEdge(R_EDGE(c,3));
375 InterlockEdge(R_EDGE(c,2), 0);
377 InterlockEdge(R_EDGE(c,1), 1);
383 module Tile12(){ ////toplevel
386 c = Rectangle_corners(c0, sz);
387 posts = Rectangle_corners2posts(c);
391 Rectangle_TileBase(c);
393 RoundEdge(R_EDGE(c,2));
394 RoundEdge(R_EDGE(c,3));
396 InterlockEdge(R_EDGE(c,0), 1);
397 InterlockEdge(R_EDGE(c,1), 1);
403 module Tile11(){ ////toplevel
406 c = Rectangle_corners(c0, sz);
407 cnr_posts = Rectangle_corners2posts(c);
409 Posts_interpolate_one(cnr_posts[0],
410 cnr_posts[1] - [cutout_tile11_x, 0]),
411 [ cnr_posts[1] + [0, cutout_tile11_y],
417 Rectangle_TileBase(c);
419 RoundEdge(R_EDGE(c,2));
420 InterlockEdge(R_EDGE(c,3));
423 InterlockEdge(R_EDGE(c,0), 1);
427 module Demo(){ ////toplevel
428 translate(demo_slop*[-2,1]) color("blue") Tile12();
429 translate(demo_slop*[-2,0]) color("red") Tile02();
430 translate(demo_slop*[-2,1]) color("orange") Tile11();