4 include <commitid.scad>
24 interlock_fine = 0.66;
26 interlock_fine_slope = 1.0;
27 interlock_fine_lenslop = 1.0;
34 cutout_l_end_curve = 1;
36 cutout_tile01_y = 170 - 147;
37 cutout_tile11_x = 22 + cutout_l_end_curve;
38 cutout_tile11_y = cutout_l_end_y - cutout_tile01_y;
44 ply_edge_hole_dist = ply_edge_min + ply_hole_dia/2;
46 echo(str("HOLES IN PLY ctr dist from PLY edge = ", ply_edge_hole_dist));
48 hole_slop = (ply_hole_dia - post_dia)/2;
49 tile_hard_edge_hole_dist = ply_edge_hole_dist + hole_slop;
51 echo(str("HOLES IN PLY ctr dist from TILE HARD edge = ",
52 tile_hard_edge_hole_dist));
54 echo(str("HOLES IN PLY ctr dist from TILE ROUND edge = ",
55 tile_hard_edge_hole_dist + round_edge_rad));
57 thehd = [ tile_hard_edge_hole_dist, tile_hard_edge_hole_dist ];
59 thehd_tl = [ -thehd_tr[0], thehd_tr[1] ];
63 interlock_rad = interlock_dia/2;
64 interlock_negative_rad = interlock_rad + 0.125;
66 interlock_sq_adj = 0.2; // arbitrary
71 cylinder(r= post_dia/2, h= tile_th + ply_th - post_shorter);
72 translate([0,0, tile_th]) {
73 cylinder(r= screw_big_dia/2, h= screw_big_len);
74 cylinder(r= screw_dia/2, h= ply_th, $fn=20);
78 tsz = tile_hard_edge_hole_dist - test_edge + 1;
79 translate([0,0, tile_th/2]) {
80 cube([post_dia, tsz*2, tile_th], center=true);
81 cube([tsz*2, post_dia, tile_th], center=true);
89 translate(concat(p, [0]))
94 module TileBase(botleft, topright){
95 size = topright - botleft;
96 botleft_post = botleft + thehd_tr;
97 topright_post = topright + thehd_bl;
100 translate(concat(botleft, [0]))
101 cube(concat(size, [tile_th]));
103 translate( concat(botleft_post, [ -tile_th ])
104 + 0.5 * [ post_dia, post_dia, 0 ] )
105 Commitid_BestCount_M( topright_post-botleft_post
106 + [-post_dia,-post_dia]
110 translate( concat(botleft + [thehd[0], 0], [0]) )
111 Commitid_BestCount([ size[0] - thehd[0]*2, thehd[1] ]);
113 translate(concat(botleft + [test_edge,test_edge], [test_tile_th]))
114 cube(concat(size - [test_edge,test_edge]*2, [tile_th]));
115 translate(concat(botleft_post, [-1]))
116 cube(concat(topright_post-botleft_post, [tile_th+2]));
122 m4_dnl INREFFRAME(left_cnr, right_cnr, morevars) { body; }
123 m4_define(`INREFFRAME',`
124 length_vec = ($2) - ($1);
125 length = dist2d([0,0], length_vec);
126 length_uvec = length_vec / length;
127 ortho_uvec = [ -length_uvec[1], length_uvec[0] ];
128 m = [ [ length_uvec[0], ortho_uvec[0], 0, ($1)[0], ],
129 [ length_uvec[1], ortho_uvec[1], 0, ($1)[1], ],
136 m4_dnl INREFFRAME(left_cnr, right_cnr, morevars)
137 m4_dnl INREFFRAME_EDGE { body; }
138 m4_define(`INREFFRAME_EDGE',`
139 translate([0,0, -round_edge_rad])
142 module RoundEdge(left_cnr, right_cnr) {
143 INREFFRAME(left_cnr, right_cnr)
147 cylinder(r= round_edge_rad, h= length, $fn=50);
148 translate([-1, 0, -20])
149 cube([length+2, 20, 20]);
154 module RoundCornerCut(ci) {
155 // ci should be [this_cnr, right_cnr]
156 // where right_cnr is to the right (ie, anticlockwise)
159 offr= round_cnr_rad - round_edge_rad;
160 INREFFRAME(this_cnr, right_cnr) INREFFRAME_EDGE {
162 cube(offr*2 - 0.1, center=true);
163 translate([offr, offr, 0])
164 cylinder(center=true, h=20, r= offr);
169 module RoundCornerAdd(ci) {
172 bigr = round_cnr_rad - round_edge_rad;
173 INREFFRAME(this_cnr, right_cnr) INREFFRAME_EDGE {
175 cube(bigr*2 + 0.1, center=true);
176 translate([bigr, bigr, 0])
177 rotate_extrude(convexity=10, $fn=50)
180 circle(r= round_edge_rad, $fn=50);
188 module InterlockLobePlan(negative) {
189 r = negative ? interlock_negative_rad : interlock_rad;
190 ymir = negative ? 0 : 1;
194 translate([thehd[0], 0]){
198 translate([-dx, -0.1])
199 square([ dx*2, r/2 + 0.1 ]);
201 translate([ xi*dx, r ])
209 module InterlockEdgePlan(negative, nlobes, length, dosquare=true) {
210 for (lobei = [ 0 : nlobes-1 ]) {
211 lobex = (length - thehd[0]*2) * (lobei ? lobei / (nlobes-1) : 0);
212 translate([lobex, 0, 0]) {
213 InterlockLobePlan(negative);
219 slotshorter = negative ? -0.1 : interlock_fine_lenslop;
220 mirror([0, negative])
221 translate([slotshorter, iadj])
222 square([length - slotshorter*2, interlock_fine + iadj*2]);
226 module InterlockEdge(left_cnr, right_cnr, negative=0, nlobes=2) {
227 plusth = negative * 1.0;
228 protr = interlock_fine + interlock_sq_adj;
231 z1 = -tile_th/2 - protr / interlock_fine_slope;
232 z3 = -tile_th/2 + protr / interlock_fine_slope;
234 negsign = negative ? -1 : +1;
235 yprotr = negsign * protr;
237 INREFFRAME(left_cnr, right_cnr) {
238 for (vsect = [ // zs0 zs1 ys0, ys1
239 [ -tile_th-plusth, plusth, 0, 0],
240 [ z1, z2, 0, yprotr],
241 [ z2, z3, yprotr, 0],
251 [ 0,1, -sl, -ys0 + negsign*interlock_sq_adj ],
255 linear_extrude(height=zsd, convexity=10)
256 InterlockEdgePlan(negative, nlobes, length, !!ysd);
261 function TestPiece_holes2corners(holes) =
262 [ holes[0] + thehd_bl,
265 holes[0] + thehd_tl ];
267 module TestPiece1(){ ////toplevel
271 corners = TestPiece_holes2corners(holes);
272 rcs = [corners[0], corners[1]];
275 TileBase(corners[0], corners[2]);
277 RoundEdge(corners[0], corners[1]);
278 RoundEdge(corners[3], corners[0]);
280 InterlockEdge(corners[1], corners[2], 1, nlobes=1);
286 module TestPiece2(){ ////toplevel
290 corners = TestPiece_holes2corners(holes);
291 TileBase(corners[0], corners[2]);
293 RoundEdge(corners[0], corners[1]);
294 InterlockEdge(corners[3], corners[0], 0, nlobes=1);
297 module TestDemo(){ ////toplevel
298 translate([ -thehd[0], 0 ])
301 translate([ +thehd[0] + demo_slop, 0 ])
308 function Rectangle_corners(c0, sz) =
309 // returns the corners of a rectangle from c0 to c0+sz
310 // if sz is positive, the corners are anticlockwise starting with c0
313 c0 + [ sz[0], sz[1] ],
316 function Rectangle_corners2posts(c) =
322 module Rectangle_TileBase(c) { TileBase(c[0], c[2]); }
324 function Posts_interpolate_one(c0,c1) = [c0, (c0+c1)/2, c1];
327 m4_dnl c is from Rectangle_corners and
328 m4_dnl ix is a corner number
329 m4_dnl expands to two comma-separated corners:
330 m4_dnl that denoted by ix, and the next one anticlockwise
331 m4_define(`R_EDGE',`$1[$2],$1[(($2)+1)%4]')
333 module Tile02(){ ////toplevel
336 c = Rectangle_corners(c0, sz);
337 posts = Rectangle_corners2posts(c);
341 Rectangle_TileBase(c);
343 RoundEdge(R_EDGE(c,0));
344 RoundEdge(R_EDGE(c,3));
345 InterlockEdge(R_EDGE(c,2), 0);
347 InterlockEdge(R_EDGE(c,1), 1);
353 module Tile12(){ ////toplevel
356 c = Rectangle_corners(c0, sz);
357 posts = Rectangle_corners2posts(c);
361 Rectangle_TileBase(c);
363 RoundEdge(R_EDGE(c,2));
364 RoundEdge(R_EDGE(c,3));
366 InterlockEdge(R_EDGE(c,0), 1);
367 InterlockEdge(R_EDGE(c,1), 1);
373 module Tile11(){ ////toplevel
376 c = Rectangle_corners(c0, sz);
377 cnr_posts = Rectangle_corners2posts(c);
379 Posts_interpolate_one(cnr_posts[0],
380 cnr_posts[1] - [cutout_tile11_x, 0]),
381 [ cnr_posts[1] + [0, cutout_tile11_y],
387 Rectangle_TileBase(c);
389 RoundEdge(R_EDGE(c,2));
390 InterlockEdge(R_EDGE(c,3));
393 InterlockEdge(R_EDGE(c,0), 1);
397 module Demo(){ ////toplevel
398 translate(demo_slop*[-2,1]) color("blue") Tile12();
399 translate(demo_slop*[-2,0]) color("red") Tile02();
400 translate(demo_slop*[-2,1]) color("orange") Tile11();