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;
38 cutout_l_end_curve = 1;
39 cutout_l_end_y_total = cutout_l_end_y
40 + cutout_l_end_y_front_slop + cutout_l_end_y_rear_slop;
44 cutout_tile01_y = 170 - 147 + cutout_l_end_y_front_slop;
45 cutout_tile11_x = 22 + cutout_l_end_curve;
46 cutout_tile11_y = cutout_l_end_y_total - cutout_tile01_y;
52 ply_edge_hole_dist = ply_edge_min + ply_hole_dia/2;
54 echo(str("HOLES IN PLY ctr dist from PLY edge = ", ply_edge_hole_dist));
56 hole_slop = (ply_hole_dia - post_dia)/2;
57 tile_hard_edge_hole_dist = ply_edge_hole_dist + hole_slop;
59 echo(str("HOLES IN PLY ctr dist from TILE HARD edge = ",
60 tile_hard_edge_hole_dist));
62 echo(str("HOLES IN PLY ctr dist from TILE ROUND edge = ",
63 tile_hard_edge_hole_dist + round_edge_rad));
65 thehd = [ tile_hard_edge_hole_dist, tile_hard_edge_hole_dist ];
67 thehd_tl = [ -thehd_tr[0], thehd_tr[1] ];
71 interlock_rad = interlock_dia/2;
72 interlock_negative_rad = interlock_rad + 0.125;
74 interlock_sq_adj = 0.2; // arbitrary
79 cylinder(r= post_dia/2, h= tile_th + ply_th - post_shorter);
80 translate([0,0, tile_th]) {
81 cylinder(r= screw_big_dia/2, h= screw_big_len);
82 cylinder(r= screw_dia/2, h= ply_th, $fn=20);
86 tsz = tile_hard_edge_hole_dist - test_edge + 1;
87 translate([0,0, tile_th/2]) {
88 cube([post_dia, tsz*2, tile_th], center=true);
89 cube([tsz*2, post_dia, tile_th], center=true);
97 translate(concat(p, [0]))
102 module TileBase(botleft, topright){
103 size = topright - botleft;
104 botleft_post = botleft + thehd_tr;
105 topright_post = topright + thehd_bl;
108 translate(concat(botleft, [0]))
109 cube(concat(size, [tile_th]));
111 translate( concat(botleft_post, [ -tile_th ])
112 + 0.5 * [ post_dia, post_dia, 0 ] )
113 Commitid_BestCount_M( topright_post-botleft_post
114 + [-post_dia,-post_dia]
118 translate( concat(botleft + [thehd[0], 0], [0]) )
119 Commitid_BestCount([ size[0] - thehd[0]*2, thehd[1] ]);
122 translate(concat(botleft + [test_edge,test_edge], [test_tile_th]))
123 cube(concat(size - [test_edge,test_edge]*2, [tile_th]));
124 translate(concat(botleft_post, [-1]))
125 cube(concat(topright_post-botleft_post, [tile_th+2]));
129 cube(max(test_edge, tile_hard_edge_hole_dist)*2, center=true);
136 m4_dnl INREFFRAME(left_cnr, right_cnr, morevars) { body; }
137 m4_define(`INREFFRAME',`
138 length_vec = ($2) - ($1);
139 length = dist2d([0,0], length_vec);
140 length_uvec = length_vec / length;
141 ortho_uvec = [ -length_uvec[1], length_uvec[0] ];
142 m = [ [ length_uvec[0], ortho_uvec[0], 0, ($1)[0], ],
143 [ length_uvec[1], ortho_uvec[1], 0, ($1)[1], ],
150 m4_dnl INREFFRAME(left_cnr, right_cnr, morevars)
151 m4_dnl INREFFRAME_EDGE { body; }
152 m4_define(`INREFFRAME_EDGE',`
153 translate([0,0, -round_edge_rad])
156 module RoundEdge(left_cnr, right_cnr) {
157 INREFFRAME(left_cnr, right_cnr)
161 cylinder(r= round_edge_rad, h= length, $fn=50);
162 translate([-1, 0, -20])
163 cube([length+2, 20, 20]);
168 module RoundCornerCut(ci) {
169 // ci should be [this_cnr, right_cnr]
170 // where right_cnr is to the right (ie, anticlockwise)
173 offr= round_cnr_rad - round_edge_rad;
174 INREFFRAME(this_cnr, right_cnr) INREFFRAME_EDGE {
176 cube(offr*2 - 0.1, center=true);
177 translate([offr, offr, 0])
178 cylinder(center=true, h=20, r= offr);
183 module RoundCornerAdd(ci) {
186 bigr = round_cnr_rad - round_edge_rad;
187 INREFFRAME(this_cnr, right_cnr) INREFFRAME_EDGE {
189 cube(bigr*2 + 0.1, center=true);
190 translate([bigr, bigr, 0])
191 rotate_extrude(convexity=10, $fn=50)
194 circle(r= round_edge_rad, $fn=50);
202 module InterlockLobePlan(negative) {
203 r = negative ? interlock_negative_rad : interlock_rad;
204 ymir = negative ? 0 : 1;
208 translate([thehd[0], 0]){
212 translate([-dx, -0.1])
213 square([ dx*2, r/2 + 0.1 ]);
215 translate([ xi*dx, r ])
223 module InterlockEdgePlan(negative, nlobes, length, dosquare=true) {
224 for (lobei = [ 0 : nlobes-1 ]) {
225 lobex = (length - thehd[0]*2) * (lobei ? lobei / (nlobes-1) : 0);
226 translate([lobex, 0, 0]) {
227 InterlockLobePlan(negative);
233 slotshorter = negative ? -0.1 : interlock_fine_lenslop;
234 mirror([0, negative])
235 translate([slotshorter, iadj])
236 square([length - slotshorter*2, interlock_fine + iadj*2]);
240 module InterlockEdge(left_cnr, right_cnr, negative=0, nlobes=2) {
241 plusth = negative * 1.0;
242 protr = interlock_fine + interlock_sq_adj;
245 z1 = -tile_th/2 - protr / interlock_fine_slope;
246 z3 = -tile_th/2 + protr / interlock_fine_slope;
248 negsign = negative ? -1 : +1;
249 yprotr = negsign * protr;
251 INREFFRAME(left_cnr, right_cnr) {
252 for (vsect = [ // zs0 zs1 ys0, ys1
253 [ -tile_th-plusth, plusth, 0, 0],
254 [ z1, z2, 0, yprotr],
255 [ z2, z3, yprotr, 0],
265 [ 0,1, -sl, -ys0 + negsign*interlock_sq_adj ],
269 linear_extrude(height=zsd, convexity=10)
270 InterlockEdgePlan(negative, nlobes, length, !!ysd);
275 function TestPiece_holes2corners(holes) =
276 [ holes[0] + thehd_bl,
279 holes[0] + thehd_tl ];
281 module TestPiece1(){ ////toplevel
285 corners = TestPiece_holes2corners(holes);
286 rcs = [corners[0], corners[1]];
289 TileBase(corners[0], corners[2]);
291 RoundEdge(corners[0], corners[1]);
292 RoundEdge(corners[3], corners[0]);
294 InterlockEdge(corners[1], corners[2], 1, nlobes=1);
300 module TestPiece2(){ ////toplevel
304 corners = TestPiece_holes2corners(holes);
305 TileBase(corners[0], corners[2]);
307 RoundEdge(corners[0], corners[1]);
308 InterlockEdge(corners[3], corners[0], 0, nlobes=1);
311 module TestDemo(){ ////toplevel
312 translate([ -thehd[0], 0 ])
315 translate([ +thehd[0] + demo_slop, 0 ])
319 module Machine_Arm(){
320 ysz = cutout_l_end_y_total;
321 // assume the round end is arc of a circle
322 chordlen = dist2d([0,0], [ cutout_l_end_y, cutout_l_end_curve ]);
323 endrad = cutout_l_end_y / cutout_l_end_curve * chordlen;
325 translate([0,0,-30]) linear_extrude(height=60) {
326 translate(tile01_tr + [0, (-cutout_tile01_y + cutout_tile11_y)/2]) {
328 translate([-100, -ysz/2])
330 translate([ endrad - cutout_l_end_y - cutout_l_end_x_slop, 0 ])
331 circle(r=endrad, $fa=0.01,$fd=5);
341 function Rectangle_corners(c0, sz) =
342 // returns the corners of a rectangle from c0 to c0+sz
343 // if sz is positive, the corners are anticlockwise starting with c0
346 c0 + [ sz[0], sz[1] ],
349 function Rectangle_corners2posts(c) =
355 module Rectangle_TileBase(c) { TileBase(c[0], c[2]); }
357 function Posts_interpolate_one(c0,c1) = [c0, (c0+c1)/2, c1];
360 m4_dnl c is from Rectangle_corners and
361 m4_dnl ix is a corner number
362 m4_dnl expands to two comma-separated corners:
363 m4_dnl that denoted by ix, and the next one anticlockwise
364 m4_define(`R_EDGE',`$1[$2],$1[(($2)+1)%4]')
366 module Tile02(){ ////toplevel
369 c = Rectangle_corners(c0, sz);
370 posts = Rectangle_corners2posts(c);
374 Rectangle_TileBase(c);
376 RoundEdge(R_EDGE(c,0));
377 RoundEdge(R_EDGE(c,3));
378 InterlockEdge(R_EDGE(c,2), 0);
380 InterlockEdge(R_EDGE(c,1), 1);
386 module Tile12(){ ////toplevel
389 c = Rectangle_corners(c0, sz);
390 posts = Rectangle_corners2posts(c);
394 Rectangle_TileBase(c);
396 RoundEdge(R_EDGE(c,2));
397 RoundEdge(R_EDGE(c,3));
399 InterlockEdge(R_EDGE(c,0), 1);
400 InterlockEdge(R_EDGE(c,1), 1);
406 module Tile11(){ ////toplevel
409 c = Rectangle_corners(c0, sz);
410 cnr_posts = Rectangle_corners2posts(c);
412 Posts_interpolate_one(cnr_posts[0],
413 cnr_posts[1] - [cutout_tile11_x, 0]),
414 [ cnr_posts[1] + [0, cutout_tile11_y],
420 Rectangle_TileBase(c);
422 RoundEdge(R_EDGE(c,2));
423 InterlockEdge(R_EDGE(c,3));
426 InterlockEdge(R_EDGE(c,0), 1);
430 module Demo(){ ////toplevel
431 translate(demo_slop*[-2,1]) color("blue") Tile12();
432 translate(demo_slop*[-2,0]) color("red") Tile02();
433 translate(demo_slop*[-2,1]) color("orange") Tile11();