// -*- C -*- include ply_th = 18; ply_hole_dia = 15; ply_edge_min = 10; tile_th = 3; post_dia = 8; post_shorter = 1; screw_dia = 2.2; screw_big_dia = 3.6; screw_big_len = 4.0; round_edge_rad = 2.0; // calculated ply_edge_hole_dist = ply_edge_min + ply_hole_dia/2; echo(str("HOLES IN PLY ctr dist from edge = ", ply_edge_hole_dist)); hole_slop = (ply_hole_dia - post_dia)/2; tile_hard_edge_hole_dist = ply_edge_hole_dist + hole_slop; thehd = [ tile_hard_edge_hole_dist, tile_hard_edge_hole_dist ]; module Post(){ mirror([0,0,1]) { difference(){ cylinder(r= post_dia/2, h= tile_th + ply_th - post_shorter); translate([0,0, tile_th]) { cylinder(r= screw_big_dia/2, h= screw_big_len); cylinder(r= screw_dia/2, h= ply_th, $fn=20); } } } } module Posts(posts) { for (p= posts) { translate([p[0], p[1], 0]) Post(); } } module TileBase(botleft_post, topright_post){ botleft = botleft_post - thehd; size = topright_post - botleft_post + thehd * 2; mirror([0,0,1]) translate([botleft[0], botleft[1], 0]) cube([size[0], size[1], tile_th]); } module RoundEdge(left_post, right_post) { length_vec = right_post - left_post; length = dist2d([0,0], length_vec); length_uvec = length_vec / length; ortho_uvec = [ -length_uvec[1], length_uvec[0] ]; m = [ [ length_uvec[0], ortho_uvec[0], 0, left_post[0], ], [ length_uvec[1], ortho_uvec[1], 0, left_post[1], ], [ 0, 0, 1, 0, ], [ 0, 0, 0, 1, ] ]; tlength = length + thehd[1] * 2; multmatrix(m) { translate([-thehd[1], -thehd[0], -round_edge_rad]){ difference(){ rotate([0,90,0]) cylinder(r= round_edge_rad, h= tlength, $fn=50); translate([-1, 0, -20]) cube([tlength+2, 20, 20]); } } } } module RoundLeftCorner(this_post, right_post) { length_vec = right_post - this_post; length_uvec = length_vec - dist2d([0,0], length_vec); ortho_uvec = [ -length_uvec[1], length_uvec[0] ]; m = [ [ length_uvec[0], ortho_uvec[0], 0, this_post[0], ], [ length_uvec[1], ortho_uvec[1], 0, this_post[1], ], [ 0, 0, 1, 0, ], [ 0, 0, 0, 1, ] ]; multmatrix(m) { translate([-thehd[1], -thehd[0], -round_edge_rad]){ difference(){ sphere(r= round_edge_rad, $fn=60); translate([0,0, -20]) cube([20,20,20]); } } } } module TestPiece1(){ holes = [ [-100, 0], [ 0, 0] ]; TileBase(holes[0], holes[1]); Posts(holes); RoundEdge(holes[0], holes[1]); RoundEdge(holes[0] + [ 0, 0.1 ], holes[0]); RoundLeftCorner(holes[0], holes[1]); } TestPiece1();