From 2099242b4fbb5ef5837f27c8df080c78936174d6 Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Thu, 1 Oct 2020 11:54:14 +0800 Subject: [PATCH] add drilled_cube --- examples/drilled_cube.scad | 53 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 examples/drilled_cube.scad diff --git a/examples/drilled_cube.scad b/examples/drilled_cube.scad new file mode 100644 index 00000000..e2a2dc18 --- /dev/null +++ b/examples/drilled_cube.scad @@ -0,0 +1,53 @@ +width = 70; +joint_h = 2; +level = 4; +reducing_scale = 0.575; // [0:0.707107] +$fn = 8; + +echo(atan2(1, sqrt(2))); + +module drilled_cube(width, reducing_scale, joint_h, level) { + module drills(width, reducing_scale, joint_h, level) { + w = width * reducing_scale; + r = 1.41421 * w / 2; + if(level > 0) { + z_offset = w / 2 + joint_h; + for(i = [0:3]) { + rotate([i * 90, 0, 0]) + translate([0, 0, z_offset]) + linear_extrude(width) + circle(r); + } + + for(ay = [90, -90]) { + rotate([0, ay, 0]) + translate([0, 0, z_offset]) + linear_extrude(width) + circle(r); + } + + drills(z_offset * 2, reducing_scale, joint_h, level - 1); + } + else { + for(i = [0:3]) { + rotate([i * 90, 0, 0]) + linear_extrude(width) + circle(r); + } + + for(ay = [90, -90]) { + rotate([0, ay, 0]) + linear_extrude(width) + circle(r); + } + } + } + + difference() { + cube(width, center = true); + drills(width, reducing_scale, joint_h, level - 1); + } +} + + +drilled_cube(width, reducing_scale, joint_h, level); \ No newline at end of file