1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-02-24 01:22:27 +01:00
dotSCAD/examples/maze/random_scala.scad

27 lines
661 B
OpenSCAD
Raw Normal View History

2020-03-05 08:44:35 +08:00
use <experimental/mz_hamiltonian.scad>;
2020-03-04 10:16:27 +08:00
2020-03-05 09:24:04 +08:00
module random_scala(rows, columns, start, width, height) {
line = mz_hamiltonian(rows, columns, start);
2020-03-05 08:45:39 +08:00
leng = len(line);
2020-03-04 10:16:27 +08:00
2020-03-05 08:45:39 +08:00
for(i = [0:leng - 1]) {
2020-03-05 08:44:35 +08:00
p1 = line[i];
translate(p1)
2020-03-04 10:16:27 +08:00
linear_extrude(height * i * 2 + height)
square(width + 0.01, center = true);
2020-03-05 08:45:39 +08:00
p2 = line[(i + 1) % leng];
2020-03-05 08:44:35 +08:00
translate(p1 + (p2 - p1) / 2)
2020-03-04 10:16:27 +08:00
linear_extrude(height * (2 * i + 1) + height)
square(width + 0.01, center = true);
}
}
random_scala(
rows = 2,
2020-03-05 09:24:04 +08:00
columns = 3,
start = [0, 0],
2020-03-04 10:16:27 +08:00
width = .5,
height = .25
);