mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-11 17:24:20 +02:00
refactor
This commit is contained in:
@@ -232,3 +232,47 @@ module build_square_maze(rows, columns, blocks, block_width, wall_thickness, lef
|
|||||||
line2d([0, 0], [block_width * columns, 0], wall_thickness);
|
line2d([0, 0], [block_width * columns, 0], wall_thickness);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function block_walls(block, block_width) =
|
||||||
|
let(
|
||||||
|
loc = [get_x(block) - 1, get_y(block) - 1] * block_width,
|
||||||
|
wall_type = get_wall_type(block),
|
||||||
|
upper_wall = wall_type == UPPER_WALL || wall_type == UPPER_RIGHT_WALL ? [[0, block_width] + loc, [block_width, block_width] + loc] : [],
|
||||||
|
right_wall = wall_type == RIGHT_WALL || wall_type == UPPER_RIGHT_WALL ? [[block_width, block_width] + loc, [block_width, 0] + loc] : []
|
||||||
|
)
|
||||||
|
concat(
|
||||||
|
upper_wall,
|
||||||
|
right_wall
|
||||||
|
);
|
||||||
|
|
||||||
|
function maze_walls(blocks, rows, columns, block_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]]] : []
|
||||||
|
)
|
||||||
|
concat(
|
||||||
|
[
|
||||||
|
for(block = blocks)
|
||||||
|
let(pts = block_walls(block, block_width))
|
||||||
|
if(pts != []) pts
|
||||||
|
]
|
||||||
|
, left_walls, buttom_walls
|
||||||
|
);
|
||||||
|
|
||||||
|
function y_twist(walls, angle, rows, columns, block_width) =
|
||||||
|
let(
|
||||||
|
x_offset = columns * block_width / 2,
|
||||||
|
x_centered = [
|
||||||
|
for(wall_pts = walls)
|
||||||
|
[for(pt = wall_pts) [pt[0], pt[1], 0] + [-x_offset, 0, 0]]
|
||||||
|
],
|
||||||
|
a_step = angle / rows
|
||||||
|
)
|
||||||
|
[
|
||||||
|
for(wall_pts = x_centered)
|
||||||
|
[
|
||||||
|
for(pt = wall_pts)
|
||||||
|
rotate_p(pt, [0, pt[1] * a_step, 0]) + [x_offset, 0, 0]
|
||||||
|
]
|
||||||
|
];
|
@@ -9,49 +9,6 @@ wall_thickness = 1;
|
|||||||
angle = 90;
|
angle = 90;
|
||||||
// $fn = 24;
|
// $fn = 24;
|
||||||
|
|
||||||
function block_walls(block, block_width) =
|
|
||||||
let(
|
|
||||||
loc = [get_x(block) - 1, get_y(block) - 1] * block_width,
|
|
||||||
wall_type = get_wall_type(block),
|
|
||||||
upper_wall = wall_type == UPPER_WALL || wall_type == UPPER_RIGHT_WALL ? [[0, block_width] + loc, [block_width, block_width] + loc] : [],
|
|
||||||
right_wall = wall_type == RIGHT_WALL || wall_type == UPPER_RIGHT_WALL ? [[block_width, block_width] + loc, [block_width, 0] + loc] : []
|
|
||||||
)
|
|
||||||
concat(
|
|
||||||
upper_wall,
|
|
||||||
right_wall
|
|
||||||
);
|
|
||||||
|
|
||||||
function maze_walls(blocks, rows, columns, block_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]]] : []
|
|
||||||
)
|
|
||||||
concat(
|
|
||||||
[
|
|
||||||
for(block = blocks)
|
|
||||||
let(pts = block_walls(block, block_width))
|
|
||||||
if(pts != []) pts
|
|
||||||
]
|
|
||||||
, left_walls, buttom_walls
|
|
||||||
);
|
|
||||||
|
|
||||||
function y_twist(walls, angle, rows, columns, block_width) =
|
|
||||||
let(
|
|
||||||
x_offset = columns * block_width / 2,
|
|
||||||
x_centered = [
|
|
||||||
for(wall_pts = walls)
|
|
||||||
[for(pt = wall_pts) [pt[0], pt[1], 0] + [-x_offset, 0, 0]]
|
|
||||||
],
|
|
||||||
a_step = angle / rows
|
|
||||||
)
|
|
||||||
[
|
|
||||||
for(wall_pts = x_centered)
|
|
||||||
[
|
|
||||||
for(pt = wall_pts)
|
|
||||||
rotate_p(pt, [0, pt[1] * a_step, 0]) + [x_offset, 0, 0]
|
|
||||||
]
|
|
||||||
];
|
|
||||||
|
|
||||||
blocks = go_maze(
|
blocks = go_maze(
|
||||||
1, 1, // starting point
|
1, 1, // starting point
|
||||||
starting_maze(rows, columns),
|
starting_maze(rows, columns),
|
||||||
|
Reference in New Issue
Block a user