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]));
133 m4_dnl INREFFRAME(left_cnr, right_cnr, morevars) { body; }
134 m4_define(`INREFFRAME',`
135 length_vec = ($2) - ($1);
136 length = dist2d([0,0], length_vec);
137 length_uvec = length_vec / length;
138 ortho_uvec = [ -length_uvec[1], length_uvec[0] ];
139 m = [ [ length_uvec[0], ortho_uvec[0], 0, ($1)[0], ],
140 [ length_uvec[1], ortho_uvec[1], 0, ($1)[1], ],
147 m4_dnl INREFFRAME(left_cnr, right_cnr, morevars)
148 m4_dnl INREFFRAME_EDGE { body; }
149 m4_define(`INREFFRAME_EDGE',`
150 translate([0,0, -round_edge_rad])
153 module RoundEdge(left_cnr, right_cnr) {
154 INREFFRAME(left_cnr, right_cnr)
158 cylinder(r= round_edge_rad, h= length, $fn=50);
159 translate([-1, 0, -20])
160 cube([length+2, 20, 20]);
165 module RoundCornerCut(ci) {
166 // ci should be [this_cnr, right_cnr]
167 // where right_cnr is to the right (ie, anticlockwise)
170 offr= round_cnr_rad - round_edge_rad;
171 INREFFRAME(this_cnr, right_cnr) INREFFRAME_EDGE {
173 cube(offr*2 - 0.1, center=true);
174 translate([offr, offr, 0])
175 cylinder(center=true, h=20, r= offr);
180 module RoundCornerAdd(ci) {
183 bigr = round_cnr_rad - round_edge_rad;
184 INREFFRAME(this_cnr, right_cnr) INREFFRAME_EDGE {
186 cube(bigr*2 + 0.1, center=true);
187 translate([bigr, bigr, 0])
188 rotate_extrude(convexity=10, $fn=50)
191 circle(r= round_edge_rad, $fn=50);
199 module InterlockLobePlan(negative) {
200 r = negative ? interlock_negative_rad : interlock_rad;
201 ymir = negative ? 0 : 1;
205 translate([thehd[0], 0]){
209 translate([-dx, -0.1])
210 square([ dx*2, r/2 + 0.1 ]);
212 translate([ xi*dx, r ])
220 module InterlockEdgePlan(negative, nlobes, length, dosquare=true) {
221 for (lobei = [ 0 : nlobes-1 ]) {
222 lobex = (length - thehd[0]*2) * (lobei ? lobei / (nlobes-1) : 0);
223 translate([lobex, 0, 0]) {
224 InterlockLobePlan(negative);
230 slotshorter = negative ? -0.1 : interlock_fine_lenslop;
231 mirror([0, negative])
232 translate([slotshorter, iadj])
233 square([length - slotshorter*2, interlock_fine + iadj*2]);
237 module InterlockEdge(left_cnr, right_cnr, negative=0, nlobes=2) {
238 plusth = negative * 1.0;
239 protr = interlock_fine + interlock_sq_adj;
242 z1 = -tile_th/2 - protr / interlock_fine_slope;
243 z3 = -tile_th/2 + protr / interlock_fine_slope;
245 negsign = negative ? -1 : +1;
246 yprotr = negsign * protr;
248 INREFFRAME(left_cnr, right_cnr) {
249 for (vsect = [ // zs0 zs1 ys0, ys1
250 [ -tile_th-plusth, plusth, 0, 0],
251 [ z1, z2, 0, yprotr],
252 [ z2, z3, yprotr, 0],
262 [ 0,1, -sl, -ys0 + negsign*interlock_sq_adj ],
266 linear_extrude(height=zsd, convexity=10)
267 InterlockEdgePlan(negative, nlobes, length, !!ysd);
272 function TestPiece_holes2corners(holes) =
273 [ holes[0] + thehd_bl,
276 holes[0] + thehd_tl ];
278 module TestPiece1(){ ////toplevel
282 corners = TestPiece_holes2corners(holes);
283 rcs = [corners[0], corners[1]];
286 TileBase(corners[0], corners[2]);
288 RoundEdge(corners[0], corners[1]);
289 RoundEdge(corners[3], corners[0]);
291 InterlockEdge(corners[1], corners[2], 1, nlobes=1);
297 module TestPiece2(){ ////toplevel
301 corners = TestPiece_holes2corners(holes);
302 TileBase(corners[0], corners[2]);
304 RoundEdge(corners[0], corners[1]);
305 InterlockEdge(corners[3], corners[0], 0, nlobes=1);
308 module TestDemo(){ ////toplevel
309 translate([ -thehd[0], 0 ])
312 translate([ +thehd[0] + demo_slop, 0 ])
316 module Machine_Arm(){
317 ysz = cutout_l_end_y_total;
318 // assume the round end is arc of a circle
321 translate([0,0,-30]) linear_extrude(height=60) {
322 translate(tile01_tr + [0, (-cutout_tile01_y + cutout_tile11_y)/2]) {
324 translate([-100, -ysz/2])
336 function Rectangle_corners(c0, sz) =
337 // returns the corners of a rectangle from c0 to c0+sz
338 // if sz is positive, the corners are anticlockwise starting with c0
341 c0 + [ sz[0], sz[1] ],
344 function Rectangle_corners2posts(c) =
350 module Rectangle_TileBase(c) { TileBase(c[0], c[2]); }
352 function Posts_interpolate_one(c0,c1) = [c0, (c0+c1)/2, c1];
355 m4_dnl c is from Rectangle_corners and
356 m4_dnl ix is a corner number
357 m4_dnl expands to two comma-separated corners:
358 m4_dnl that denoted by ix, and the next one anticlockwise
359 m4_define(`R_EDGE',`$1[$2],$1[(($2)+1)%4]')
361 module Tile02(){ ////toplevel
364 c = Rectangle_corners(c0, sz);
365 posts = Rectangle_corners2posts(c);
369 Rectangle_TileBase(c);
371 RoundEdge(R_EDGE(c,0));
372 RoundEdge(R_EDGE(c,3));
373 InterlockEdge(R_EDGE(c,2), 0);
375 InterlockEdge(R_EDGE(c,1), 1);
381 module Tile12(){ ////toplevel
384 c = Rectangle_corners(c0, sz);
385 posts = Rectangle_corners2posts(c);
389 Rectangle_TileBase(c);
391 RoundEdge(R_EDGE(c,2));
392 RoundEdge(R_EDGE(c,3));
394 InterlockEdge(R_EDGE(c,0), 1);
395 InterlockEdge(R_EDGE(c,1), 1);
401 module Tile11(){ ////toplevel
404 c = Rectangle_corners(c0, sz);
405 cnr_posts = Rectangle_corners2posts(c);
407 Posts_interpolate_one(cnr_posts[0],
408 cnr_posts[1] - [cutout_tile11_x, 0]),
409 [ cnr_posts[1] + [0, cutout_tile11_y],
415 Rectangle_TileBase(c);
417 RoundEdge(R_EDGE(c,2));
418 InterlockEdge(R_EDGE(c,3));
421 InterlockEdge(R_EDGE(c,0), 1);
425 module Demo(){ ////toplevel
426 translate(demo_slop*[-2,1]) color("blue") Tile12();
427 translate(demo_slop*[-2,0]) color("red") Tile02();
428 translate(demo_slop*[-2,1]) color("orange") Tile11();