mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-10 16:54:23 +02:00
rename block to cell
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
use <square_maze.scad>;
|
||||
|
||||
maze_rows = 8;
|
||||
block_width = 2;
|
||||
cell_width = 2;
|
||||
wall_thickness = 1;
|
||||
inner_cube = true;
|
||||
travel_all = true;
|
||||
|
||||
module cube_maze(maze_rows, block_width, wall_thickness, inner_cube, travel_all) {
|
||||
blocks_size = block_width * maze_rows;
|
||||
cube_size = blocks_size - wall_thickness;
|
||||
maze_size = blocks_size + wall_thickness;
|
||||
module cube_maze(maze_rows, cell_width, wall_thickness, inner_cube, travel_all) {
|
||||
cells_size = cell_width * maze_rows;
|
||||
cube_size = cells_size - wall_thickness;
|
||||
maze_size = cells_size + wall_thickness;
|
||||
|
||||
half_wall_thickness = wall_thickness / 2;
|
||||
half_cube_size = cube_size / 2;
|
||||
@@ -21,7 +21,7 @@ module cube_maze(maze_rows, block_width, wall_thickness, inner_cube, travel_all)
|
||||
module one_maze() {
|
||||
translate([origin, origin, half_cube_size])
|
||||
linear_extrude(wall_thickness)
|
||||
square_maze(maze_rows, block_width, wall_thickness);
|
||||
square_maze(maze_rows, cell_width, wall_thickness);
|
||||
}
|
||||
|
||||
one_maze();
|
||||
@@ -64,4 +64,4 @@ module cube_maze(maze_rows, block_width, wall_thickness, inner_cube, travel_all)
|
||||
}
|
||||
}
|
||||
|
||||
cube_maze(maze_rows, block_width, wall_thickness, inner_cube, travel_all);
|
||||
cube_maze(maze_rows, cell_width, wall_thickness, inner_cube, travel_all);
|
||||
|
@@ -1,10 +1,10 @@
|
||||
use <bend.scad>;
|
||||
use <maze/mz_square_blocks.scad>;
|
||||
use <maze/mz_square_cells.scad>;
|
||||
use <maze/mz_square_walls.scad>;
|
||||
|
||||
radius = 30;
|
||||
height = 60;
|
||||
block_width = 8;
|
||||
cell_width = 8;
|
||||
|
||||
wall_thickness = 5;
|
||||
wall_height = 5;
|
||||
@@ -32,19 +32,19 @@ module cylinder_maze() {
|
||||
}
|
||||
}
|
||||
|
||||
maze_rows = round(height / block_width);
|
||||
maze_columns = round(2 * 3.14159 * radius / block_width);
|
||||
maze_rows = round(height / cell_width);
|
||||
maze_columns = round(2 * 3.14159 * radius / cell_width);
|
||||
|
||||
maze_blocks = mz_square_blocks(
|
||||
maze_cells = mz_square_cells(
|
||||
maze_rows, maze_columns,
|
||||
x_wrapping = true
|
||||
);
|
||||
|
||||
walls = mz_square_walls(maze_blocks, maze_rows, maze_columns, block_width, left_border = false);
|
||||
walls = mz_square_walls(maze_cells, maze_rows, maze_columns, cell_width, left_border = false);
|
||||
|
||||
leng_circumference = block_width * maze_columns + wall_thickness;
|
||||
leng_circumference = cell_width * maze_columns + wall_thickness;
|
||||
|
||||
bend(size = [leng_circumference, block_width * maze_rows + wall_thickness, wall_height], angle = 360 + 360 * wall_thickness / leng_circumference, frags = fn)
|
||||
bend(size = [leng_circumference, cell_width * maze_rows + wall_thickness, wall_height], angle = 360 + 360 * wall_thickness / leng_circumference, frags = fn)
|
||||
translate([0, wall_thickness / 2])
|
||||
for(wall = walls) {
|
||||
for(i = [0:len(wall) - 2]) {
|
||||
|
@@ -1,14 +1,14 @@
|
||||
use <regular_polygon_maze.scad>;
|
||||
use <hollow_out.scad>;
|
||||
|
||||
cblocks = 8;
|
||||
ccells = 8;
|
||||
wall_thickness = 1.5;
|
||||
spacing = 0.6;
|
||||
$fn = 48;
|
||||
|
||||
gyro_maze(cblocks, wall_thickness, spacing);
|
||||
gyro_maze(ccells, wall_thickness, spacing);
|
||||
|
||||
module gyro_maze(cblocks, wall_thickness, spacing) {
|
||||
module gyro_maze(ccells, wall_thickness, spacing) {
|
||||
// Don't change these variables. They require more math.
|
||||
radius = 15;
|
||||
wall_height = 1;
|
||||
@@ -20,7 +20,7 @@ module gyro_maze(cblocks, wall_thickness, spacing) {
|
||||
linear_extrude(wall_height)
|
||||
scale(1.029) {
|
||||
difference() {
|
||||
regular_polygon_maze(radius - wall_thickness, cblocks, levels - 1, wall_thickness, $fn);
|
||||
regular_polygon_maze(radius - wall_thickness, ccells, levels - 1, wall_thickness, $fn);
|
||||
circle(radius / 3.5);
|
||||
}
|
||||
circle(radius / 3.5 - wall_thickness / 1.45);
|
||||
|
@@ -1,6 +1,6 @@
|
||||
use <arc.scad>;
|
||||
use <heart_maze.scad>;
|
||||
use <maze/mz_square_blocks.scad>;
|
||||
use <maze/mz_square_cells.scad>;
|
||||
|
||||
names = ["Justin", "Monica"];
|
||||
font_name = "Arial Black";
|
||||
@@ -9,7 +9,7 @@ font_size = 8;
|
||||
radius_of_heart = 15;
|
||||
tip_r_of_heart = 5;
|
||||
wall_thickness = 2.5;
|
||||
cblocks = 6;
|
||||
ccells = 6;
|
||||
levels = 3;
|
||||
spacing = 0.4;
|
||||
|
||||
@@ -30,14 +30,14 @@ module heart_base(name, font_name, font_size, radius, ring_thickness, tip_r_of_h
|
||||
arc(radius = radius / 3, angle = [25, 155], width = ring_thickness);
|
||||
}
|
||||
|
||||
module heart2heart_maze(names, font_name, font_size, radius_of_heart, tip_r_of_heart, wall_thickness, cblocks, levels, spacing) {
|
||||
maze = mz_square_blocks(
|
||||
cblocks, levels, y_wrapping = true
|
||||
module heart2heart_maze(names, font_name, font_size, radius_of_heart, tip_r_of_heart, wall_thickness, ccells, levels, spacing) {
|
||||
maze = mz_square_cells(
|
||||
ccells, levels, y_wrapping = true
|
||||
);
|
||||
|
||||
translate([0, 0, wall_thickness])
|
||||
linear_extrude(wall_thickness)
|
||||
heart_maze(maze, radius_of_heart, cblocks, levels, wall_thickness);
|
||||
heart_maze(maze, radius_of_heart, ccells, levels, wall_thickness);
|
||||
heart_base(names[0], font_name, font_size, radius_of_heart + wall_thickness / 2, wall_thickness, tip_r_of_heart);
|
||||
|
||||
translate([radius_of_heart * 4, 0, 0]) {
|
||||
@@ -50,9 +50,9 @@ module heart2heart_maze(names, font_name, font_size, radius_of_heart, tip_r_of_h
|
||||
heart(radius_of_heart, tip_r_of_heart);
|
||||
linear_extrude(wall_thickness * 2)
|
||||
offset(delta = spacing)
|
||||
heart_maze(maze, radius_of_heart, cblocks, levels, wall_thickness);
|
||||
heart_maze(maze, radius_of_heart, ccells, levels, wall_thickness);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
heart2heart_maze(names, font_name, font_size, radius_of_heart, tip_r_of_heart, wall_thickness, cblocks, levels, spacing);
|
||||
heart2heart_maze(names, font_name, font_size, radius_of_heart, tip_r_of_heart, wall_thickness, ccells, levels, spacing);
|
@@ -2,14 +2,14 @@ use <line2d.scad>;
|
||||
use <hollow_out.scad>;
|
||||
use <ellipse_extrude.scad>;
|
||||
use <arc.scad>;
|
||||
use <maze/mz_square_blocks.scad>;
|
||||
use <maze/mz_square_cells.scad>;
|
||||
use <maze/mz_square_get.scad>;
|
||||
|
||||
radius_of_heart = 12;
|
||||
height_of_heart = 25;
|
||||
tip_r_of_heart = 5;
|
||||
wall_thickness = 2;
|
||||
cblocks = 6;
|
||||
ccells = 6;
|
||||
levels = 3;
|
||||
|
||||
$fn = 36;
|
||||
@@ -58,17 +58,17 @@ module heart_to_heart_wall(radius, length, angle, thickness) {
|
||||
}
|
||||
}
|
||||
|
||||
module heart_maze(maze, radius, cblocks, levels, thickness = 1) {
|
||||
function no_wall(block) = get_wall_type(block) == "NO_WALL";
|
||||
function top_wall(block) = get_wall_type(block) == "TOP_WALL";
|
||||
function right_wall(block) = get_wall_type(block) == "RIGHT_WALL";
|
||||
function top_right_wall(block) = get_wall_type(block) == "TOP_RIGHT_WALL";
|
||||
module heart_maze(maze, radius, ccells, levels, thickness = 1) {
|
||||
function no_wall(cell) = get_wall_type(cell) == "NO_WALL";
|
||||
function top_wall(cell) = get_wall_type(cell) == "TOP_WALL";
|
||||
function right_wall(cell) = get_wall_type(cell) == "RIGHT_WALL";
|
||||
function top_right_wall(cell) = get_wall_type(cell) == "TOP_RIGHT_WALL";
|
||||
|
||||
function get_x(block) = mz_square_get(block, "x");
|
||||
function get_y(block) = mz_square_get(block, "y");
|
||||
function get_wall_type(block) = mz_square_get(block, "w");
|
||||
function get_x(cell) = mz_square_get(cell, "x");
|
||||
function get_y(cell) = mz_square_get(cell, "y");
|
||||
function get_wall_type(cell) = mz_square_get(cell, "w");
|
||||
|
||||
arc_angle = 360 / cblocks;
|
||||
arc_angle = 360 / ccells;
|
||||
r = radius / (levels + 1);
|
||||
|
||||
difference() {
|
||||
@@ -79,13 +79,13 @@ module heart_maze(maze, radius, cblocks, levels, thickness = 1) {
|
||||
|
||||
|
||||
for(i = [0:len(maze) - 1]) {
|
||||
block = maze[i];
|
||||
cr = get_x(block) + 1;
|
||||
cc = get_y(block);
|
||||
cell = maze[i];
|
||||
cr = get_x(cell) + 1;
|
||||
cc = get_y(cell);
|
||||
|
||||
angle = cc * arc_angle;
|
||||
|
||||
if(top_wall(block) || top_right_wall(block)) {
|
||||
if(top_wall(cell) || top_right_wall(cell)) {
|
||||
heart_to_heart_wall(r * cr, r, cc * arc_angle , thickness);
|
||||
}
|
||||
}
|
||||
@@ -94,11 +94,11 @@ module heart_maze(maze, radius, cblocks, levels, thickness = 1) {
|
||||
render() union() {
|
||||
// road to the next level
|
||||
for(i = [0:len(maze) - 1]) {
|
||||
block = maze[i];
|
||||
cr = get_x(block) + 1;
|
||||
cc = get_y(block);
|
||||
cell = maze[i];
|
||||
cr = get_x(cell) + 1;
|
||||
cc = get_y(cell);
|
||||
|
||||
if(no_wall(block) || top_wall(block)) {
|
||||
if(no_wall(cell) || top_wall(cell)) {
|
||||
ring_heart_sector(r * (cr + 1), (cc + 0.5) * arc_angle , thickness, thickness * 0.75);
|
||||
}
|
||||
}
|
||||
@@ -106,8 +106,8 @@ module heart_maze(maze, radius, cblocks, levels, thickness = 1) {
|
||||
}
|
||||
}
|
||||
|
||||
maze = mz_square_blocks(
|
||||
cblocks, levels, y_wrapping = true
|
||||
maze = mz_square_cells(
|
||||
ccells, levels, y_wrapping = true
|
||||
);
|
||||
|
||||
intersection() {
|
||||
@@ -121,7 +121,7 @@ intersection() {
|
||||
}
|
||||
|
||||
linear_extrude(height_of_heart, center = true)
|
||||
heart_maze(maze, radius_of_heart, cblocks, levels, wall_thickness);
|
||||
heart_maze(maze, radius_of_heart, ccells, levels, wall_thickness);
|
||||
}
|
||||
|
||||
linear_extrude(wall_thickness * 2, center = true)
|
||||
|
@@ -1,4 +1,4 @@
|
||||
use <maze/mz_square_blocks.scad>;
|
||||
use <maze/mz_square_cells.scad>;
|
||||
use <maze/mz_square_walls.scad>;
|
||||
use <maze/mz_square_initialize.scad>;
|
||||
use <voxel/vx_contour.scad>;
|
||||
@@ -18,18 +18,18 @@ mask = [
|
||||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
||||
];
|
||||
|
||||
block_width = 3;
|
||||
cell_width = 3;
|
||||
wall_thickness = 1;
|
||||
wall_height = 2;
|
||||
base_height = 1;
|
||||
contour = true;
|
||||
base = true;
|
||||
|
||||
module maze_masking(start, mask, block_width, wall_thickness, wall_height, base_height, contour, base) {
|
||||
module maze_masking(start, mask, cell_width, wall_thickness, wall_height, base_height, contour, base) {
|
||||
rows = len(mask);
|
||||
columns = len(mask[0]);
|
||||
|
||||
blocks = mz_square_blocks(
|
||||
cells = mz_square_cells(
|
||||
rows, columns, start,
|
||||
mz_square_initialize(mask = mask)
|
||||
);
|
||||
@@ -41,7 +41,7 @@ module maze_masking(start, mask, block_width, wall_thickness, wall_height, base_
|
||||
[x, y]
|
||||
], sorted = true) : [];
|
||||
|
||||
walls = mz_square_walls(blocks, rows, columns, block_width);
|
||||
walls = mz_square_walls(cells, rows, columns, cell_width);
|
||||
|
||||
color("gray")
|
||||
linear_extrude(wall_height)
|
||||
@@ -62,8 +62,8 @@ module maze_masking(start, mask, block_width, wall_thickness, wall_height, base_
|
||||
for(y = [0:rows - 1]) {
|
||||
for(x = [0:columns - 1]) {
|
||||
if(mask[rows - y - 1][x] == 0) {
|
||||
translate([x * block_width + wall_thickness, y * block_width + wall_thickness])
|
||||
square(block_width);
|
||||
translate([x * cell_width + wall_thickness, y * cell_width + wall_thickness])
|
||||
square(cell_width);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -71,7 +71,7 @@ module maze_masking(start, mask, block_width, wall_thickness, wall_height, base_
|
||||
|
||||
if(contour) {
|
||||
translate([wall_thickness * 2, wall_thickness * 2])
|
||||
polygon(pts * block_width);
|
||||
polygon(pts * cell_width);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,15 +80,15 @@ module maze_masking(start, mask, block_width, wall_thickness, wall_height, base_
|
||||
translate([0, 0, -base_height])
|
||||
linear_extrude(base_height)
|
||||
translate([wall_thickness * 2, wall_thickness * 2])
|
||||
polygon(pts * block_width);
|
||||
polygon(pts * cell_width);
|
||||
}
|
||||
else {
|
||||
translate([0, 0, -base_height])
|
||||
linear_extrude(base_height)
|
||||
translate([wall_thickness, wall_thickness])
|
||||
square([columns, rows] * block_width);
|
||||
square([columns, rows] * cell_width);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
maze_masking(start, mask, block_width, wall_thickness, wall_height, base_height, contour, base);
|
||||
maze_masking(start, mask, cell_width, wall_thickness, wall_height, base_height, contour, base);
|
@@ -1,27 +1,27 @@
|
||||
use <hull_polyline3d.scad>;
|
||||
use <maze/mz_square_blocks.scad>;
|
||||
use <maze/mz_square_cells.scad>;
|
||||
use <maze/mz_square_walls.scad>;
|
||||
use <ptf/ptf_ring.scad>;
|
||||
|
||||
rows = 48;
|
||||
columns = 8;
|
||||
block_width = 2;
|
||||
cell_width = 2;
|
||||
wall_thickness = 1;
|
||||
angle = 180;
|
||||
// $fn = 24;
|
||||
|
||||
leng = rows * block_width;
|
||||
leng = rows * cell_width;
|
||||
radius = 0.5 * leng / PI;
|
||||
a_step = 360 / leng;
|
||||
|
||||
blocks = mz_square_blocks(
|
||||
cells = mz_square_cells(
|
||||
rows, columns,
|
||||
y_wrapping = true
|
||||
);
|
||||
|
||||
walls = mz_square_walls(blocks, rows, columns, block_width, bottom_border = false);
|
||||
walls = mz_square_walls(cells, rows, columns, cell_width, bottom_border = false);
|
||||
|
||||
size = [columns * block_width, rows * block_width];
|
||||
size = [columns * cell_width, rows * cell_width];
|
||||
for(wall_pts = walls) {
|
||||
transformed = [for(pt = wall_pts) ptf_ring(size, pt, radius, 360, angle)];
|
||||
hull_polyline3d(transformed, wall_thickness);
|
||||
|
@@ -1,18 +1,18 @@
|
||||
use <hull_polyline2d.scad>;
|
||||
use <util/rand.scad>;
|
||||
use <maze/mz_square_blocks.scad>;
|
||||
use <maze/mz_square_cells.scad>;
|
||||
use <maze/mz_square_walls.scad>;
|
||||
use <ptf/ptf_circle.scad>;
|
||||
use <noise/nz_perlin2.scad>;
|
||||
|
||||
module noisy_circle_maze(r_blocks, block_width, wall_thickness, origin_offset, noisy_factor) {
|
||||
double_r_blocks = r_blocks * 2;
|
||||
blocks = mz_square_blocks(
|
||||
double_r_blocks, double_r_blocks
|
||||
module noisy_circle_maze(r_cells, cell_width, wall_thickness, origin_offset, noisy_factor) {
|
||||
double_r_cells = r_cells * 2;
|
||||
cells = mz_square_cells(
|
||||
double_r_cells, double_r_cells
|
||||
);
|
||||
|
||||
width = double_r_blocks * block_width;
|
||||
walls = mz_square_walls(blocks, double_r_blocks, double_r_blocks, block_width);
|
||||
width = double_r_cells * cell_width;
|
||||
walls = mz_square_walls(cells, double_r_cells, double_r_cells, cell_width);
|
||||
|
||||
half_width = width / 2;
|
||||
rect_size = is_undef(origin_offset) ? [width, width] : [width, width] - origin_offset * 2;
|
||||
@@ -34,8 +34,8 @@ module noisy_circle_maze(r_blocks, block_width, wall_thickness, origin_offset, n
|
||||
}
|
||||
|
||||
noisy_circle_maze(
|
||||
r_blocks = 8,
|
||||
block_width = 5,
|
||||
r_cells = 8,
|
||||
cell_width = 5,
|
||||
wall_thickness = 2,
|
||||
noisy_factor = 2
|
||||
);
|
@@ -1,5 +1,5 @@
|
||||
use <polyline2d.scad>;
|
||||
use <maze/mz_square_blocks.scad>;
|
||||
use <maze/mz_square_cells.scad>;
|
||||
use <maze/mz_hex_walls.scad>;
|
||||
|
||||
columns = 10;
|
||||
@@ -30,11 +30,9 @@ module pyramid_hex_maze(columns, cell_radius, wall_thickness) {
|
||||
|
||||
pyramid_height = square_w / sqrt(2);
|
||||
|
||||
blocks = mz_square_blocks(
|
||||
rows, columns
|
||||
);
|
||||
cells = mz_square_cells(rows, columns);
|
||||
|
||||
walls = mz_hex_walls(blocks, rows, columns, cell_radius, wall_thickness);
|
||||
walls = mz_hex_walls(cells, rows, columns, cell_radius, wall_thickness);
|
||||
|
||||
intersection() {
|
||||
linear_extrude(pyramid_height)
|
||||
|
@@ -1,26 +1,26 @@
|
||||
use <square_maze.scad>;
|
||||
|
||||
maze_rows = 10;
|
||||
block_width = 2;
|
||||
cell_width = 2;
|
||||
wall_thickness = 1;
|
||||
|
||||
module pyramid_maze(maze_rows, block_width, wall_thickness) {
|
||||
module pyramid_maze(maze_rows, cell_width, wall_thickness) {
|
||||
module pyramid(leng) {
|
||||
height = leng / 1.4142135623730950488016887242097;
|
||||
linear_extrude(height, scale = 0)
|
||||
square(leng, center = true);
|
||||
}
|
||||
|
||||
leng = maze_rows * block_width ;
|
||||
leng = maze_rows * cell_width ;
|
||||
half_leng = leng / 2;
|
||||
|
||||
intersection() {
|
||||
linear_extrude(leng * 2)
|
||||
translate([-half_leng, -half_leng])
|
||||
square_maze(maze_rows, block_width, wall_thickness);
|
||||
square_maze(maze_rows, cell_width, wall_thickness);
|
||||
|
||||
pyramid(leng + wall_thickness);
|
||||
}
|
||||
}
|
||||
|
||||
pyramid_maze(maze_rows, block_width, wall_thickness);
|
||||
pyramid_maze(maze_rows, cell_width, wall_thickness);
|
@@ -1,6 +1,6 @@
|
||||
use <line2d.scad>;
|
||||
use <hollow_out.scad>;
|
||||
use <maze/mz_square_blocks.scad>;
|
||||
use <maze/mz_square_cells.scad>;
|
||||
use <maze/mz_square_get.scad>;
|
||||
|
||||
// only for creating a small maze
|
||||
@@ -8,7 +8,7 @@ use <maze/mz_square_get.scad>;
|
||||
radius_of_circle_wrapper = 15;
|
||||
wall_thickness = 1;
|
||||
wall_height = 1;
|
||||
cblocks = 6;
|
||||
ccells = 6;
|
||||
levels = 3;
|
||||
sides = 3;
|
||||
|
||||
@@ -36,21 +36,21 @@ module regular_polygon_to_polygon_wall(radius, length, angle, thickness, sides)
|
||||
}
|
||||
}
|
||||
|
||||
module regular_polygon_maze(radius, cblocks, levels, thickness = 1, sides) {
|
||||
function no_wall(block) = get_wall_type(block) == "NO_WALL";
|
||||
function top_wall(block) = get_wall_type(block) == "TOP_WALL";
|
||||
function right_wall(block) = get_wall_type(block) == "RIGHT_WALL";
|
||||
function top_right_wall(block) = get_wall_type(block) == "TOP_RIGHT_WALL";
|
||||
module regular_polygon_maze(radius, ccells, levels, thickness = 1, sides) {
|
||||
function no_wall(cell) = get_wall_type(cell) == "NO_WALL";
|
||||
function top_wall(cell) = get_wall_type(cell) == "TOP_WALL";
|
||||
function right_wall(cell) = get_wall_type(cell) == "RIGHT_WALL";
|
||||
function top_right_wall(cell) = get_wall_type(cell) == "TOP_RIGHT_WALL";
|
||||
|
||||
function get_x(block) = mz_square_get(block, "x");
|
||||
function get_y(block) = mz_square_get(block, "y");
|
||||
function get_wall_type(block) = mz_square_get(block, "w");
|
||||
function get_x(cell) = mz_square_get(cell, "x");
|
||||
function get_y(cell) = mz_square_get(cell, "y");
|
||||
function get_wall_type(cell) = mz_square_get(cell, "w");
|
||||
|
||||
arc_angle = 360 / cblocks;
|
||||
arc_angle = 360 / ccells;
|
||||
r = radius / (levels + 1);
|
||||
|
||||
maze = mz_square_blocks(
|
||||
cblocks, levels, y_wrapping = true
|
||||
maze = mz_square_cells(
|
||||
ccells, levels, y_wrapping = true
|
||||
);
|
||||
|
||||
difference() {
|
||||
@@ -61,13 +61,13 @@ module regular_polygon_maze(radius, cblocks, levels, thickness = 1, sides) {
|
||||
|
||||
|
||||
for(i = [0:len(maze) - 1]) {
|
||||
block = maze[i];
|
||||
cr = get_x(block) + 1;
|
||||
cc = get_y(block);
|
||||
cell = maze[i];
|
||||
cr = get_x(cell) + 1;
|
||||
cc = get_y(cell);
|
||||
|
||||
angle = cc * arc_angle;
|
||||
|
||||
if(top_wall(block) || top_right_wall(block)) {
|
||||
if(top_wall(cell) || top_right_wall(cell)) {
|
||||
regular_polygon_to_polygon_wall(r * cr, r, cc * arc_angle , thickness, sides);
|
||||
}
|
||||
}
|
||||
@@ -79,11 +79,11 @@ module regular_polygon_maze(radius, cblocks, levels, thickness = 1, sides) {
|
||||
|
||||
// road to the next level
|
||||
for(i = [0:len(maze) - 1]) {
|
||||
block = maze[i];
|
||||
cr = get_x(block) + 1;
|
||||
cc = get_y(block);
|
||||
cell = maze[i];
|
||||
cr = get_x(cell) + 1;
|
||||
cc = get_y(cell);
|
||||
|
||||
if(no_wall(block) || top_wall(block)) {
|
||||
if(no_wall(cell) || top_wall(cell)) {
|
||||
ring_regular_polygon_sector(r * (cr + 1), (cc + 0.5) * arc_angle , thickness, thickness * 0.75 , sides);
|
||||
}
|
||||
}
|
||||
@@ -92,4 +92,4 @@ module regular_polygon_maze(radius, cblocks, levels, thickness = 1, sides) {
|
||||
}
|
||||
|
||||
linear_extrude(wall_height)
|
||||
regular_polygon_maze(radius_of_circle_wrapper, cblocks, levels, wall_thickness, sides);
|
||||
regular_polygon_maze(radius_of_circle_wrapper, ccells, levels, wall_thickness, sides);
|
||||
|
@@ -1,15 +1,15 @@
|
||||
use <matrix/m_rotation.scad>;
|
||||
use <maze/mz_square_blocks.scad>;
|
||||
use <maze/mz_square_cells.scad>;
|
||||
use <maze/mz_square_walls.scad>;
|
||||
use <ptf/ptf_sphere.scad>;
|
||||
|
||||
r = 10;
|
||||
rows = 24;
|
||||
columns = 18;
|
||||
block_width = .5;
|
||||
cell_width = .5;
|
||||
wall_thickness = .5;
|
||||
wall_height = 1.5;
|
||||
pole_offset = block_width * 2.5;
|
||||
pole_offset = cell_width * 2.5;
|
||||
|
||||
module sphere_maze() {
|
||||
function _angles(p) =
|
||||
@@ -50,16 +50,16 @@ module sphere_maze() {
|
||||
}
|
||||
|
||||
|
||||
size = [rows * block_width, columns * block_width + pole_offset * 2];
|
||||
blocks = mz_square_blocks(
|
||||
size = [rows * cell_width, columns * cell_width + pole_offset * 2];
|
||||
cells = mz_square_cells(
|
||||
rows, columns,
|
||||
y_wrapping = true
|
||||
);
|
||||
|
||||
p_offset = [block_width * rows, pole_offset, 0];
|
||||
p_offset = [cell_width * rows, pole_offset, 0];
|
||||
mr = m_rotation(90);
|
||||
|
||||
walls = mz_square_walls(blocks, rows, columns, block_width, bottom_border = false);
|
||||
walls = mz_square_walls(cells, rows, columns, cell_width, bottom_border = false);
|
||||
for(wall_pts = walls) {
|
||||
rxpts = [
|
||||
for(p = wall_pts)
|
||||
|
@@ -1,12 +1,12 @@
|
||||
use <maze/mz_square_blocks.scad>;
|
||||
use <maze/mz_square_cells.scad>;
|
||||
use <maze/mz_square_walls.scad>;
|
||||
|
||||
module square_maze(rows, block_width, wall_thickness) {
|
||||
blocks = mz_square_blocks(
|
||||
module square_maze(rows, cell_width, wall_thickness) {
|
||||
cells = mz_square_cells(
|
||||
rows, rows
|
||||
);
|
||||
|
||||
walls = mz_square_walls(blocks, rows, rows, block_width);
|
||||
walls = mz_square_walls(cells, rows, rows, cell_width);
|
||||
|
||||
for(wall = walls) {
|
||||
for(i = [0:len(wall) - 2]) {
|
||||
@@ -20,6 +20,6 @@ module square_maze(rows, block_width, wall_thickness) {
|
||||
|
||||
square_maze(
|
||||
rows = 10,
|
||||
block_width = 2,
|
||||
cell_width = 2,
|
||||
wall_thickness = 1
|
||||
);
|
@@ -1,7 +1,7 @@
|
||||
use <square_maze.scad>;
|
||||
|
||||
maze_rows = 8;
|
||||
block_width = 10;
|
||||
cell_width = 10;
|
||||
stairs_width = 5;
|
||||
|
||||
module pyramid_with_stairs(base_width, stairs_width, rows) {
|
||||
@@ -29,29 +29,29 @@ module pyramid_with_stairs(base_width, stairs_width, rows) {
|
||||
}
|
||||
}
|
||||
|
||||
module step_pyramid_maze(maze_rows, block_width, stairs_width) {
|
||||
module step_pyramid_maze(maze_rows, cell_width, stairs_width) {
|
||||
intersection() {
|
||||
pyramid_with_stairs(
|
||||
maze_rows * block_width, stairs_width, maze_rows);
|
||||
maze_rows * cell_width, stairs_width, maze_rows);
|
||||
|
||||
linear_extrude(maze_rows * block_width * sqrt(2) / 2) difference() {
|
||||
linear_extrude(maze_rows * cell_width * sqrt(2) / 2) difference() {
|
||||
|
||||
square([block_width * maze_rows + stairs_width, block_width * maze_rows + stairs_width], center = true);
|
||||
square([cell_width * maze_rows + stairs_width, cell_width * maze_rows + stairs_width], center = true);
|
||||
|
||||
translate([-(maze_rows * block_width) / 2, -(maze_rows * block_width) / 2, 0])
|
||||
translate([-(maze_rows * cell_width) / 2, -(maze_rows * cell_width) / 2, 0])
|
||||
difference() {
|
||||
square_maze(maze_rows, block_width, stairs_width);
|
||||
square_maze(maze_rows, cell_width, stairs_width);
|
||||
|
||||
// entry
|
||||
translate([0, stairs_width])
|
||||
square(stairs_width, center = true);
|
||||
|
||||
// exit
|
||||
translate([maze_rows * block_width, maze_rows * block_width - stairs_width])
|
||||
translate([maze_rows * cell_width, maze_rows * cell_width - stairs_width])
|
||||
square(stairs_width, center = true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
step_pyramid_maze(maze_rows, block_width, stairs_width);
|
||||
step_pyramid_maze(maze_rows, cell_width, stairs_width);
|
@@ -1,6 +1,6 @@
|
||||
use <polyline2d.scad>;
|
||||
use <stereographic_extrude.scad>;
|
||||
use <maze/mz_square_blocks.scad>;
|
||||
use <maze/mz_square_cells.scad>;
|
||||
use <maze/mz_hex_walls.scad>;
|
||||
|
||||
columns = 10;
|
||||
@@ -24,11 +24,11 @@ module hex_maze_stereographic_projection(columns, cell_radius, wall_thickness, f
|
||||
pyramid_height = square_w / sqrt(2);
|
||||
|
||||
// create a maze
|
||||
blocks = mz_square_blocks(
|
||||
cells = mz_square_cells(
|
||||
rows, columns
|
||||
);
|
||||
|
||||
walls = mz_hex_walls(blocks, rows, columns, cell_radius, wall_thickness);
|
||||
walls = mz_hex_walls(cells, rows, columns, cell_radius, wall_thickness);
|
||||
|
||||
stereographic_extrude(square_w, $fn = fn)
|
||||
translate([grid_w - square_w / 2, grid_h - square_w / 2, 0])
|
||||
|
@@ -2,18 +2,18 @@ use <stereographic_extrude.scad>;
|
||||
use <square_maze.scad>;
|
||||
|
||||
maze_rows = 10;
|
||||
block_width = 40;
|
||||
cell_width = 40;
|
||||
wall_thickness = 20;
|
||||
fn = 24;
|
||||
shadow = "YES"; // [YES, NO]
|
||||
wall_height = 2;
|
||||
|
||||
module stereographic_projection_maze2(maze_rows, block_width, wall_thickness, fn, wall_height, shadow) {
|
||||
length = block_width * maze_rows + wall_thickness;
|
||||
module stereographic_projection_maze2(maze_rows, cell_width, wall_thickness, fn, wall_height, shadow) {
|
||||
length = cell_width * maze_rows + wall_thickness;
|
||||
|
||||
module maze() {
|
||||
translate([-block_width * maze_rows / 2, -block_width * maze_rows / 2, 0])
|
||||
square_maze(maze_rows, block_width, wall_thickness);
|
||||
translate([-cell_width * maze_rows / 2, -cell_width * maze_rows / 2, 0])
|
||||
square_maze(maze_rows, cell_width, wall_thickness);
|
||||
}
|
||||
|
||||
stereographic_extrude(shadow_side_leng = length, $fn = fn)
|
||||
@@ -26,4 +26,4 @@ module stereographic_projection_maze2(maze_rows, block_width, wall_thickness, fn
|
||||
}
|
||||
}
|
||||
|
||||
stereographic_projection_maze2(maze_rows, block_width, wall_thickness, fn, wall_height, shadow);
|
||||
stereographic_projection_maze2(maze_rows, cell_width, wall_thickness, fn, wall_height, shadow);
|
@@ -1,27 +1,27 @@
|
||||
use <hull_polyline3d.scad>;
|
||||
use <ptf/ptf_torus.scad>;
|
||||
use <maze/mz_square_blocks.scad>;
|
||||
use <maze/mz_square_cells.scad>;
|
||||
use <maze/mz_square_walls.scad>;
|
||||
|
||||
rows = 36;
|
||||
columns = 12;
|
||||
block_width = 2;
|
||||
cell_width = 2;
|
||||
wall_thickness = 1;
|
||||
angle = 180;
|
||||
twist = 360;
|
||||
|
||||
leng = rows * block_width;
|
||||
leng = rows * cell_width;
|
||||
radius = 0.5 * leng / PI;
|
||||
a_step = 360 / leng;
|
||||
|
||||
blocks = mz_square_blocks(
|
||||
cells = mz_square_cells(
|
||||
rows, columns,
|
||||
x_wrapping = true, y_wrapping = true
|
||||
);
|
||||
|
||||
walls = mz_square_walls(blocks, rows, columns, block_width, left_border = false, bottom_border = false);
|
||||
walls = mz_square_walls(cells, rows, columns, cell_width, left_border = false, bottom_border = false);
|
||||
|
||||
size = [columns * block_width, rows * block_width];
|
||||
size = [columns * cell_width, rows * cell_width];
|
||||
for(wall_pts = walls) {
|
||||
transformed = [for(pt = wall_pts) ptf_torus(size, pt, [radius, radius / 2], twist = twist)];
|
||||
hull_polyline3d(transformed, wall_thickness, $fn = 4);
|
||||
|
@@ -1,24 +1,24 @@
|
||||
use <hull_polyline3d.scad>;
|
||||
use <maze/mz_square_blocks.scad>;
|
||||
use <maze/mz_square_cells.scad>;
|
||||
use <maze/mz_square_walls.scad>;
|
||||
use <ptf/ptf_x_twist.scad>;
|
||||
use <ptf/ptf_y_twist.scad>;
|
||||
|
||||
rows = 10;
|
||||
columns = 10;
|
||||
block_width = 4;
|
||||
cell_width = 4;
|
||||
wall_thickness = 1;
|
||||
angle = 90;
|
||||
axis = "X_AXIS"; // [X_AXIS, Y_AXIS]
|
||||
// $fn = 24;
|
||||
|
||||
blocks = mz_square_blocks(
|
||||
cells = mz_square_cells(
|
||||
rows, columns
|
||||
);
|
||||
|
||||
walls = mz_square_walls(blocks, rows, columns, block_width);
|
||||
walls = mz_square_walls(cells, rows, columns, cell_width);
|
||||
|
||||
size = [columns * block_width, rows * block_width];
|
||||
size = [columns * cell_width, rows * cell_width];
|
||||
for(wall_pts = walls) {
|
||||
transformed = [for(pt = wall_pts) axis == "X_AXIS" ? ptf_x_twist(size, pt, angle) : ptf_y_twist(size, pt, angle)];
|
||||
hull_polyline3d(transformed, wall_thickness);
|
||||
|
@@ -1,26 +1,26 @@
|
||||
use <_mz_comm.scad>;
|
||||
|
||||
// find out the index of a block with the position (x, y)
|
||||
function indexOf(x, y, maze, i = 0) =
|
||||
i == len(maze) ? -1 : (
|
||||
[get_x(maze[i]), get_y(maze[i])] == [x, y] ? i :
|
||||
indexOf(x, y, maze, i + 1)
|
||||
// find out the index of a cell with the position (x, y)
|
||||
function indexOf(x, y, cells, i = 0) =
|
||||
i == len(cells) ? -1 : (
|
||||
[get_x(cells[i]), get_y(cells[i])] == [x, y] ? i :
|
||||
indexOf(x, y, cells, i + 1)
|
||||
);
|
||||
|
||||
// is (x, y) visited?
|
||||
function visited(x, y, maze) = maze[indexOf(x, y, maze)][3];
|
||||
function visited(x, y, cells) = cells[indexOf(x, y, cells)][3];
|
||||
|
||||
// is (x, y) visitable?
|
||||
function visitable(x, y, maze, rows, columns) =
|
||||
function visitable(x, y, cells, rows, columns) =
|
||||
y >= 0 && y < rows && // y bound
|
||||
x >= 0 && x < columns && // x bound
|
||||
!visited(x, y, maze); // unvisited
|
||||
!visited(x, y, cells); // unvisited
|
||||
|
||||
// setting (x, y) as being visited
|
||||
function set_visited(x, y, maze) = [
|
||||
for(b = maze)
|
||||
[x, y] == [get_x(b), get_y(b)] ?
|
||||
[x, y, get_wall_type(b), true] : b
|
||||
function set_visited(x, y, cells) = [
|
||||
for(cell = cells)
|
||||
[x, y] == [get_x(cell), get_y(cell)] ?
|
||||
[x, y, get_wall_type(cell), true] : cell
|
||||
];
|
||||
|
||||
// 0(right), 1(top), 2(left), 3(bottom)
|
||||
@@ -67,92 +67,92 @@ function next_y(y, dir, rows, wrapping) =
|
||||
wrapping ? (ny < 0 ? ny + rows : ny % rows) : ny;
|
||||
|
||||
// go right and carve the right wall
|
||||
function carve_right(x, y, maze) = [
|
||||
for(b = maze) [get_x(b), get_y(b)] == [x, y] ? (
|
||||
top_right_wall(b) ? [x, y, 1, 1] : [x, y, 0, 1]
|
||||
) : b
|
||||
function carve_right(x, y, cells) = [
|
||||
for(cell = cells) [get_x(cell), get_y(cell)] == [x, y] ? (
|
||||
top_right_wall(cell) ? [x, y, 1, 1] : [x, y, 0, 1]
|
||||
) : cell
|
||||
];
|
||||
|
||||
// go up and carve the top wall
|
||||
function carve_top(x, y, maze) = [
|
||||
for(b = maze) [get_x(b), get_y(b)] == [x, y] ? (
|
||||
top_right_wall(b) ? [x, y, 2, 1] : [x, y, 0, 1]
|
||||
) : b
|
||||
function carve_top(x, y, cells) = [
|
||||
for(cell = cells) [get_x(cell), get_y(cell)] == [x, y] ? (
|
||||
top_right_wall(cell) ? [x, y, 2, 1] : [x, y, 0, 1]
|
||||
) : cell
|
||||
];
|
||||
|
||||
// go left and carve the right wall of the left block
|
||||
function carve_left(x, y, maze, columns) =
|
||||
// go left and carve the right wall of the left cell
|
||||
function carve_left(x, y, cells, columns) =
|
||||
let(
|
||||
x_minus_one = x - 1,
|
||||
nx = x_minus_one < 0 ? x_minus_one + columns : x_minus_one
|
||||
)
|
||||
[for(b = maze) [get_x(b), get_y(b)] == [nx, y] ? [nx, y, 1, 0] : b];
|
||||
[for(cell = cells) [get_x(cell), get_y(cell)] == [nx, y] ? [nx, y, 1, 0] : cell];
|
||||
|
||||
// go down and carve the top wall of the bottom block
|
||||
function carve_bottom(x, y, maze, rows) =
|
||||
// go down and carve the top wall of the bottom cell
|
||||
function carve_bottom(x, y, cells, rows) =
|
||||
let(
|
||||
y_minus_one = y - 1,
|
||||
ny = y_minus_one < 0 ? y_minus_one + rows : y_minus_one
|
||||
)
|
||||
[for(b = maze) [get_x(b), get_y(b)] == [x, ny] ? [x, ny, 2, 0] : b];
|
||||
[for(cell = cells) [get_x(cell), get_y(cell)] == [x, ny] ? [x, ny, 2, 0] : cell];
|
||||
|
||||
// 0(right), 1(top), 2(left), 3(bottom)
|
||||
function carve(dir, x, y, maze, rows, columns) =
|
||||
dir == 0 ? carve_right(x, y, maze) :
|
||||
dir == 1 ? carve_top(x, y, maze) :
|
||||
dir == 2 ? carve_left(x, y, maze, columns) :
|
||||
/*dir 3*/ carve_bottom(x, y, maze, rows);
|
||||
function carve(dir, x, y, cells, rows, columns) =
|
||||
dir == 0 ? carve_right(x, y, cells) :
|
||||
dir == 1 ? carve_top(x, y, cells) :
|
||||
dir == 2 ? carve_left(x, y, cells, columns) :
|
||||
/*dir 3*/ carve_bottom(x, y, cells, rows);
|
||||
|
||||
|
||||
// find out visitable dirs from (x, y)
|
||||
function visitable_dirs(r_dirs, x, y, maze, rows, columns, x_wrapping, y_wrapping) = [
|
||||
function visitable_dirs(r_dirs, x, y, cells, rows, columns, x_wrapping, y_wrapping) = [
|
||||
for(dir = r_dirs)
|
||||
if(visitable(next_x(x, dir, columns, x_wrapping), next_y(y, dir, rows, y_wrapping), maze, rows, columns))
|
||||
if(visitable(next_x(x, dir, columns, x_wrapping), next_y(y, dir, rows, y_wrapping), cells, rows, columns))
|
||||
dir
|
||||
];
|
||||
|
||||
// go maze from (x, y)
|
||||
function go_maze(x, y, maze, rows, columns, x_wrapping = false, y_wrapping = false, seed) =
|
||||
function go_maze(x, y, cells, rows, columns, x_wrapping = false, y_wrapping = false, seed) =
|
||||
let(
|
||||
r_dirs = rand_dirs(x * rows + y, seed),
|
||||
v_dirs = visitable_dirs(r_dirs, x, y, maze, rows, columns, x_wrapping, y_wrapping)
|
||||
v_dirs = visitable_dirs(r_dirs, x, y, cells, rows, columns, x_wrapping, y_wrapping)
|
||||
)
|
||||
// have visitable dirs?
|
||||
len(v_dirs) == 0 ?
|
||||
set_visited(x, y, maze) // road closed
|
||||
set_visited(x, y, cells) // road closed
|
||||
: walk_around_from(
|
||||
x, y,
|
||||
v_dirs,
|
||||
set_visited(x, y, maze),
|
||||
set_visited(x, y, cells),
|
||||
rows, columns,
|
||||
x_wrapping, y_wrapping,
|
||||
seed = seed
|
||||
);
|
||||
|
||||
// try four directions
|
||||
function walk_around_from(x, y, dirs, maze, rows, columns, x_wrapping, y_wrapping, i = 0, seed) =
|
||||
function walk_around_from(x, y, dirs, cells, rows, columns, x_wrapping, y_wrapping, i = 0, seed) =
|
||||
// all done?
|
||||
i < len(dirs) ?
|
||||
// not yet
|
||||
walk_around_from(x, y, dirs,
|
||||
// try one direction
|
||||
try_routes_from(x, y, dirs[i], maze, rows, columns, x_wrapping, y_wrapping, seed),
|
||||
try_routes_from(x, y, dirs[i], cells, rows, columns, x_wrapping, y_wrapping, seed),
|
||||
rows, columns,
|
||||
x_wrapping, y_wrapping,
|
||||
i + 1,
|
||||
seed)
|
||||
: maze;
|
||||
: cells;
|
||||
|
||||
function try_routes_from(x, y, dir, maze, rows, columns, x_wrapping, y_wrapping, seed) =
|
||||
function try_routes_from(x, y, dir, cells, rows, columns, x_wrapping, y_wrapping, seed) =
|
||||
// is the dir visitable?
|
||||
visitable(next_x(x, dir, columns, x_wrapping), next_y(y, dir, rows, y_wrapping), maze, rows, columns) ?
|
||||
// try the block
|
||||
visitable(next_x(x, dir, columns, x_wrapping), next_y(y, dir, rows, y_wrapping), cells, rows, columns) ?
|
||||
// try the cell
|
||||
go_maze(
|
||||
next_x(x, dir, columns, x_wrapping), next_y(y, dir, rows, y_wrapping),
|
||||
carve(dir, x, y, maze, rows, columns),
|
||||
carve(dir, x, y, cells, rows, columns),
|
||||
rows, columns,
|
||||
x_wrapping, y_wrapping,
|
||||
seed
|
||||
)
|
||||
// road closed so return maze directly
|
||||
: maze;
|
||||
// road closed so return cells directly
|
||||
: cells;
|
@@ -4,12 +4,12 @@
|
||||
// TOP_RIGHT_WALL = 3;
|
||||
// MASK = 4;
|
||||
|
||||
function no_wall(block) = get_wall_type(block) == 0;
|
||||
function top_wall(block) = get_wall_type(block) == 1;
|
||||
function right_wall(block) = get_wall_type(block) == 2;
|
||||
function top_right_wall(block) = get_wall_type(block) == 3;
|
||||
function no_wall(cell) = get_wall_type(cell) == 0;
|
||||
function top_wall(cell) = get_wall_type(cell) == 1;
|
||||
function right_wall(cell) = get_wall_type(cell) == 2;
|
||||
function top_right_wall(cell) = get_wall_type(cell) == 3;
|
||||
|
||||
function block(x, y, wall_type, visited) = [x, y, wall_type, visited];
|
||||
function get_x(block) = block[0];
|
||||
function get_y(block) = block[1];
|
||||
function get_wall_type(block) = block[2];
|
||||
function cell(x, y, wall_type, visited) = [x, y, wall_type, visited];
|
||||
function get_x(cell) = cell[0];
|
||||
function get_y(cell) = cell[1];
|
||||
function get_wall_type(cell) = cell[2];
|
@@ -1,12 +1,12 @@
|
||||
use <../mz_square_get.scad>;
|
||||
|
||||
function _get_x(block) = mz_square_get(block, "x");
|
||||
function _get_y(block) = mz_square_get(block, "y");
|
||||
function _get_wall_type(block) = mz_square_get(block, "w");
|
||||
function _get_x(cell) = mz_square_get(cell, "x");
|
||||
function _get_y(cell) = mz_square_get(cell, "y");
|
||||
function _get_wall_type(cell) = mz_square_get(cell, "w");
|
||||
|
||||
function _is_top_wall(block) = _get_wall_type(block) == "TOP_WALL";
|
||||
function _is_right_wall(block) = _get_wall_type(block) == "RIGHT_WALL";
|
||||
function _is_top_right_wall(block) = _get_wall_type(block) == "TOP_RIGHT_WALL";
|
||||
function _is_top_wall(cell) = _get_wall_type(cell) == "TOP_WALL";
|
||||
function _is_right_wall(cell) = _get_wall_type(cell) == "RIGHT_WALL";
|
||||
function _is_top_right_wall(cell) = _get_wall_type(cell) == "TOP_RIGHT_WALL";
|
||||
|
||||
function _cell_position(cell_radius, x_cell, y_cell) =
|
||||
let(
|
||||
@@ -31,14 +31,14 @@ function _right_wall(cell_radius, x_cell) =
|
||||
function _row_wall(cell_radius, x_cell, y_cell) =
|
||||
x_cell % 2 != 0 ? [_top_right(cell_radius), _top_left(cell_radius)] : [_bottom_right(cell_radius)];
|
||||
|
||||
function _build_cell(cell_radius, block) =
|
||||
function _build_cell(cell_radius, cell) =
|
||||
let(
|
||||
x = _get_x(block),
|
||||
y = _get_y(block),
|
||||
x = _get_x(cell),
|
||||
y = _get_y(cell),
|
||||
walls = concat(
|
||||
_row_wall(cell_radius, x, y),
|
||||
[_is_top_wall(block) || _is_top_right_wall(block) ? _top(cell_radius) : []],
|
||||
[_is_right_wall(block) || _is_top_right_wall(block) ? _right_wall(cell_radius, x) : []]
|
||||
[_is_top_wall(cell) || _is_top_right_wall(cell) ? _top(cell_radius) : []],
|
||||
[_is_right_wall(cell) || _is_top_right_wall(cell) ? _right_wall(cell_radius, x) : []]
|
||||
)
|
||||
)
|
||||
[
|
||||
|
@@ -4,9 +4,9 @@ use <_mz_comm.scad>;
|
||||
function _rc_maze(rows, columns) = [
|
||||
for(y = [0:rows - 1])
|
||||
for(x = [0:columns - 1])
|
||||
block(
|
||||
cell(
|
||||
x, y,
|
||||
// all blocks have top and right walls
|
||||
// all cells have top and right walls
|
||||
3,
|
||||
// unvisited
|
||||
false
|
||||
@@ -22,15 +22,15 @@ function _mz_mask(mask) =
|
||||
for(y = [0:rows - 1])
|
||||
for(x = [0:columns - 1])
|
||||
mask[rows - y - 1][x] == 0 ?
|
||||
block(
|
||||
cell(
|
||||
x, y,
|
||||
4, // mask
|
||||
true // visited
|
||||
)
|
||||
:
|
||||
block(
|
||||
cell(
|
||||
x, y,
|
||||
// all blocks have top and right walls
|
||||
// all cells have top and right walls
|
||||
3, // unvisited
|
||||
false
|
||||
)
|
||||
|
@@ -1,9 +1,9 @@
|
||||
use <_mz_comm.scad>;
|
||||
|
||||
function _square_walls(block, block_width) =
|
||||
function _square_walls(cell, cell_width) =
|
||||
let(
|
||||
loc = [get_x(block), get_y(block)] * block_width,
|
||||
top = top_wall(block) || top_right_wall(block) ? [[0, block_width] + loc, [block_width, block_width] + loc] : [],
|
||||
right = right_wall(block) || top_right_wall(block) ? [[block_width, block_width] + loc, [block_width, 0] + loc] : []
|
||||
loc = [get_x(cell), get_y(cell)] * cell_width,
|
||||
top = top_wall(cell) || top_right_wall(cell) ? [[0, cell_width] + loc, [cell_width, cell_width] + loc] : [],
|
||||
right = right_wall(cell) || top_right_wall(cell) ? [[cell_width, cell_width] + loc, [cell_width, 0] + loc] : []
|
||||
)
|
||||
concat(top, right);
|
||||
|
@@ -1,22 +1,22 @@
|
||||
use <_impl/_mz_hamiltonian_impl.scad>;
|
||||
use <mz_square_blocks.scad>;
|
||||
use <mz_square_cells.scad>;
|
||||
use <mz_square_get.scad>;
|
||||
use <../util/sort.scad>;
|
||||
use <../util/dedup.scad>;
|
||||
|
||||
function mz_hamiltonian(rows, columns, start, seed) =
|
||||
let(
|
||||
blocks = mz_square_blocks(
|
||||
cells = mz_square_cells(
|
||||
rows, columns,
|
||||
seed = seed
|
||||
),
|
||||
all = concat(
|
||||
[
|
||||
for(block = blocks)
|
||||
for(cell = cells)
|
||||
let(
|
||||
x = mz_square_get(block, "x"),
|
||||
y = mz_square_get(block, "y"),
|
||||
wall_type = mz_square_get(block, "w"),
|
||||
x = mz_square_get(cell, "x"),
|
||||
y = mz_square_get(cell, "y"),
|
||||
wall_type = mz_square_get(cell, "w"),
|
||||
pts = wall_type == "TOP_WALL" ? _mz_hamiltonian_top(x, y) :
|
||||
wall_type == "RIGHT_WALL" ? _mz_hamiltonian_right(x, y) :
|
||||
wall_type == "TOP_RIGHT_WALL" ? _mz_hamiltonian_top_right(x, y) : []
|
||||
|
@@ -1,10 +1,10 @@
|
||||
use <_impl/_mz_hex_walls.scad>;
|
||||
|
||||
function mz_hex_walls(blocks, rows, columns, cell_radius, wall_thickness, left_border = true, bottom_border = true) =
|
||||
function mz_hex_walls(cells, rows, columns, cell_radius, wall_thickness, left_border = true, bottom_border = true) =
|
||||
let(
|
||||
walls = [
|
||||
for(block = blocks)
|
||||
for(wall = _build_cell(cell_radius, block))
|
||||
for(cell = cells)
|
||||
for(wall = _build_cell(cell_radius, cell))
|
||||
wall
|
||||
],
|
||||
left_pair_walls = left_border ? [
|
||||
|
@@ -1,9 +0,0 @@
|
||||
use <_impl/_mz_blocks_impl.scad>;
|
||||
use <mz_square_initialize.scad>;
|
||||
|
||||
function mz_square_blocks(rows, columns, start = [0, 0], init_blocks, x_wrapping = false, y_wrapping = false, seed) =
|
||||
go_maze(
|
||||
start[0], start[1], // starting point
|
||||
is_undef(init_blocks) ? mz_square_initialize(rows, columns) : init_blocks,
|
||||
rows, columns, x_wrapping, y_wrapping, seed
|
||||
);
|
9
src/maze/mz_square_cells.scad
Normal file
9
src/maze/mz_square_cells.scad
Normal file
@@ -0,0 +1,9 @@
|
||||
use <_impl/_mz_cells_impl.scad>;
|
||||
use <mz_square_initialize.scad>;
|
||||
|
||||
function mz_square_cells(rows, columns, start = [0, 0], init_cells, x_wrapping = false, y_wrapping = false, seed) =
|
||||
go_maze(
|
||||
start[0], start[1], // starting point
|
||||
is_undef(init_cells) ? mz_square_initialize(rows, columns) : init_cells,
|
||||
rows, columns, x_wrapping, y_wrapping, seed
|
||||
);
|
@@ -1,4 +1,4 @@
|
||||
function mz_square_get(block, query) =
|
||||
function mz_square_get(cell, query) =
|
||||
let(
|
||||
i = search(query, [
|
||||
["x", 0],
|
||||
@@ -6,4 +6,4 @@ function mz_square_get(block, query) =
|
||||
["w", 2]
|
||||
])[0]
|
||||
)
|
||||
i != 2 ? block[i] : ["NO_WALL", "TOP_WALL", "RIGHT_WALL", "TOP_RIGHT_WALL", "MASK"][block[i]];
|
||||
i != 2 ? cell[i] : ["NO_WALL", "TOP_WALL", "RIGHT_WALL", "TOP_RIGHT_WALL", "MASK"][cell[i]];
|
@@ -1,14 +1,14 @@
|
||||
use <_impl/_mz_square_walls_impl.scad>;
|
||||
|
||||
function mz_square_walls(blocks, rows, columns, block_width, left_border = true, bottom_border = true) =
|
||||
function mz_square_walls(cells, rows, columns, cell_width, left_border = true, bottom_border = true) =
|
||||
let(
|
||||
left_walls = left_border ? [for(y = [0:rows - 1]) [[0, block_width * (y + 1)], [0, block_width * y]]] : [],
|
||||
buttom_walls = bottom_border ? [for(x = [0:columns - 1]) [[block_width * x, 0], [block_width * (x + 1), 0]]] : []
|
||||
left_walls = left_border ? [for(y = [0:rows - 1]) [[0, cell_width * (y + 1)], [0, cell_width * y]]] : [],
|
||||
buttom_walls = bottom_border ? [for(x = [0:columns - 1]) [[cell_width * x, 0], [cell_width * (x + 1), 0]]] : []
|
||||
)
|
||||
concat(
|
||||
[
|
||||
for(block = blocks)
|
||||
let(pts = _square_walls(block, block_width))
|
||||
for(cell = cells)
|
||||
let(pts = _square_walls(cell, cell_width))
|
||||
if(pts != []) pts
|
||||
]
|
||||
, left_walls, buttom_walls
|
||||
|
Reference in New Issue
Block a user