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;
35 cutout_l_end_x_slop = 0.25;
39 cutout_l_end_curve = 1;
40 cutout_l_end_y_total = cutout_l_end_y
41 + cutout_l_end_y_front_slop + cutout_l_end_y_rear_slop;
46 cutout_tile01_y = 170 - 147 + cutout_l_end_y_front_slop;
47 cutout_tile11_x = cutout_l_end_x + cutout_l_end_curve;
48 cutout_tile11_y = cutout_l_end_y_total - cutout_tile01_y;
55 rearcurve_strt_len = 65;
56 rearcurve_total_len = 84;
58 rearcurve_rad_slop = 0.75;
60 rearcurve_avoid_y = rearcurve_rad + 10;
70 ply_edge_hole_dist = ply_edge_min + ply_hole_dia/2;
72 echo(str("HOLES IN PLY ctr dist from PLY edge = ", ply_edge_hole_dist));
74 hole_slop = (ply_hole_dia - post_dia)/2;
75 tile_hard_edge_hole_dist = ply_edge_hole_dist + hole_slop;
77 echo(str("HOLES IN PLY ctr dist from TILE HARD edge = ",
78 tile_hard_edge_hole_dist));
80 echo(str("HOLES IN PLY ctr dist from TILE ROUND edge = ",
81 tile_hard_edge_hole_dist + round_edge_rad));
83 thehd = [ tile_hard_edge_hole_dist, tile_hard_edge_hole_dist ];
85 thehd_tl = [ -thehd_tr[0], thehd_tr[1] ];
89 interlock_rad = interlock_dia/2;
90 interlock_negative_rad = interlock_rad + 0.125;
92 interlock_sq_adj = 0.2; // arbitrary
97 cylinder(r= post_dia/2, h= tile_th + ply_th - post_shorter);
98 translate([0,0, tile_th]) {
99 cylinder(r= screw_big_dia/2, h= screw_big_len);
100 cylinder(r= screw_dia/2, h= ply_th, $fn=20);
104 tsz = tile_hard_edge_hole_dist - test_edge + 1;
105 translate([0,0, tile_th/2]) {
106 cube([post_dia, tsz*2, tile_th], center=true);
107 cube([tsz*2, post_dia, tile_th], center=true);
113 module Posts(posts) {
115 translate(concat(p, [0]))
120 module TileBase(botleft, topright){
121 size = topright - botleft;
122 botleft_post = botleft + thehd_tr;
123 topright_post = topright + thehd_bl;
126 translate(concat(botleft, [0]))
127 cube(concat(size, [tile_th]));
129 translate( concat(botleft_post, [ -tile_th ])
130 + 0.5 * [ post_dia, post_dia, 0 ] )
131 Commitid_BestCount_M( topright_post-botleft_post
132 + [-post_dia,-post_dia]
136 translate( concat(botleft + [thehd[0], 0], [0]) )
137 Commitid_BestCount([ size[0] - thehd[0]*2, thehd[1] ]);
140 translate(concat(botleft + [test_edge,test_edge], [test_tile_th]))
141 cube(concat(size - [test_edge,test_edge]*2, [tile_th]));
142 translate(concat(botleft_post, [-1]))
143 cube(concat(topright_post-botleft_post, [tile_th+2]));
147 cube(max(test_edge, tile_hard_edge_hole_dist)*2, center=true);
154 m4_dnl INREFFRAME(left_cnr, right_cnr, morevars) { body; }
155 m4_define(`INREFFRAME',`
156 length_vec = ($2) - ($1);
157 length = dist2d([0,0], length_vec);
158 length_uvec = length_vec / length;
159 ortho_uvec = [ -length_uvec[1], length_uvec[0] ];
160 m = [ [ length_uvec[0], ortho_uvec[0], 0, ($1)[0], ],
161 [ length_uvec[1], ortho_uvec[1], 0, ($1)[1], ],
168 m4_dnl INREFFRAME(left_cnr, right_cnr, morevars)
169 m4_dnl INREFFRAME_EDGE { body; }
170 m4_define(`INREFFRAME_EDGE',`
171 translate([0,0, -round_edge_rad])
174 module RoundEdge(left_cnr, right_cnr) {
175 INREFFRAME(left_cnr, right_cnr)
179 cylinder(r= round_edge_rad, h= length, $fn=50);
180 translate([-1, 0, -20])
181 cube([length+2, 20, 20]);
186 module RoundCornerCut(ci) {
187 // ci should be [this_cnr, right_cnr]
188 // where right_cnr is to the right (ie, anticlockwise)
191 offr= round_cnr_rad - round_edge_rad;
192 INREFFRAME(this_cnr, right_cnr) INREFFRAME_EDGE {
194 cube(offr*2 - 0.1, center=true);
195 translate([offr, offr, 0])
196 cylinder(center=true, h=20, r= offr);
201 module RoundCornerAdd(ci) {
204 bigr = round_cnr_rad - round_edge_rad;
205 INREFFRAME(this_cnr, right_cnr) INREFFRAME_EDGE {
207 cube(bigr*2 + 0.1, center=true);
208 translate([bigr, bigr, 0])
209 rotate_extrude(convexity=10, $fn=50)
212 circle(r= round_edge_rad, $fn=50);
220 module InterlockLobePlan(negative) {
221 r = negative ? interlock_negative_rad : interlock_rad;
222 ymir = negative ? 0 : 1;
226 translate([thehd[0], 0]){
230 translate([-dx, -0.1])
231 square([ dx*2, r/2 + 0.1 ]);
233 translate([ xi*dx, r ])
241 module InterlockEdgePlan(negative, nlobes, length, dosquare=true) {
242 for (lobei = [ 0 : nlobes-1 ]) {
243 lobex = (length - thehd[0]*2) * (lobei ? lobei / (nlobes-1) : 0);
244 translate([lobex, 0, 0]) {
245 InterlockLobePlan(negative);
251 slotshorter = negative ? -0.1 : interlock_fine_lenslop;
252 mirror([0, negative])
253 translate([slotshorter, iadj])
254 square([length - slotshorter*2, interlock_fine + iadj*2]);
258 module InterlockEdge(left_cnr, right_cnr, negative=0, nlobes=2) {
259 plusth = negative * 1.0;
260 protr = interlock_fine + interlock_sq_adj;
263 z1 = -tile_th/2 - protr / interlock_fine_slope;
264 z3 = -tile_th/2 + protr / interlock_fine_slope;
266 negsign = negative ? -1 : +1;
267 yprotr = negsign * protr;
269 INREFFRAME(left_cnr, right_cnr) {
270 for (vsect = [ // zs0 zs1 ys0, ys1
271 [ -tile_th-plusth, plusth, 0, 0],
272 [ z1, z2, 0, yprotr],
273 [ z2, z3, yprotr, 0],
283 [ 0,1, -sl, -ys0 + negsign*interlock_sq_adj ],
287 linear_extrude(height=zsd, convexity=10)
288 InterlockEdgePlan(negative, nlobes, length, !!ysd);
293 function TestPiece_holes2corners(holes) =
294 [ holes[0] + thehd_bl,
297 holes[0] + thehd_tl ];
299 module TestPiece1(){ ////toplevel
303 corners = TestPiece_holes2corners(holes);
304 rcs = [corners[0], corners[1]];
307 TileBase(corners[0], corners[2]);
309 RoundEdge(corners[0], corners[1]);
310 RoundEdge(corners[3], corners[0]);
312 InterlockEdge(corners[1], corners[2], 1, nlobes=1);
318 module TestPiece2(){ ////toplevel
322 corners = TestPiece_holes2corners(holes);
323 TileBase(corners[0], corners[2]);
325 RoundEdge(corners[0], corners[1]);
326 InterlockEdge(corners[3], corners[0], 0, nlobes=1);
329 module TestDemo(){ ////toplevel
330 translate([ -thehd[0], 0 ])
333 translate([ +thehd[0] + demo_slop, 0 ])
337 module Machine_Arm(){
338 ysz = cutout_l_end_y_total;
339 // assume the round end is arc of a circle
340 chordlen = dist2d([0,0], [ cutout_l_end_y, cutout_l_end_curve ]);
341 endrad = cutout_l_end_y / cutout_l_end_curve * chordlen;
343 translate([0,0,-30]) linear_extrude(height=60) {
344 translate(tile01_tr + [0, (-cutout_tile01_y + cutout_tile11_y)/2]) {
346 translate([-100, -ysz/2])
348 translate([ endrad - cutout_tile11_x - cutout_l_end_x_slop, 0 ])
349 circle(r=endrad, $fa=0.01,$fd=5);
355 module Machine_Rear(){ ////toplevel
356 big_rad = rearcurve_total_len - rearcurve_strt_len + rearcurve_rad;
357 small_rad = rearcurve_rad + rearcurve_rad_slop;
358 translate([ tile01_tr[0] - cutout_l_end_x + rearedge_len,
362 translate([ -reartablet_x,
366 cube([ reartablet_x+1,
369 translate([ rearcurve_strt_len,
377 rotate([0,0, 360/8/2])
378 cylinder(r = small_rad, h= rearcurve_strt_len);
383 big_rad - rearcurve_rad ]) {
386 rotate_extrude(convexity=10) {
390 circle(r= small_rad);
392 circle(r= small_rad);
405 module Machine(){ ////toplevel
410 function Rectangle_corners(c0, sz) =
411 // returns the corners of a rectangle from c0 to c0+sz
412 // if sz is positive, the corners are anticlockwise starting with c0
415 c0 + [ sz[0], sz[1] ],
418 function Rectangle_corners2posts(c) =
424 module Rectangle_TileBase(c) { TileBase(c[0], c[2]); }
426 function Posts_interpolate_one(c0,c1) = [c0, (c0+c1)/2, c1];
429 m4_dnl c is from Rectangle_corners and
430 m4_dnl ix is a corner number
431 m4_dnl expands to two comma-separated corners:
432 m4_dnl that denoted by ix, and the next one anticlockwise
433 m4_define(`R_EDGE',`$1[$2],$1[(($2)+1)%4]')
435 module Tile02(){ ////toplevel
437 c0 = tile02_tr + -sz;
438 c = Rectangle_corners(c0, sz);
439 posts = Rectangle_corners2posts(c);
443 Rectangle_TileBase(c);
445 RoundEdge(R_EDGE(c,0));
446 RoundEdge(R_EDGE(c,3));
447 InterlockEdge(R_EDGE(c,2), 0);
449 InterlockEdge(R_EDGE(c,1), 1);
455 module Tile12(){ ////toplevel
457 c0 = tile02_tr + [-sz[0], 0];
458 c = Rectangle_corners(c0, sz);
459 posts = Rectangle_corners2posts(c);
463 Rectangle_TileBase(c);
465 RoundEdge(R_EDGE(c,2));
466 RoundEdge(R_EDGE(c,3));
468 InterlockEdge(R_EDGE(c,0), 1);
469 InterlockEdge(R_EDGE(c,1), 1);
475 tile_01_11_cnr = tile01_tr + [-cutout_tile11_x, 0];
476 tile_11_10_cnr = tile01_tr + [0, cutout_tile11_y];
478 module Tile11(){ ////toplevel
480 c0 = tile02_tr + [0,0];
481 c = Rectangle_corners(c0, sz);
482 cnr_posts = Rectangle_corners2posts(c);
484 Posts_interpolate_one(cnr_posts[0],
485 cnr_posts[1] - [cutout_tile11_x, 0]),
486 [ cnr_posts[1] + [0, cutout_tile11_y],
492 Rectangle_TileBase(c);
494 RoundEdge(R_EDGE(c,2));
495 InterlockEdge(R_EDGE(c,3));
497 InterlockEdge(c[0], tile_01_11_cnr, 1);
498 InterlockEdge(tile_11_10_cnr, c[2], 1);
503 tile_01_00_cnr = tile01_tr + [0, -cutout_tile01_y];
505 module Tile01(){ ////toplevel
507 c0 = tile02_tr + [0,-sz[1]];
508 c = Rectangle_corners(c0, sz);
509 cnr_posts = Rectangle_corners2posts(c);
511 Posts_interpolate_one(R_EDGE(cnr_posts,0)),
512 [ cnr_posts[2] + [0, -cutout_tile01_y] ],
513 Posts_interpolate_one(cnr_posts[2] - [cutout_tile11_x, 0],
518 Rectangle_TileBase(c);
520 RoundEdge(R_EDGE(c,0));
521 InterlockEdge(tile_01_11_cnr, c[3]);
522 InterlockEdge(R_EDGE(c,3));
524 InterlockEdge(c[1], tile_01_00_cnr, 1);
529 module Tile10(){ ////toplevel
531 c0 = tile02_tr + [sz[0],0];
532 c = Rectangle_corners(c0, sz);
533 cnr_posts = Rectangle_corners2posts(c);
534 cty = cutout_tile11_y;
535 rcy = cty + rearcurve_avoid_y;
536 posts = [ cnr_posts[0] + [ 0, cty ],
537 cnr_posts[1] + [ -sz[1] + rearedge_len - cutout_l_end_x, cty ],
538 cnr_posts[1] + [ 0, rcy ],
544 Rectangle_TileBase(c);
546 RoundEdge(R_EDGE(c,1));
547 RoundEdge(R_EDGE(c,2));
548 InterlockEdge(c[3], tile_11_10_cnr);
556 module Demo(){ ////toplevel
557 translate(demo_slop*[-2,1]) color("blue") Tile12();
558 translate(demo_slop*[-2,0]) color("red") Tile02();
559 translate(demo_slop*[-2,1]) color("orange") Tile11();
560 translate(demo_slop*[-2,0]) color("purple") Tile01();
561 translate(demo_slop*[-3,1]) color("blue") Tile10();