1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-11 01:04:07 +02:00

rename block to cell

This commit is contained in:
Justin Lin
2020-12-20 10:49:16 +08:00
parent afaf67c739
commit f594215469
29 changed files with 245 additions and 247 deletions

View File

@@ -1,15 +1,15 @@
use <square_maze.scad>; use <square_maze.scad>;
maze_rows = 8; maze_rows = 8;
block_width = 2; cell_width = 2;
wall_thickness = 1; wall_thickness = 1;
inner_cube = true; inner_cube = true;
travel_all = true; travel_all = true;
module cube_maze(maze_rows, block_width, wall_thickness, inner_cube, travel_all) { module cube_maze(maze_rows, cell_width, wall_thickness, inner_cube, travel_all) {
blocks_size = block_width * maze_rows; cells_size = cell_width * maze_rows;
cube_size = blocks_size - wall_thickness; cube_size = cells_size - wall_thickness;
maze_size = blocks_size + wall_thickness; maze_size = cells_size + wall_thickness;
half_wall_thickness = wall_thickness / 2; half_wall_thickness = wall_thickness / 2;
half_cube_size = cube_size / 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() { module one_maze() {
translate([origin, origin, half_cube_size]) translate([origin, origin, half_cube_size])
linear_extrude(wall_thickness) linear_extrude(wall_thickness)
square_maze(maze_rows, block_width, wall_thickness); square_maze(maze_rows, cell_width, wall_thickness);
} }
one_maze(); 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);

View File

@@ -1,10 +1,10 @@
use <bend.scad>; use <bend.scad>;
use <maze/mz_square_blocks.scad>; use <maze/mz_square_cells.scad>;
use <maze/mz_square_walls.scad>; use <maze/mz_square_walls.scad>;
radius = 30; radius = 30;
height = 60; height = 60;
block_width = 8; cell_width = 8;
wall_thickness = 5; wall_thickness = 5;
wall_height = 5; wall_height = 5;
@@ -32,19 +32,19 @@ module cylinder_maze() {
} }
} }
maze_rows = round(height / block_width); maze_rows = round(height / cell_width);
maze_columns = round(2 * 3.14159 * radius / block_width); maze_columns = round(2 * 3.14159 * radius / cell_width);
maze_blocks = mz_square_blocks( maze_cells = mz_square_cells(
maze_rows, maze_columns, maze_rows, maze_columns,
x_wrapping = true 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]) translate([0, wall_thickness / 2])
for(wall = walls) { for(wall = walls) {
for(i = [0:len(wall) - 2]) { for(i = [0:len(wall) - 2]) {

View File

@@ -1,14 +1,14 @@
use <regular_polygon_maze.scad>; use <regular_polygon_maze.scad>;
use <hollow_out.scad>; use <hollow_out.scad>;
cblocks = 8; ccells = 8;
wall_thickness = 1.5; wall_thickness = 1.5;
spacing = 0.6; spacing = 0.6;
$fn = 48; $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. // Don't change these variables. They require more math.
radius = 15; radius = 15;
wall_height = 1; wall_height = 1;
@@ -20,7 +20,7 @@ module gyro_maze(cblocks, wall_thickness, spacing) {
linear_extrude(wall_height) linear_extrude(wall_height)
scale(1.029) { scale(1.029) {
difference() { 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);
} }
circle(radius / 3.5 - wall_thickness / 1.45); circle(radius / 3.5 - wall_thickness / 1.45);

View File

@@ -1,6 +1,6 @@
use <arc.scad>; use <arc.scad>;
use <heart_maze.scad>; use <heart_maze.scad>;
use <maze/mz_square_blocks.scad>; use <maze/mz_square_cells.scad>;
names = ["Justin", "Monica"]; names = ["Justin", "Monica"];
font_name = "Arial Black"; font_name = "Arial Black";
@@ -9,7 +9,7 @@ font_size = 8;
radius_of_heart = 15; radius_of_heart = 15;
tip_r_of_heart = 5; tip_r_of_heart = 5;
wall_thickness = 2.5; wall_thickness = 2.5;
cblocks = 6; ccells = 6;
levels = 3; levels = 3;
spacing = 0.4; 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); 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) { module heart2heart_maze(names, font_name, font_size, radius_of_heart, tip_r_of_heart, wall_thickness, ccells, levels, spacing) {
maze = mz_square_blocks( maze = mz_square_cells(
cblocks, levels, y_wrapping = true ccells, levels, y_wrapping = true
); );
translate([0, 0, wall_thickness]) translate([0, 0, wall_thickness])
linear_extrude(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); 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]) { 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); heart(radius_of_heart, tip_r_of_heart);
linear_extrude(wall_thickness * 2) linear_extrude(wall_thickness * 2)
offset(delta = spacing) 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);

View File

@@ -2,14 +2,14 @@ use <line2d.scad>;
use <hollow_out.scad>; use <hollow_out.scad>;
use <ellipse_extrude.scad>; use <ellipse_extrude.scad>;
use <arc.scad>; use <arc.scad>;
use <maze/mz_square_blocks.scad>; use <maze/mz_square_cells.scad>;
use <maze/mz_square_get.scad>; use <maze/mz_square_get.scad>;
radius_of_heart = 12; radius_of_heart = 12;
height_of_heart = 25; height_of_heart = 25;
tip_r_of_heart = 5; tip_r_of_heart = 5;
wall_thickness = 2; wall_thickness = 2;
cblocks = 6; ccells = 6;
levels = 3; levels = 3;
$fn = 36; $fn = 36;
@@ -58,17 +58,17 @@ module heart_to_heart_wall(radius, length, angle, thickness) {
} }
} }
module heart_maze(maze, radius, cblocks, levels, thickness = 1) { module heart_maze(maze, radius, ccells, levels, thickness = 1) {
function no_wall(block) = get_wall_type(block) == "NO_WALL"; function no_wall(cell) = get_wall_type(cell) == "NO_WALL";
function top_wall(block) = get_wall_type(block) == "TOP_WALL"; function top_wall(cell) = get_wall_type(cell) == "TOP_WALL";
function right_wall(block) = get_wall_type(block) == "RIGHT_WALL"; function right_wall(cell) = get_wall_type(cell) == "RIGHT_WALL";
function top_right_wall(block) = get_wall_type(block) == "TOP_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_x(cell) = mz_square_get(cell, "x");
function get_y(block) = mz_square_get(block, "y"); function get_y(cell) = mz_square_get(cell, "y");
function get_wall_type(block) = mz_square_get(block, "w"); function get_wall_type(cell) = mz_square_get(cell, "w");
arc_angle = 360 / cblocks; arc_angle = 360 / ccells;
r = radius / (levels + 1); r = radius / (levels + 1);
difference() { difference() {
@@ -79,13 +79,13 @@ module heart_maze(maze, radius, cblocks, levels, thickness = 1) {
for(i = [0:len(maze) - 1]) { for(i = [0:len(maze) - 1]) {
block = maze[i]; cell = maze[i];
cr = get_x(block) + 1; cr = get_x(cell) + 1;
cc = get_y(block); cc = get_y(cell);
angle = cc * arc_angle; 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); 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() { render() union() {
// road to the next level // road to the next level
for(i = [0:len(maze) - 1]) { for(i = [0:len(maze) - 1]) {
block = maze[i]; cell = maze[i];
cr = get_x(block) + 1; cr = get_x(cell) + 1;
cc = get_y(block); 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); 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( maze = mz_square_cells(
cblocks, levels, y_wrapping = true ccells, levels, y_wrapping = true
); );
intersection() { intersection() {
@@ -121,7 +121,7 @@ intersection() {
} }
linear_extrude(height_of_heart, center = true) 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) linear_extrude(wall_thickness * 2, center = true)

View File

@@ -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_walls.scad>;
use <maze/mz_square_initialize.scad>; use <maze/mz_square_initialize.scad>;
use <voxel/vx_contour.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] [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_thickness = 1;
wall_height = 2; wall_height = 2;
base_height = 1; base_height = 1;
contour = true; contour = true;
base = 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); rows = len(mask);
columns = len(mask[0]); columns = len(mask[0]);
blocks = mz_square_blocks( cells = mz_square_cells(
rows, columns, start, rows, columns, start,
mz_square_initialize(mask = mask) mz_square_initialize(mask = mask)
); );
@@ -41,7 +41,7 @@ module maze_masking(start, mask, block_width, wall_thickness, wall_height, base_
[x, y] [x, y]
], sorted = true) : []; ], sorted = true) : [];
walls = mz_square_walls(blocks, rows, columns, block_width); walls = mz_square_walls(cells, rows, columns, cell_width);
color("gray") color("gray")
linear_extrude(wall_height) 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(y = [0:rows - 1]) {
for(x = [0:columns - 1]) { for(x = [0:columns - 1]) {
if(mask[rows - y - 1][x] == 0) { if(mask[rows - y - 1][x] == 0) {
translate([x * block_width + wall_thickness, y * block_width + wall_thickness]) translate([x * cell_width + wall_thickness, y * cell_width + wall_thickness])
square(block_width); square(cell_width);
} }
} }
} }
@@ -71,7 +71,7 @@ module maze_masking(start, mask, block_width, wall_thickness, wall_height, base_
if(contour) { if(contour) {
translate([wall_thickness * 2, wall_thickness * 2]) 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]) translate([0, 0, -base_height])
linear_extrude(base_height) linear_extrude(base_height)
translate([wall_thickness * 2, wall_thickness * 2]) translate([wall_thickness * 2, wall_thickness * 2])
polygon(pts * block_width); polygon(pts * cell_width);
} }
else { else {
translate([0, 0, -base_height]) translate([0, 0, -base_height])
linear_extrude(base_height) linear_extrude(base_height)
translate([wall_thickness, wall_thickness]) 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);

View File

@@ -1,27 +1,27 @@
use <hull_polyline3d.scad>; use <hull_polyline3d.scad>;
use <maze/mz_square_blocks.scad>; use <maze/mz_square_cells.scad>;
use <maze/mz_square_walls.scad>; use <maze/mz_square_walls.scad>;
use <ptf/ptf_ring.scad>; use <ptf/ptf_ring.scad>;
rows = 48; rows = 48;
columns = 8; columns = 8;
block_width = 2; cell_width = 2;
wall_thickness = 1; wall_thickness = 1;
angle = 180; angle = 180;
// $fn = 24; // $fn = 24;
leng = rows * block_width; leng = rows * cell_width;
radius = 0.5 * leng / PI; radius = 0.5 * leng / PI;
a_step = 360 / leng; a_step = 360 / leng;
blocks = mz_square_blocks( cells = mz_square_cells(
rows, columns, rows, columns,
y_wrapping = true 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) { for(wall_pts = walls) {
transformed = [for(pt = wall_pts) ptf_ring(size, pt, radius, 360, angle)]; transformed = [for(pt = wall_pts) ptf_ring(size, pt, radius, 360, angle)];
hull_polyline3d(transformed, wall_thickness); hull_polyline3d(transformed, wall_thickness);

View File

@@ -1,18 +1,18 @@
use <hull_polyline2d.scad>; use <hull_polyline2d.scad>;
use <util/rand.scad>; use <util/rand.scad>;
use <maze/mz_square_blocks.scad>; use <maze/mz_square_cells.scad>;
use <maze/mz_square_walls.scad>; use <maze/mz_square_walls.scad>;
use <ptf/ptf_circle.scad>; use <ptf/ptf_circle.scad>;
use <noise/nz_perlin2.scad>; use <noise/nz_perlin2.scad>;
module noisy_circle_maze(r_blocks, block_width, wall_thickness, origin_offset, noisy_factor) { module noisy_circle_maze(r_cells, cell_width, wall_thickness, origin_offset, noisy_factor) {
double_r_blocks = r_blocks * 2; double_r_cells = r_cells * 2;
blocks = mz_square_blocks( cells = mz_square_cells(
double_r_blocks, double_r_blocks double_r_cells, double_r_cells
); );
width = double_r_blocks * block_width; width = double_r_cells * cell_width;
walls = mz_square_walls(blocks, double_r_blocks, double_r_blocks, block_width); walls = mz_square_walls(cells, double_r_cells, double_r_cells, cell_width);
half_width = width / 2; half_width = width / 2;
rect_size = is_undef(origin_offset) ? [width, width] : [width, width] - origin_offset * 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( noisy_circle_maze(
r_blocks = 8, r_cells = 8,
block_width = 5, cell_width = 5,
wall_thickness = 2, wall_thickness = 2,
noisy_factor = 2 noisy_factor = 2
); );

View File

@@ -1,5 +1,5 @@
use <polyline2d.scad>; use <polyline2d.scad>;
use <maze/mz_square_blocks.scad>; use <maze/mz_square_cells.scad>;
use <maze/mz_hex_walls.scad>; use <maze/mz_hex_walls.scad>;
columns = 10; columns = 10;
@@ -30,11 +30,9 @@ module pyramid_hex_maze(columns, cell_radius, wall_thickness) {
pyramid_height = square_w / sqrt(2); pyramid_height = square_w / sqrt(2);
blocks = mz_square_blocks( cells = mz_square_cells(rows, columns);
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() { intersection() {
linear_extrude(pyramid_height) linear_extrude(pyramid_height)

View File

@@ -1,26 +1,26 @@
use <square_maze.scad>; use <square_maze.scad>;
maze_rows = 10; maze_rows = 10;
block_width = 2; cell_width = 2;
wall_thickness = 1; wall_thickness = 1;
module pyramid_maze(maze_rows, block_width, wall_thickness) { module pyramid_maze(maze_rows, cell_width, wall_thickness) {
module pyramid(leng) { module pyramid(leng) {
height = leng / 1.4142135623730950488016887242097; height = leng / 1.4142135623730950488016887242097;
linear_extrude(height, scale = 0) linear_extrude(height, scale = 0)
square(leng, center = true); square(leng, center = true);
} }
leng = maze_rows * block_width ; leng = maze_rows * cell_width ;
half_leng = leng / 2; half_leng = leng / 2;
intersection() { intersection() {
linear_extrude(leng * 2) linear_extrude(leng * 2)
translate([-half_leng, -half_leng]) 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(leng + wall_thickness);
} }
} }
pyramid_maze(maze_rows, block_width, wall_thickness); pyramid_maze(maze_rows, cell_width, wall_thickness);

View File

@@ -1,6 +1,6 @@
use <line2d.scad>; use <line2d.scad>;
use <hollow_out.scad>; use <hollow_out.scad>;
use <maze/mz_square_blocks.scad>; use <maze/mz_square_cells.scad>;
use <maze/mz_square_get.scad>; use <maze/mz_square_get.scad>;
// only for creating a small maze // only for creating a small maze
@@ -8,7 +8,7 @@ use <maze/mz_square_get.scad>;
radius_of_circle_wrapper = 15; radius_of_circle_wrapper = 15;
wall_thickness = 1; wall_thickness = 1;
wall_height = 1; wall_height = 1;
cblocks = 6; ccells = 6;
levels = 3; levels = 3;
sides = 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) { module regular_polygon_maze(radius, ccells, levels, thickness = 1, sides) {
function no_wall(block) = get_wall_type(block) == "NO_WALL"; function no_wall(cell) = get_wall_type(cell) == "NO_WALL";
function top_wall(block) = get_wall_type(block) == "TOP_WALL"; function top_wall(cell) = get_wall_type(cell) == "TOP_WALL";
function right_wall(block) = get_wall_type(block) == "RIGHT_WALL"; function right_wall(cell) = get_wall_type(cell) == "RIGHT_WALL";
function top_right_wall(block) = get_wall_type(block) == "TOP_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_x(cell) = mz_square_get(cell, "x");
function get_y(block) = mz_square_get(block, "y"); function get_y(cell) = mz_square_get(cell, "y");
function get_wall_type(block) = mz_square_get(block, "w"); function get_wall_type(cell) = mz_square_get(cell, "w");
arc_angle = 360 / cblocks; arc_angle = 360 / ccells;
r = radius / (levels + 1); r = radius / (levels + 1);
maze = mz_square_blocks( maze = mz_square_cells(
cblocks, levels, y_wrapping = true ccells, levels, y_wrapping = true
); );
difference() { difference() {
@@ -61,13 +61,13 @@ module regular_polygon_maze(radius, cblocks, levels, thickness = 1, sides) {
for(i = [0:len(maze) - 1]) { for(i = [0:len(maze) - 1]) {
block = maze[i]; cell = maze[i];
cr = get_x(block) + 1; cr = get_x(cell) + 1;
cc = get_y(block); cc = get_y(cell);
angle = cc * arc_angle; 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); 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 // road to the next level
for(i = [0:len(maze) - 1]) { for(i = [0:len(maze) - 1]) {
block = maze[i]; cell = maze[i];
cr = get_x(block) + 1; cr = get_x(cell) + 1;
cc = get_y(block); 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); 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) 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);

View File

@@ -1,15 +1,15 @@
use <matrix/m_rotation.scad>; use <matrix/m_rotation.scad>;
use <maze/mz_square_blocks.scad>; use <maze/mz_square_cells.scad>;
use <maze/mz_square_walls.scad>; use <maze/mz_square_walls.scad>;
use <ptf/ptf_sphere.scad>; use <ptf/ptf_sphere.scad>;
r = 10; r = 10;
rows = 24; rows = 24;
columns = 18; columns = 18;
block_width = .5; cell_width = .5;
wall_thickness = .5; wall_thickness = .5;
wall_height = 1.5; wall_height = 1.5;
pole_offset = block_width * 2.5; pole_offset = cell_width * 2.5;
module sphere_maze() { module sphere_maze() {
function _angles(p) = function _angles(p) =
@@ -50,16 +50,16 @@ module sphere_maze() {
} }
size = [rows * block_width, columns * block_width + pole_offset * 2]; size = [rows * cell_width, columns * cell_width + pole_offset * 2];
blocks = mz_square_blocks( cells = mz_square_cells(
rows, columns, rows, columns,
y_wrapping = true y_wrapping = true
); );
p_offset = [block_width * rows, pole_offset, 0]; p_offset = [cell_width * rows, pole_offset, 0];
mr = m_rotation(90); 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) { for(wall_pts = walls) {
rxpts = [ rxpts = [
for(p = wall_pts) for(p = wall_pts)

View File

@@ -1,12 +1,12 @@
use <maze/mz_square_blocks.scad>; use <maze/mz_square_cells.scad>;
use <maze/mz_square_walls.scad>; use <maze/mz_square_walls.scad>;
module square_maze(rows, block_width, wall_thickness) { module square_maze(rows, cell_width, wall_thickness) {
blocks = mz_square_blocks( cells = mz_square_cells(
rows, rows rows, rows
); );
walls = mz_square_walls(blocks, rows, rows, block_width); walls = mz_square_walls(cells, rows, rows, cell_width);
for(wall = walls) { for(wall = walls) {
for(i = [0:len(wall) - 2]) { for(i = [0:len(wall) - 2]) {
@@ -20,6 +20,6 @@ module square_maze(rows, block_width, wall_thickness) {
square_maze( square_maze(
rows = 10, rows = 10,
block_width = 2, cell_width = 2,
wall_thickness = 1 wall_thickness = 1
); );

View File

@@ -1,7 +1,7 @@
use <square_maze.scad>; use <square_maze.scad>;
maze_rows = 8; maze_rows = 8;
block_width = 10; cell_width = 10;
stairs_width = 5; stairs_width = 5;
module pyramid_with_stairs(base_width, stairs_width, rows) { 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() { intersection() {
pyramid_with_stairs( 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() { difference() {
square_maze(maze_rows, block_width, stairs_width); square_maze(maze_rows, cell_width, stairs_width);
// entry // entry
translate([0, stairs_width]) translate([0, stairs_width])
square(stairs_width, center = true); square(stairs_width, center = true);
// exit // 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); square(stairs_width, center = true);
} }
} }
} }
} }
step_pyramid_maze(maze_rows, block_width, stairs_width); step_pyramid_maze(maze_rows, cell_width, stairs_width);

View File

@@ -1,6 +1,6 @@
use <polyline2d.scad>; use <polyline2d.scad>;
use <stereographic_extrude.scad>; use <stereographic_extrude.scad>;
use <maze/mz_square_blocks.scad>; use <maze/mz_square_cells.scad>;
use <maze/mz_hex_walls.scad>; use <maze/mz_hex_walls.scad>;
columns = 10; columns = 10;
@@ -24,11 +24,11 @@ module hex_maze_stereographic_projection(columns, cell_radius, wall_thickness, f
pyramid_height = square_w / sqrt(2); pyramid_height = square_w / sqrt(2);
// create a maze // create a maze
blocks = mz_square_blocks( cells = mz_square_cells(
rows, columns 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) stereographic_extrude(square_w, $fn = fn)
translate([grid_w - square_w / 2, grid_h - square_w / 2, 0]) translate([grid_w - square_w / 2, grid_h - square_w / 2, 0])

View File

@@ -2,18 +2,18 @@ use <stereographic_extrude.scad>;
use <square_maze.scad>; use <square_maze.scad>;
maze_rows = 10; maze_rows = 10;
block_width = 40; cell_width = 40;
wall_thickness = 20; wall_thickness = 20;
fn = 24; fn = 24;
shadow = "YES"; // [YES, NO] shadow = "YES"; // [YES, NO]
wall_height = 2; wall_height = 2;
module stereographic_projection_maze2(maze_rows, block_width, wall_thickness, fn, wall_height, shadow) { module stereographic_projection_maze2(maze_rows, cell_width, wall_thickness, fn, wall_height, shadow) {
length = block_width * maze_rows + wall_thickness; length = cell_width * maze_rows + wall_thickness;
module maze() { module maze() {
translate([-block_width * maze_rows / 2, -block_width * maze_rows / 2, 0]) translate([-cell_width * maze_rows / 2, -cell_width * maze_rows / 2, 0])
square_maze(maze_rows, block_width, wall_thickness); square_maze(maze_rows, cell_width, wall_thickness);
} }
stereographic_extrude(shadow_side_leng = length, $fn = fn) 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);

View File

@@ -1,27 +1,27 @@
use <hull_polyline3d.scad>; use <hull_polyline3d.scad>;
use <ptf/ptf_torus.scad>; use <ptf/ptf_torus.scad>;
use <maze/mz_square_blocks.scad>; use <maze/mz_square_cells.scad>;
use <maze/mz_square_walls.scad>; use <maze/mz_square_walls.scad>;
rows = 36; rows = 36;
columns = 12; columns = 12;
block_width = 2; cell_width = 2;
wall_thickness = 1; wall_thickness = 1;
angle = 180; angle = 180;
twist = 360; twist = 360;
leng = rows * block_width; leng = rows * cell_width;
radius = 0.5 * leng / PI; radius = 0.5 * leng / PI;
a_step = 360 / leng; a_step = 360 / leng;
blocks = mz_square_blocks( cells = mz_square_cells(
rows, columns, rows, columns,
x_wrapping = true, y_wrapping = true 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) { for(wall_pts = walls) {
transformed = [for(pt = wall_pts) ptf_torus(size, pt, [radius, radius / 2], twist = twist)]; transformed = [for(pt = wall_pts) ptf_torus(size, pt, [radius, radius / 2], twist = twist)];
hull_polyline3d(transformed, wall_thickness, $fn = 4); hull_polyline3d(transformed, wall_thickness, $fn = 4);

View File

@@ -1,24 +1,24 @@
use <hull_polyline3d.scad>; use <hull_polyline3d.scad>;
use <maze/mz_square_blocks.scad>; use <maze/mz_square_cells.scad>;
use <maze/mz_square_walls.scad>; use <maze/mz_square_walls.scad>;
use <ptf/ptf_x_twist.scad>; use <ptf/ptf_x_twist.scad>;
use <ptf/ptf_y_twist.scad>; use <ptf/ptf_y_twist.scad>;
rows = 10; rows = 10;
columns = 10; columns = 10;
block_width = 4; cell_width = 4;
wall_thickness = 1; wall_thickness = 1;
angle = 90; angle = 90;
axis = "X_AXIS"; // [X_AXIS, Y_AXIS] axis = "X_AXIS"; // [X_AXIS, Y_AXIS]
// $fn = 24; // $fn = 24;
blocks = mz_square_blocks( cells = mz_square_cells(
rows, columns 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) { for(wall_pts = walls) {
transformed = [for(pt = wall_pts) axis == "X_AXIS" ? ptf_x_twist(size, pt, angle) : ptf_y_twist(size, pt, angle)]; 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); hull_polyline3d(transformed, wall_thickness);

View File

@@ -1,26 +1,26 @@
use <_mz_comm.scad>; use <_mz_comm.scad>;
// find out the index of a block with the position (x, y) // find out the index of a cell with the position (x, y)
function indexOf(x, y, maze, i = 0) = function indexOf(x, y, cells, i = 0) =
i == len(maze) ? -1 : ( i == len(cells) ? -1 : (
[get_x(maze[i]), get_y(maze[i])] == [x, y] ? i : [get_x(cells[i]), get_y(cells[i])] == [x, y] ? i :
indexOf(x, y, maze, i + 1) indexOf(x, y, cells, i + 1)
); );
// is (x, y) visited? // 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? // is (x, y) visitable?
function visitable(x, y, maze, rows, columns) = function visitable(x, y, cells, rows, columns) =
y >= 0 && y < rows && // y bound y >= 0 && y < rows && // y bound
x >= 0 && x < columns && // x bound x >= 0 && x < columns && // x bound
!visited(x, y, maze); // unvisited !visited(x, y, cells); // unvisited
// setting (x, y) as being visited // setting (x, y) as being visited
function set_visited(x, y, maze) = [ function set_visited(x, y, cells) = [
for(b = maze) for(cell = cells)
[x, y] == [get_x(b), get_y(b)] ? [x, y] == [get_x(cell), get_y(cell)] ?
[x, y, get_wall_type(b), true] : b [x, y, get_wall_type(cell), true] : cell
]; ];
// 0(right), 1(top), 2(left), 3(bottom) // 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; wrapping ? (ny < 0 ? ny + rows : ny % rows) : ny;
// go right and carve the right wall // go right and carve the right wall
function carve_right(x, y, maze) = [ function carve_right(x, y, cells) = [
for(b = maze) [get_x(b), get_y(b)] == [x, y] ? ( for(cell = cells) [get_x(cell), get_y(cell)] == [x, y] ? (
top_right_wall(b) ? [x, y, 1, 1] : [x, y, 0, 1] top_right_wall(cell) ? [x, y, 1, 1] : [x, y, 0, 1]
) : b ) : cell
]; ];
// go up and carve the top wall // go up and carve the top wall
function carve_top(x, y, maze) = [ function carve_top(x, y, cells) = [
for(b = maze) [get_x(b), get_y(b)] == [x, y] ? ( for(cell = cells) [get_x(cell), get_y(cell)] == [x, y] ? (
top_right_wall(b) ? [x, y, 2, 1] : [x, y, 0, 1] top_right_wall(cell) ? [x, y, 2, 1] : [x, y, 0, 1]
) : b ) : cell
]; ];
// go left and carve the right wall of the left block // go left and carve the right wall of the left cell
function carve_left(x, y, maze, columns) = function carve_left(x, y, cells, columns) =
let( let(
x_minus_one = x - 1, x_minus_one = x - 1,
nx = x_minus_one < 0 ? x_minus_one + columns : x_minus_one 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 // go down and carve the top wall of the bottom cell
function carve_bottom(x, y, maze, rows) = function carve_bottom(x, y, cells, rows) =
let( let(
y_minus_one = y - 1, y_minus_one = y - 1,
ny = y_minus_one < 0 ? y_minus_one + rows : y_minus_one 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) // 0(right), 1(top), 2(left), 3(bottom)
function carve(dir, x, y, maze, rows, columns) = function carve(dir, x, y, cells, rows, columns) =
dir == 0 ? carve_right(x, y, maze) : dir == 0 ? carve_right(x, y, cells) :
dir == 1 ? carve_top(x, y, maze) : dir == 1 ? carve_top(x, y, cells) :
dir == 2 ? carve_left(x, y, maze, columns) : dir == 2 ? carve_left(x, y, cells, columns) :
/*dir 3*/ carve_bottom(x, y, maze, rows); /*dir 3*/ carve_bottom(x, y, cells, rows);
// find out visitable dirs from (x, y) // 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) 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 dir
]; ];
// go maze from (x, y) // 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( let(
r_dirs = rand_dirs(x * rows + y, seed), 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? // have visitable dirs?
len(v_dirs) == 0 ? len(v_dirs) == 0 ?
set_visited(x, y, maze) // road closed set_visited(x, y, cells) // road closed
: walk_around_from( : walk_around_from(
x, y, x, y,
v_dirs, v_dirs,
set_visited(x, y, maze), set_visited(x, y, cells),
rows, columns, rows, columns,
x_wrapping, y_wrapping, x_wrapping, y_wrapping,
seed = seed seed = seed
); );
// try four directions // 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? // all done?
i < len(dirs) ? i < len(dirs) ?
// not yet // not yet
walk_around_from(x, y, dirs, walk_around_from(x, y, dirs,
// try one direction // 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, rows, columns,
x_wrapping, y_wrapping, x_wrapping, y_wrapping,
i + 1, i + 1,
seed) 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? // is the dir visitable?
visitable(next_x(x, dir, columns, x_wrapping), next_y(y, dir, rows, y_wrapping), maze, rows, columns) ? visitable(next_x(x, dir, columns, x_wrapping), next_y(y, dir, rows, y_wrapping), cells, rows, columns) ?
// try the block // try the cell
go_maze( go_maze(
next_x(x, dir, columns, x_wrapping), next_y(y, dir, rows, y_wrapping), 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, rows, columns,
x_wrapping, y_wrapping, x_wrapping, y_wrapping,
seed seed
) )
// road closed so return maze directly // road closed so return cells directly
: maze; : cells;

View File

@@ -4,12 +4,12 @@
// TOP_RIGHT_WALL = 3; // TOP_RIGHT_WALL = 3;
// MASK = 4; // MASK = 4;
function no_wall(block) = get_wall_type(block) == 0; function no_wall(cell) = get_wall_type(cell) == 0;
function top_wall(block) = get_wall_type(block) == 1; function top_wall(cell) = get_wall_type(cell) == 1;
function right_wall(block) = get_wall_type(block) == 2; function right_wall(cell) = get_wall_type(cell) == 2;
function top_right_wall(block) = get_wall_type(block) == 3; function top_right_wall(cell) = get_wall_type(cell) == 3;
function block(x, y, wall_type, visited) = [x, y, wall_type, visited]; function cell(x, y, wall_type, visited) = [x, y, wall_type, visited];
function get_x(block) = block[0]; function get_x(cell) = cell[0];
function get_y(block) = block[1]; function get_y(cell) = cell[1];
function get_wall_type(block) = block[2]; function get_wall_type(cell) = cell[2];

View File

@@ -1,12 +1,12 @@
use <../mz_square_get.scad>; use <../mz_square_get.scad>;
function _get_x(block) = mz_square_get(block, "x"); function _get_x(cell) = mz_square_get(cell, "x");
function _get_y(block) = mz_square_get(block, "y"); function _get_y(cell) = mz_square_get(cell, "y");
function _get_wall_type(block) = mz_square_get(block, "w"); function _get_wall_type(cell) = mz_square_get(cell, "w");
function _is_top_wall(block) = _get_wall_type(block) == "TOP_WALL"; function _is_top_wall(cell) = _get_wall_type(cell) == "TOP_WALL";
function _is_right_wall(block) = _get_wall_type(block) == "RIGHT_WALL"; function _is_right_wall(cell) = _get_wall_type(cell) == "RIGHT_WALL";
function _is_top_right_wall(block) = _get_wall_type(block) == "TOP_RIGHT_WALL"; function _is_top_right_wall(cell) = _get_wall_type(cell) == "TOP_RIGHT_WALL";
function _cell_position(cell_radius, x_cell, y_cell) = function _cell_position(cell_radius, x_cell, y_cell) =
let( let(
@@ -31,14 +31,14 @@ function _right_wall(cell_radius, x_cell) =
function _row_wall(cell_radius, x_cell, y_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)]; 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( let(
x = _get_x(block), x = _get_x(cell),
y = _get_y(block), y = _get_y(cell),
walls = concat( walls = concat(
_row_wall(cell_radius, x, y), _row_wall(cell_radius, x, y),
[_is_top_wall(block) || _is_top_right_wall(block) ? _top(cell_radius) : []], [_is_top_wall(cell) || _is_top_right_wall(cell) ? _top(cell_radius) : []],
[_is_right_wall(block) || _is_top_right_wall(block) ? _right_wall(cell_radius, x) : []] [_is_right_wall(cell) || _is_top_right_wall(cell) ? _right_wall(cell_radius, x) : []]
) )
) )
[ [

View File

@@ -4,9 +4,9 @@ use <_mz_comm.scad>;
function _rc_maze(rows, columns) = [ function _rc_maze(rows, columns) = [
for(y = [0:rows - 1]) for(y = [0:rows - 1])
for(x = [0:columns - 1]) for(x = [0:columns - 1])
block( cell(
x, y, x, y,
// all blocks have top and right walls // all cells have top and right walls
3, 3,
// unvisited // unvisited
false false
@@ -22,15 +22,15 @@ function _mz_mask(mask) =
for(y = [0:rows - 1]) for(y = [0:rows - 1])
for(x = [0:columns - 1]) for(x = [0:columns - 1])
mask[rows - y - 1][x] == 0 ? mask[rows - y - 1][x] == 0 ?
block( cell(
x, y, x, y,
4, // mask 4, // mask
true // visited true // visited
) )
: :
block( cell(
x, y, x, y,
// all blocks have top and right walls // all cells have top and right walls
3, // unvisited 3, // unvisited
false false
) )

View File

@@ -1,9 +1,9 @@
use <_mz_comm.scad>; use <_mz_comm.scad>;
function _square_walls(block, block_width) = function _square_walls(cell, cell_width) =
let( let(
loc = [get_x(block), get_y(block)] * block_width, loc = [get_x(cell), get_y(cell)] * cell_width,
top = top_wall(block) || top_right_wall(block) ? [[0, block_width] + loc, [block_width, block_width] + loc] : [], top = top_wall(cell) || top_right_wall(cell) ? [[0, cell_width] + loc, [cell_width, cell_width] + loc] : [],
right = right_wall(block) || top_right_wall(block) ? [[block_width, block_width] + loc, [block_width, 0] + loc] : [] right = right_wall(cell) || top_right_wall(cell) ? [[cell_width, cell_width] + loc, [cell_width, 0] + loc] : []
) )
concat(top, right); concat(top, right);

View File

@@ -1,22 +1,22 @@
use <_impl/_mz_hamiltonian_impl.scad>; use <_impl/_mz_hamiltonian_impl.scad>;
use <mz_square_blocks.scad>; use <mz_square_cells.scad>;
use <mz_square_get.scad>; use <mz_square_get.scad>;
use <../util/sort.scad>; use <../util/sort.scad>;
use <../util/dedup.scad>; use <../util/dedup.scad>;
function mz_hamiltonian(rows, columns, start, seed) = function mz_hamiltonian(rows, columns, start, seed) =
let( let(
blocks = mz_square_blocks( cells = mz_square_cells(
rows, columns, rows, columns,
seed = seed seed = seed
), ),
all = concat( all = concat(
[ [
for(block = blocks) for(cell = cells)
let( let(
x = mz_square_get(block, "x"), x = mz_square_get(cell, "x"),
y = mz_square_get(block, "y"), y = mz_square_get(cell, "y"),
wall_type = mz_square_get(block, "w"), wall_type = mz_square_get(cell, "w"),
pts = wall_type == "TOP_WALL" ? _mz_hamiltonian_top(x, y) : pts = wall_type == "TOP_WALL" ? _mz_hamiltonian_top(x, y) :
wall_type == "RIGHT_WALL" ? _mz_hamiltonian_right(x, y) : wall_type == "RIGHT_WALL" ? _mz_hamiltonian_right(x, y) :
wall_type == "TOP_RIGHT_WALL" ? _mz_hamiltonian_top_right(x, y) : [] wall_type == "TOP_RIGHT_WALL" ? _mz_hamiltonian_top_right(x, y) : []

View File

@@ -1,10 +1,10 @@
use <_impl/_mz_hex_walls.scad>; 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( let(
walls = [ walls = [
for(block = blocks) for(cell = cells)
for(wall = _build_cell(cell_radius, block)) for(wall = _build_cell(cell_radius, cell))
wall wall
], ],
left_pair_walls = left_border ? [ left_pair_walls = left_border ? [

View File

@@ -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
);

View 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
);

View File

@@ -1,4 +1,4 @@
function mz_square_get(block, query) = function mz_square_get(cell, query) =
let( let(
i = search(query, [ i = search(query, [
["x", 0], ["x", 0],
@@ -6,4 +6,4 @@ function mz_square_get(block, query) =
["w", 2] ["w", 2]
])[0] ])[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]];

View File

@@ -1,14 +1,14 @@
use <_impl/_mz_square_walls_impl.scad>; 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( let(
left_walls = left_border ? [for(y = [0:rows - 1]) [[0, block_width * (y + 1)], [0, block_width * y]]] : [], 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]) [[block_width * x, 0], [block_width * (x + 1), 0]]] : [] buttom_walls = bottom_border ? [for(x = [0:columns - 1]) [[cell_width * x, 0], [cell_width * (x + 1), 0]]] : []
) )
concat( concat(
[ [
for(block = blocks) for(cell = cells)
let(pts = _square_walls(block, block_width)) let(pts = _square_walls(cell, cell_width))
if(pts != []) pts if(pts != []) pts
] ]
, left_walls, buttom_walls , left_walls, buttom_walls