1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-09-01 18:54:39 +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,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);