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;
45 cutout_tile01_y = 170 - 147 + cutout_l_end_y_front_slop;
46 cutout_tile11_x = cutout_l_end_x + cutout_l_end_curve;
47 cutout_tile11_y = cutout_l_end_y_total - cutout_tile01_y;
53 ply_edge_hole_dist = ply_edge_min + ply_hole_dia/2;
55 echo(str("HOLES IN PLY ctr dist from PLY edge = ", ply_edge_hole_dist));
57 hole_slop = (ply_hole_dia - post_dia)/2;
58 tile_hard_edge_hole_dist = ply_edge_hole_dist + hole_slop;
60 echo(str("HOLES IN PLY ctr dist from TILE HARD edge = ",
61 tile_hard_edge_hole_dist));
63 echo(str("HOLES IN PLY ctr dist from TILE ROUND edge = ",
64 tile_hard_edge_hole_dist + round_edge_rad));
66 thehd = [ tile_hard_edge_hole_dist, tile_hard_edge_hole_dist ];
68 thehd_tl = [ -thehd_tr[0], thehd_tr[1] ];
72 interlock_rad = interlock_dia/2;
73 interlock_negative_rad = interlock_rad + 0.125;
75 interlock_sq_adj = 0.2; // arbitrary
80 cylinder(r= post_dia/2, h= tile_th + ply_th - post_shorter);
81 translate([0,0, tile_th]) {
82 cylinder(r= screw_big_dia/2, h= screw_big_len);
83 cylinder(r= screw_dia/2, h= ply_th, $fn=20);
87 tsz = tile_hard_edge_hole_dist - test_edge + 1;
88 translate([0,0, tile_th/2]) {
89 cube([post_dia, tsz*2, tile_th], center=true);
90 cube([tsz*2, post_dia, tile_th], center=true);
98 translate(concat(p, [0]))
103 module TileBase(botleft, topright){
104 size = topright - botleft;
105 botleft_post = botleft + thehd_tr;
106 topright_post = topright + thehd_bl;
109 translate(concat(botleft, [0]))
110 cube(concat(size, [tile_th]));
112 translate( concat(botleft_post, [ -tile_th ])
113 + 0.5 * [ post_dia, post_dia, 0 ] )
114 Commitid_BestCount_M( topright_post-botleft_post
115 + [-post_dia,-post_dia]
119 translate( concat(botleft + [thehd[0], 0], [0]) )
120 Commitid_BestCount([ size[0] - thehd[0]*2, thehd[1] ]);
123 translate(concat(botleft + [test_edge,test_edge], [test_tile_th]))
124 cube(concat(size - [test_edge,test_edge]*2, [tile_th]));
125 translate(concat(botleft_post, [-1]))
126 cube(concat(topright_post-botleft_post, [tile_th+2]));
130 cube(max(test_edge, tile_hard_edge_hole_dist)*2, center=true);
137 m4_dnl INREFFRAME(left_cnr, right_cnr, morevars) { body; }
138 m4_define(`INREFFRAME',`
139 length_vec = ($2) - ($1);
140 length = dist2d([0,0], length_vec);
141 length_uvec = length_vec / length;
142 ortho_uvec = [ -length_uvec[1], length_uvec[0] ];
143 m = [ [ length_uvec[0], ortho_uvec[0], 0, ($1)[0], ],
144 [ length_uvec[1], ortho_uvec[1], 0, ($1)[1], ],
151 m4_dnl INREFFRAME(left_cnr, right_cnr, morevars)
152 m4_dnl INREFFRAME_EDGE { body; }
153 m4_define(`INREFFRAME_EDGE',`
154 translate([0,0, -round_edge_rad])
157 module RoundEdge(left_cnr, right_cnr) {
158 INREFFRAME(left_cnr, right_cnr)
162 cylinder(r= round_edge_rad, h= length, $fn=50);
163 translate([-1, 0, -20])
164 cube([length+2, 20, 20]);
169 module RoundCornerCut(ci) {
170 // ci should be [this_cnr, right_cnr]
171 // where right_cnr is to the right (ie, anticlockwise)
174 offr= round_cnr_rad - round_edge_rad;
175 INREFFRAME(this_cnr, right_cnr) INREFFRAME_EDGE {
177 cube(offr*2 - 0.1, center=true);
178 translate([offr, offr, 0])
179 cylinder(center=true, h=20, r= offr);
184 module RoundCornerAdd(ci) {
187 bigr = round_cnr_rad - round_edge_rad;
188 INREFFRAME(this_cnr, right_cnr) INREFFRAME_EDGE {
190 cube(bigr*2 + 0.1, center=true);
191 translate([bigr, bigr, 0])
192 rotate_extrude(convexity=10, $fn=50)
195 circle(r= round_edge_rad, $fn=50);
203 module InterlockLobePlan(negative) {
204 r = negative ? interlock_negative_rad : interlock_rad;
205 ymir = negative ? 0 : 1;
209 translate([thehd[0], 0]){
213 translate([-dx, -0.1])
214 square([ dx*2, r/2 + 0.1 ]);
216 translate([ xi*dx, r ])
224 module InterlockEdgePlan(negative, nlobes, length, dosquare=true) {
225 for (lobei = [ 0 : nlobes-1 ]) {
226 lobex = (length - thehd[0]*2) * (lobei ? lobei / (nlobes-1) : 0);
227 translate([lobex, 0, 0]) {
228 InterlockLobePlan(negative);
234 slotshorter = negative ? -0.1 : interlock_fine_lenslop;
235 mirror([0, negative])
236 translate([slotshorter, iadj])
237 square([length - slotshorter*2, interlock_fine + iadj*2]);
241 module InterlockEdge(left_cnr, right_cnr, negative=0, nlobes=2) {
242 plusth = negative * 1.0;
243 protr = interlock_fine + interlock_sq_adj;
246 z1 = -tile_th/2 - protr / interlock_fine_slope;
247 z3 = -tile_th/2 + protr / interlock_fine_slope;
249 negsign = negative ? -1 : +1;
250 yprotr = negsign * protr;
252 INREFFRAME(left_cnr, right_cnr) {
253 for (vsect = [ // zs0 zs1 ys0, ys1
254 [ -tile_th-plusth, plusth, 0, 0],
255 [ z1, z2, 0, yprotr],
256 [ z2, z3, yprotr, 0],
266 [ 0,1, -sl, -ys0 + negsign*interlock_sq_adj ],
270 linear_extrude(height=zsd, convexity=10)
271 InterlockEdgePlan(negative, nlobes, length, !!ysd);
276 function TestPiece_holes2corners(holes) =
277 [ holes[0] + thehd_bl,
280 holes[0] + thehd_tl ];
282 module TestPiece1(){ ////toplevel
286 corners = TestPiece_holes2corners(holes);
287 rcs = [corners[0], corners[1]];
290 TileBase(corners[0], corners[2]);
292 RoundEdge(corners[0], corners[1]);
293 RoundEdge(corners[3], corners[0]);
295 InterlockEdge(corners[1], corners[2], 1, nlobes=1);
301 module TestPiece2(){ ////toplevel
305 corners = TestPiece_holes2corners(holes);
306 TileBase(corners[0], corners[2]);
308 RoundEdge(corners[0], corners[1]);
309 InterlockEdge(corners[3], corners[0], 0, nlobes=1);
312 module TestDemo(){ ////toplevel
313 translate([ -thehd[0], 0 ])
316 translate([ +thehd[0] + demo_slop, 0 ])
320 module Machine_Arm(){
321 ysz = cutout_l_end_y_total;
322 // assume the round end is arc of a circle
323 chordlen = dist2d([0,0], [ cutout_l_end_y, cutout_l_end_curve ]);
324 endrad = cutout_l_end_y / cutout_l_end_curve * chordlen;
326 translate([0,0,-30]) linear_extrude(height=60) {
327 translate(tile01_tr + [0, (-cutout_tile01_y + cutout_tile11_y)/2]) {
329 translate([-100, -ysz/2])
331 translate([ endrad - cutout_tile11_x - cutout_l_end_x_slop, 0 ])
332 circle(r=endrad, $fa=0.01,$fd=5);
342 function Rectangle_corners(c0, sz) =
343 // returns the corners of a rectangle from c0 to c0+sz
344 // if sz is positive, the corners are anticlockwise starting with c0
347 c0 + [ sz[0], sz[1] ],
350 function Rectangle_corners2posts(c) =
356 module Rectangle_TileBase(c) { TileBase(c[0], c[2]); }
358 function Posts_interpolate_one(c0,c1) = [c0, (c0+c1)/2, c1];
361 m4_dnl c is from Rectangle_corners and
362 m4_dnl ix is a corner number
363 m4_dnl expands to two comma-separated corners:
364 m4_dnl that denoted by ix, and the next one anticlockwise
365 m4_define(`R_EDGE',`$1[$2],$1[(($2)+1)%4]')
367 module Tile02(){ ////toplevel
370 c = Rectangle_corners(c0, sz);
371 posts = Rectangle_corners2posts(c);
375 Rectangle_TileBase(c);
377 RoundEdge(R_EDGE(c,0));
378 RoundEdge(R_EDGE(c,3));
379 InterlockEdge(R_EDGE(c,2), 0);
381 InterlockEdge(R_EDGE(c,1), 1);
387 module Tile12(){ ////toplevel
390 c = Rectangle_corners(c0, sz);
391 posts = Rectangle_corners2posts(c);
395 Rectangle_TileBase(c);
397 RoundEdge(R_EDGE(c,2));
398 RoundEdge(R_EDGE(c,3));
400 InterlockEdge(R_EDGE(c,0), 1);
401 InterlockEdge(R_EDGE(c,1), 1);
407 tile_01_11_cnr = [250, 0] + [-cutout_tile11_x, 0];
408 tile_11_10_cnr = [250, 0] + [0, cutout_tile11_y];
410 module Tile11(){ ////toplevel
413 c = Rectangle_corners(c0, sz);
414 cnr_posts = Rectangle_corners2posts(c);
416 Posts_interpolate_one(cnr_posts[0],
417 cnr_posts[1] - [cutout_tile11_x, 0]),
418 [ cnr_posts[1] + [0, cutout_tile11_y],
424 Rectangle_TileBase(c);
426 RoundEdge(R_EDGE(c,2));
427 InterlockEdge(R_EDGE(c,3));
429 InterlockEdge(c[0], tile_01_11_cnr, 1);
430 InterlockEdge(tile_11_10_cnr, c[2], 1);
435 tile_01_00_cnr = [250, 0] + [0, -cutout_tile01_y];
437 module Tile01(){ ////toplevel
440 c = Rectangle_corners(c0, sz);
441 cnr_posts = Rectangle_corners2posts(c);
443 Posts_interpolate_one(R_EDGE(cnr_posts,0)),
444 [ cnr_posts[2] + [0, -cutout_tile01_y] ],
445 Posts_interpolate_one(cnr_posts[2] - [cutout_tile11_x, 0],
450 Rectangle_TileBase(c);
452 RoundEdge(R_EDGE(c,0));
453 InterlockEdge(tile_01_11_cnr, c[3]);
454 InterlockEdge(R_EDGE(c,3));
456 InterlockEdge(c[1], tile_01_00_cnr, 1);
461 module Demo(){ ////toplevel
462 translate(demo_slop*[-2,1]) color("blue") Tile12();
463 translate(demo_slop*[-2,0]) color("red") Tile02();
464 translate(demo_slop*[-2,1]) color("orange") Tile11();
465 translate(demo_slop*[-2,0]) color("purple") Tile01();