diff --git a/examples/maze/senbon_torii.scad b/examples/maze/senbon_torii.scad index b2264277..149c35fe 100644 --- a/examples/maze/senbon_torii.scad +++ b/examples/maze/senbon_torii.scad @@ -7,17 +7,13 @@ module senbon_torii(rows, columns, start, width, height) { // first torii fst = line[0]; snd = line[1]; - fa = atan2(snd[0] - fst[0], snd[1] - fst[1]); - color("LightSalmon") - translate(line[0]) - rotate([90, 0, fa]) - linear_extrude(.1, center = true) + translate(fst) + rotate([90, 0, atan2(snd[0] - fst[0], snd[1] - fst[1])]) translate([0, .175]) - children(0); + children(0); - // middle torris - for(i = [0:leng - 2]) { + module middle_torii(i) { p1 = line[i]; p2 = line[i + 1]; md = (p1 + p2) / 2; @@ -25,25 +21,12 @@ module senbon_torii(rows, columns, start, width, height) { a1 = atan2(p2[0] - p1[0], p2[1] - p1[1]); - color("LightSalmon") translate([md[0], md[1], h]) rotate([90, 0, a1]) - linear_extrude(.1, center = true) - translate([0, .1]) + translate([0, .1]) children(0); - - color("LightSalmon") - if(i > 0) { - p0 = line[i - 1]; - a2 = atan2(p1[0] - p0[0], p1[1] - p0[1]); - translate([p1[0], p1[1], h - width * 0.233333]) - rotate([90, 0, a1 + (a1 - a2) / 2]) - linear_extrude(.1, center = true) - translate([0, .2]) - children(0); - } - - color("OliveDrab") + + // road hull() { translate(p1) linear_extrude(h) @@ -52,7 +35,29 @@ module senbon_torii(rows, columns, start, width, height) { translate(p2) linear_extrude((i + 1) * height + 0.1) square(width, center = true); - } + } + } + + // second torii + middle_torii(0) + children(0); + + // middle torris + for(i = [1:leng - 2]) { + middle_torii(i) + children(0); + + p0 = line[i - 1]; + p1 = line[i]; + p2 = line[i + 1]; + h = i * height + 0.1; + + a1 = atan2(p2[0] - p1[0], p2[1] - p1[1]); + a2 = atan2(p1[0] - p0[0], p1[1] - p0[1]); + translate([p1[0], p1[1], h - width * 0.233333]) + rotate([90, 0, a1 + (a1 - a2) / 2]) + translate([0, .2]) + children(0); } // top @@ -60,26 +65,21 @@ module senbon_torii(rows, columns, start, width, height) { pre_lst = line[leng - 2]; la = atan2(lst[0] - pre_lst[0], lst[1] - pre_lst[1]); - color("Gold") translate([lst[0], lst[1], (leng - 1) * height]) rotate([90, 0, la]) - linear_extrude(.3, center = true) translate([0, .175]) children(1); } module torii_symbol() { - difference() { - translate([-0.025, 0.025]) - text("⛩", font = "Segoe UI Emoji", size = 0.5 * 0.7, halign = "center"); - - *translate([0, .285]) - square([.275, .1], center = true); - } + linear_extrude(.1, center = true) + translate([-0.025, 0.025]) + text("⛩", font = "Segoe UI Emoji", size = 0.5 * 0.7, halign = "center"); } module top_symbol() { translate([-0.005, .05]) + linear_extrude(.3, center = true) scale([0.9, 1.5]) text("🏔", font = "Segoe UI Emoji", size = 0.45 * 0.7, halign = "center"); }