1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-09 08:16:50 +02:00
This commit is contained in:
Justin Lin
2022-03-15 21:45:11 +08:00
parent f5e403bbf0
commit cb0e361671
2 changed files with 22 additions and 31 deletions

View File

@@ -11,40 +11,33 @@
use <_impl/_mz_hex_walls.scad>; use <_impl/_mz_hex_walls.scad>;
function mz_hex_walls(cells, rows, columns, cell_radius, left_border = true, bottom_border = true) = function mz_hex_walls(cells, rows, columns, cell_radius, left_border = true, bottom_border = true) =
let( [
walls = [for(cell = cells, wall = _build_cell(cell_radius, cell)) wall], each [for(cell = cells, wall = _build_cell(cell_radius, cell)) wall],
left_pair_walls = left_border ? [
if(left_border) each [
for(y = [0:rows - 1]) for(y = [0:rows - 1])
let( let(
cell_p = _cell_position(cell_radius, 0, y), cell_p = _cell_position(cell_radius, 0, y),
walls1 = _top_left(cell_radius), walls1 = _top_left(cell_radius),
walls2 = _bottom_left(cell_radius) walls2 = _bottom_left(cell_radius)
) )
[ each [
[walls1[0] + cell_p, walls1[1] + cell_p], [walls1[0] + cell_p, walls1[1] + cell_p],
[walls2[0] + cell_p, walls2[1] + cell_p] [walls2[0] + cell_p, walls2[1] + cell_p]
] ]
] : [], ],
left_border_walls = [for(pair = left_pair_walls) each pair],
bottom_pair_walls = bottom_border ? [ if(bottom_border) each [
for(x = [0:columns - 1]) for(x = [0:columns - 1])
let( let(
cell_p = _cell_position(cell_radius, x, 0), cell_p = _cell_position(cell_radius, x, 0),
walls1 = _bottom(cell_radius), walls1 = _bottom(cell_radius)
walls2 = [
for(pair = (x % 2 == 0 ? [_bottom_left(cell_radius), _bottom_right(cell_radius)] : []))
each pair
]
) )
walls2 == [] ? each [
[ [walls1[0] + cell_p, walls1[1] + cell_p],
[walls1[0] + cell_p, walls1[1] + cell_p] if(x % 2 == 0)
] : let(walls2 = [each _bottom_left(cell_radius), each _bottom_right(cell_radius)])
[ [walls2[0] + cell_p, walls2[1] + cell_p]
[walls1[0] + cell_p, walls1[1] + cell_p], ]
[walls2[0] + cell_p, walls2[1] + cell_p] ]
] ];
] : [],
bottom_border_walls = [for(pair = bottom_pair_walls) each pair]
)
concat(walls, left_border_walls, bottom_border_walls);

View File

@@ -18,11 +18,9 @@ function mz_square_walls(cells, rows, columns, cell_width, left_border = true, b
concat( concat(
[ [
for(cell = cells) for(cell = cells)
let( let(wall_pts = _square_walls(cell, cell_width))
wall_pts = _square_walls(cell, cell_width), if(wall_pts != [])
pts = len(wall_pts) == 4 ? [wall_pts[0], wall_pts[1], wall_pts[3]]: wall_pts len(wall_pts) == 4 ? [wall_pts[0], wall_pts[1], wall_pts[3]]: wall_pts
)
if(pts != []) pts
] ]
, left_walls, buttom_walls , left_walls, buttom_walls
); );