1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-01-18 06:38:14 +01:00
dotSCAD/examples/maze/twisted_maze.scad
2019-09-09 09:30:25 +08:00

38 lines
963 B
OpenSCAD

include <hull_polyline3d.scad>;
include <rotate_p.scad>;
include <square_maze.scad>;
rows = 16;
columns = 8;
block_width = 4;
wall_thickness = 1;
angle = 180;
// $fn = 24;
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 * block_width)
)
[
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(
1, 1, // starting point
starting_maze(rows, columns),
rows, columns
);
walls = maze_walls(blocks, rows, columns, block_width);
for(wall_pts = y_twist(walls, angle, rows, columns, block_width)) {
hull_polyline3d(wall_pts, wall_thickness);
}