2022-03-27 12:24:34 +08:00
|
|
|
use <maze/mz_theta.scad>;
|
2021-02-28 10:34:56 +08:00
|
|
|
use <maze/mz_theta_get.scad>;
|
2021-10-08 09:36:01 +08:00
|
|
|
use <polyline_join.scad>;
|
2021-02-28 10:34:56 +08:00
|
|
|
|
2022-03-27 12:24:34 +08:00
|
|
|
rings = 5;
|
2021-03-07 21:03:48 +08:00
|
|
|
beginning_number = 8;
|
2021-02-28 10:34:56 +08:00
|
|
|
cell_width = 10;
|
|
|
|
wall_thickness = 2;
|
|
|
|
wall_height = 5;
|
|
|
|
|
2022-03-27 12:24:34 +08:00
|
|
|
theta_maze(rings, beginning_number, cell_width, wall_thickness, wall_height);
|
2021-02-28 10:34:56 +08:00
|
|
|
|
2022-03-27 12:24:34 +08:00
|
|
|
module theta_maze(rings, beginning_number, cell_width, wall_thickness, wall_height) {
|
2021-02-28 10:34:56 +08:00
|
|
|
|
|
|
|
function vt_from_angle(theta, r) = [r * cos(theta), r * sin(theta)];
|
|
|
|
|
2022-03-27 12:24:34 +08:00
|
|
|
maze = mz_theta(rings, beginning_number);
|
2021-02-28 10:34:56 +08:00
|
|
|
|
2021-10-08 09:36:01 +08:00
|
|
|
half_wall_thickness = wall_thickness / 2;
|
2021-02-28 10:34:56 +08:00
|
|
|
linear_extrude(wall_height) {
|
2022-04-03 14:16:17 +08:00
|
|
|
for(rings = maze, cell = rings) {
|
|
|
|
ri = mz_theta_get(cell, "r");
|
|
|
|
ci = mz_theta_get(cell, "c");
|
|
|
|
wallType = mz_theta_get(cell, "t");
|
|
|
|
thetaStep = 360 / len(maze[ri]);
|
|
|
|
innerR = (ri + 1) * cell_width;
|
|
|
|
outerR = (ri + 2) * cell_width;
|
|
|
|
theta1 = thetaStep * ci;
|
|
|
|
theta2 = thetaStep * (ci + 1);
|
|
|
|
|
|
|
|
innerVt1 = vt_from_angle(theta1, innerR);
|
|
|
|
innerVt2 = vt_from_angle(theta2, innerR);
|
|
|
|
outerVt2 = vt_from_angle(theta2, outerR);
|
|
|
|
|
|
|
|
if(wallType == "INWARD_WALL" || wallType == "INWARD_CCW_WALL") {
|
|
|
|
polyline_join([innerVt1, innerVt2])
|
|
|
|
circle(half_wall_thickness);
|
|
|
|
}
|
2021-02-28 10:34:56 +08:00
|
|
|
|
2022-04-03 14:16:17 +08:00
|
|
|
if(wallType == "CCW_WALL" || wallType == "INWARD_CCW_WALL") {
|
|
|
|
polyline_join([innerVt2, outerVt2])
|
|
|
|
circle(half_wall_thickness);
|
|
|
|
}
|
2021-02-28 10:34:56 +08:00
|
|
|
}
|
|
|
|
|
2022-03-27 12:24:34 +08:00
|
|
|
thetaStep = 360 / len(maze[rings - 1]);
|
|
|
|
r = cell_width * (rings + 1);
|
2021-02-28 10:34:56 +08:00
|
|
|
for(theta = [0:thetaStep:360 - thetaStep]) {
|
|
|
|
vt1 = vt_from_angle(theta, r);
|
|
|
|
vt2 = vt_from_angle(theta + thetaStep, r);
|
2021-10-08 09:36:01 +08:00
|
|
|
polyline_join([vt1, vt2])
|
|
|
|
circle(half_wall_thickness);
|
2021-02-28 10:34:56 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|