2020-02-16 16:47:11 +08:00
|
|
|
use <polyline2d.scad>;
|
2020-01-28 10:08:01 +08:00
|
|
|
use <stereographic_extrude.scad>;
|
2020-10-01 11:59:03 +08:00
|
|
|
use <maze/mz_blocks.scad>;
|
2020-10-03 21:17:23 +08:00
|
|
|
use <maze/mz_hex_walls.scad>;
|
2019-09-01 11:58:44 +08:00
|
|
|
|
2020-10-03 21:17:23 +08:00
|
|
|
columns = 10;
|
2019-09-01 11:58:44 +08:00
|
|
|
cell_radius = 20;
|
|
|
|
wall_thickness = 12;
|
|
|
|
fn = 24;
|
|
|
|
shadow = "YES"; // [YES, NO]
|
|
|
|
wall_height = 1;
|
|
|
|
|
2020-10-03 21:17:23 +08:00
|
|
|
module hex_maze_stereographic_projection(columns, cell_radius, wall_thickness, fn, wall_height, shadow) {
|
|
|
|
rows = round(0.866 * columns - 0.211);
|
2019-09-01 11:58:44 +08:00
|
|
|
|
|
|
|
grid_h = 2 * cell_radius * sin(60);
|
|
|
|
grid_w = cell_radius + cell_radius * cos(60);
|
|
|
|
|
2020-10-03 21:17:23 +08:00
|
|
|
square_w = grid_w * (columns - 1) + cell_radius * 2 + wall_thickness * 2;
|
|
|
|
square_h = grid_h * rows + grid_h / 2 + wall_thickness * 2;
|
2019-09-01 11:58:44 +08:00
|
|
|
square_offset_x = square_w / 2 -cell_radius - wall_thickness;
|
|
|
|
square_offset_y = square_h / 2 -grid_h / 2 - wall_thickness;
|
|
|
|
|
|
|
|
pyramid_height = square_w / sqrt(2);
|
|
|
|
|
|
|
|
// create a maze
|
2020-10-03 21:17:23 +08:00
|
|
|
blocks = mz_blocks(
|
2020-02-16 16:47:11 +08:00
|
|
|
[1, 1],
|
2020-10-03 21:17:23 +08:00
|
|
|
rows, columns
|
2020-02-16 16:47:11 +08:00
|
|
|
);
|
2019-09-01 11:58:44 +08:00
|
|
|
|
2020-10-03 21:17:23 +08:00
|
|
|
walls = mz_hex_walls(blocks, rows, columns, cell_radius, wall_thickness);
|
|
|
|
|
2019-09-01 11:58:44 +08:00
|
|
|
stereographic_extrude(square_w, $fn = fn)
|
2019-09-26 08:53:47 +08:00
|
|
|
translate([grid_w - square_w / 2, grid_h - square_w / 2, 0])
|
2020-10-03 21:17:23 +08:00
|
|
|
for(wall = walls) {
|
|
|
|
polyline2d(
|
|
|
|
wall,
|
|
|
|
wall_thickness,
|
|
|
|
startingStyle = "CAP_ROUND", endingStyle = "CAP_ROUND"
|
|
|
|
);
|
|
|
|
}
|
2019-09-01 11:58:44 +08:00
|
|
|
|
|
|
|
if(shadow == "YES") {
|
2019-09-03 21:00:50 +08:00
|
|
|
color("black")
|
|
|
|
linear_extrude(wall_height)
|
2019-09-26 08:53:47 +08:00
|
|
|
translate([grid_w - square_w / 2, grid_h - square_w / 2, 0])
|
2020-10-03 21:17:23 +08:00
|
|
|
for(wall = walls) {
|
|
|
|
polyline2d(
|
|
|
|
wall,
|
|
|
|
wall_thickness,
|
|
|
|
startingStyle = "CAP_ROUND", endingStyle = "CAP_ROUND"
|
|
|
|
);
|
|
|
|
}
|
2019-09-01 11:58:44 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-03 21:17:23 +08:00
|
|
|
hex_maze_stereographic_projection(columns, cell_radius, wall_thickness, fn, wall_height, shadow);
|