mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-01-17 22:28:16 +01:00
87 lines
2.2 KiB
OpenSCAD
87 lines
2.2 KiB
OpenSCAD
include <line2d.scad>;
|
|
include <hollow_out.scad>;
|
|
include <square_maze.scad>;
|
|
|
|
// only for creating a small maze
|
|
|
|
radius_of_circle_wrapper = 15;
|
|
wall_thickness = 1;
|
|
wall_height = 1;
|
|
cblocks = 6;
|
|
levels = 3;
|
|
sides = 3;
|
|
|
|
module ring_regular_polygon(radius, thickness, sides) {
|
|
hollow_out(thickness)
|
|
circle(radius + thickness, $fn = sides);
|
|
}
|
|
|
|
module ring_regular_polygon_sector(radius, angle, thickness, width, sides) {
|
|
intersection() {
|
|
ring_regular_polygon(radius - 0.1, thickness + 0.2, sides);
|
|
rotate([0, 0, angle])
|
|
line2d([0, 0], [0, radius * 3 + width], width);
|
|
}
|
|
}
|
|
|
|
module regular_polygon_to_polygon_wall(radius, length, angle, thickness, sides) {
|
|
intersection() {
|
|
difference() {
|
|
circle(radius + length, $fn = sides);
|
|
circle(radius, $fn = sides);
|
|
}
|
|
rotate([0, 0, angle])
|
|
line2d([0, 0], [0, (radius + length) * 2 + thickness], thickness);
|
|
}
|
|
}
|
|
|
|
module regular_polygon_maze(radius, cblocks, levels, thickness = 1, sides) {
|
|
arc_angle = 360 / cblocks;
|
|
r = radius / (levels + 1);
|
|
|
|
maze = go_maze(1, 1,
|
|
starting_maze(cblocks, levels),
|
|
cblocks, levels, y_circular = true
|
|
);
|
|
|
|
difference() {
|
|
render() union() {
|
|
for(i = [1 : levels + 1]) {
|
|
ring_regular_polygon(r * i, thickness, sides);
|
|
}
|
|
|
|
|
|
for(i = [0:len(maze) - 1]) {
|
|
block = maze[i];
|
|
cr = get_x(block);
|
|
cc = get_y(block) - 1;
|
|
|
|
angle = cc * arc_angle;
|
|
|
|
if(upper_wall(block) || upper_right_wall(block)) {
|
|
regular_polygon_to_polygon_wall(r * cr, r, cc * arc_angle , thickness, sides);
|
|
}
|
|
}
|
|
}
|
|
|
|
render() union() {
|
|
// maze entry
|
|
// ring_regular_polygon_sector(r, arc_angle / 1.975 , thickness, r / 3, sides);
|
|
|
|
// road to the next level
|
|
for(i = [0:len(maze) - 1]) {
|
|
block = maze[i];
|
|
cr = get_x(block);
|
|
cc = get_y(block) - 1;
|
|
|
|
if(no_wall(block) || upper_wall(block)) {
|
|
ring_regular_polygon_sector(r * (cr + 1), (cc + 0.5) * arc_angle , thickness, r / 3 , sides);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
linear_extrude(wall_height)
|
|
regular_polygon_maze(radius_of_circle_wrapper, cblocks, levels, wall_thickness, sides);
|