1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-12 09:44:16 +02:00
This commit is contained in:
Justin Lin
2022-04-03 14:16:17 +08:00
parent fb4a626707
commit 8ce96f9128
5 changed files with 66 additions and 75 deletions

View File

@@ -18,17 +18,15 @@ module noisy_circle_maze(r_cells, cell_width, wall_thickness, origin_offset, noi
noisy_f = is_undef(noisy_factor) ? 1 : noisy_factor; noisy_f = is_undef(noisy_factor) ? 1 : noisy_factor;
half_wall_thickness = wall_thickness / 2; half_wall_thickness = wall_thickness / 2;
seed = rand(0, 256); seed = rand(0, 256);
for(wall = walls) { for(wall = walls, i = [0:len(wall) - 2]) {
for(i = [0:len(wall) - 2]) { p0 = ptf_circle(rect_size, wall[i]);
p0 = ptf_circle(rect_size, wall[i]); p1 = ptf_circle(rect_size, wall[i + 1]);
p1 = ptf_circle(rect_size, wall[i + 1]); pn00 = nz_perlin2(p0[0], p0[1], seed) * noisy_f;
pn00 = nz_perlin2(p0[0], p0[1], seed) * noisy_f; pn01 = nz_perlin2(p0[0] + seed, p0[1] + seed, seed) * noisy_f;
pn01 = nz_perlin2(p0[0] + seed, p0[1] + seed, seed) * noisy_f; pn10 = nz_perlin2(p1[0], p1[1], seed) * noisy_f;
pn10 = nz_perlin2(p1[0], p1[1], seed) * noisy_f; pn11 = nz_perlin2(p1[0] + seed, p1[1] + seed, seed) * noisy_f;
pn11 = nz_perlin2(p1[0] + seed, p1[1] + seed, seed) * noisy_f; polyline_join([p0 + [pn00, pn01], p1 + [pn10, pn11]])
polyline_join([p0 + [pn00, pn01], p1 + [pn10, pn11]]) circle(half_wall_thickness);
circle(half_wall_thickness);
}
} }
} }

View File

@@ -10,11 +10,9 @@ module pyramid_hex_maze(columns, cell_radius, wall_thickness) {
module bottom(rows, columns, cell_radius, wall_thickness) { module bottom(rows, columns, cell_radius, wall_thickness) {
grid_h = 2 * cell_radius * sin(60); grid_h = 2 * cell_radius * sin(60);
grid_w = cell_radius + cell_radius * cos(60); grid_w = cell_radius + cell_radius * cos(60);
for(x_cell = [0:columns - 1]) { for(x_cell = [0:columns - 1], (y_cell = [0:rows - 1]) {
for(y_cell = [0:rows - 1]) { translate([grid_w * x_cell, grid_h * y_cell + (x_cell % 2 == 0 ? 0 : grid_h / 2), 0])
translate([grid_w * x_cell, grid_h * y_cell + (x_cell % 2 == 0 ? 0 : grid_h / 2), 0]) circle(cell_radius + wall_thickness, $fn = 6);
circle(cell_radius + wall_thickness, $fn = 6);
}
} }
} }
@@ -35,17 +33,17 @@ module pyramid_hex_maze(columns, cell_radius, wall_thickness) {
intersection() { intersection() {
linear_extrude(pyramid_height) linear_extrude(pyramid_height)
for(wall = walls) { for(wall = walls) {
polyline2d( polyline2d(
wall, wall,
wall_thickness, wall_thickness,
startingStyle = "CAP_ROUND", endingStyle = "CAP_ROUND" startingStyle = "CAP_ROUND", endingStyle = "CAP_ROUND"
); );
} }
translate([square_offset_x, square_offset_y, 0]) translate([square_offset_x, square_offset_y, 0])
linear_extrude(pyramid_height, scale = 0) linear_extrude(pyramid_height, scale = 0)
square([square_w, square_h], center = true); square([square_w, square_h], center = true);
} }
linear_extrude(wall_thickness) linear_extrude(wall_thickness)

View File

@@ -52,7 +52,7 @@ module regular_polygon_maze(radius, ccells, levels, thickness = 1, sides) {
cells = mz_square(ccells, levels, y_wrapping = true); cells = mz_square(ccells, levels, y_wrapping = true);
difference() { difference() {
render() union() { union() {
for(i = [1 : levels + 1]) { for(i = [1 : levels + 1]) {
ring_regular_polygon(r * i, thickness, sides); ring_regular_polygon(r * i, thickness, sides);
} }
@@ -70,7 +70,7 @@ module regular_polygon_maze(radius, ccells, levels, thickness = 1, sides) {
} }
} }
render() union() { union() {
// maze entry // maze entry
// ring_regular_polygon_sector(r, arc_angle / 1.975 , thickness, r / 3, sides); // ring_regular_polygon_sector(r, arc_angle / 1.975 , thickness, r / 3, sides);

View File

@@ -44,32 +44,29 @@ module rock_theta_maze(rings, begining_columns, cell_width, rock_size, height_sc
scale([1, 1, height_scale]) scale([1, 1, height_scale])
difference() { difference() {
union() { union() {
for(rings = maze) { for(rings = maze, cell = rings) {
for(cell = rings) { ri = mz_theta_get(cell, "r");
ci = mz_theta_get(cell, "c");
if([ri, ci] != [0, 0]) {
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);
ri = mz_theta_get(cell, "r"); innerVt1 = vt_from_angle(theta1, innerR);
ci = mz_theta_get(cell, "c"); innerVt2 = vt_from_angle(theta2, innerR);
if([ri, ci] != [0, 0]) { outerVt2 = vt_from_angle(theta2, outerR);
wallType = mz_theta_get(cell, "t");
thetaStep = 360 / len(maze[ri]); if(wallType == "INWARD_WALL" || wallType == "INWARD_CCW_WALL") {
innerR = (ri + 1) * cell_width; rock_wall(innerVt1, innerVt2, rock_size);
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") {
rock_wall(innerVt1, innerVt2, rock_size);
}
if(wallType == "CCW_WALL" || wallType == "INWARD_CCW_WALL") {
rock_wall(innerVt2, outerVt2, rock_size);
}
} }
}
if(wallType == "CCW_WALL" || wallType == "INWARD_CCW_WALL") {
rock_wall(innerVt2, outerVt2, rock_size);
}
}
} }
thetaStep = 360 / len(maze[rings - 1]); thetaStep = 360 / len(maze[rings - 1]);

View File

@@ -18,31 +18,29 @@ module theta_maze(rings, beginning_number, cell_width, wall_thickness, wall_heig
half_wall_thickness = wall_thickness / 2; half_wall_thickness = wall_thickness / 2;
linear_extrude(wall_height) { linear_extrude(wall_height) {
for(rings = maze) { for(rings = maze, cell = rings) {
for(cell = rings) { ri = mz_theta_get(cell, "r");
ri = mz_theta_get(cell, "r"); ci = mz_theta_get(cell, "c");
ci = mz_theta_get(cell, "c"); wallType = mz_theta_get(cell, "t");
wallType = mz_theta_get(cell, "t"); thetaStep = 360 / len(maze[ri]);
thetaStep = 360 / len(maze[ri]); innerR = (ri + 1) * cell_width;
innerR = (ri + 1) * cell_width; outerR = (ri + 2) * cell_width;
outerR = (ri + 2) * cell_width; theta1 = thetaStep * ci;
theta1 = thetaStep * ci; theta2 = thetaStep * (ci + 1);
theta2 = thetaStep * (ci + 1);
innerVt1 = vt_from_angle(theta1, innerR);
innerVt1 = vt_from_angle(theta1, innerR); innerVt2 = vt_from_angle(theta2, innerR);
innerVt2 = vt_from_angle(theta2, innerR); outerVt2 = vt_from_angle(theta2, outerR);
outerVt2 = vt_from_angle(theta2, outerR);
if(wallType == "INWARD_WALL" || wallType == "INWARD_CCW_WALL") {
if(wallType == "INWARD_WALL" || wallType == "INWARD_CCW_WALL") { polyline_join([innerVt1, innerVt2])
polyline_join([innerVt1, innerVt2]) circle(half_wall_thickness);
circle(half_wall_thickness); }
}
if(wallType == "CCW_WALL" || wallType == "INWARD_CCW_WALL") { if(wallType == "CCW_WALL" || wallType == "INWARD_CCW_WALL") {
polyline_join([innerVt2, outerVt2]) polyline_join([innerVt2, outerVt2])
circle(half_wall_thickness); circle(half_wall_thickness);
} }
}
} }
thetaStep = 360 / len(maze[rings - 1]); thetaStep = 360 / len(maze[rings - 1]);