From 38ee800e6afeb71f4cf6271ac881ef9f59206298 Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Tue, 24 Mar 2020 16:16:03 +0800 Subject: [PATCH] add pnoise and rename --- ...ircle_maze.scad => noisy_circle_maze.scad} | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) rename examples/maze/{circle_maze.scad => noisy_circle_maze.scad} (56%) diff --git a/examples/maze/circle_maze.scad b/examples/maze/noisy_circle_maze.scad similarity index 56% rename from examples/maze/circle_maze.scad rename to examples/maze/noisy_circle_maze.scad index f3f71e30..045a89cc 100644 --- a/examples/maze/circle_maze.scad +++ b/examples/maze/noisy_circle_maze.scad @@ -1,9 +1,11 @@ use ; +use ; use ; use ; use ; +use ; -module circle_maze(start, r_blocks, block_width, wall_thickness, origin_offset) { +module noisy_circle_maze(start, r_blocks, block_width, wall_thickness, origin_offset, noisy_factor) { double_r_blocks = r_blocks * 2; blocks = mz_blocks( start, @@ -15,19 +17,25 @@ module circle_maze(start, r_blocks, block_width, wall_thickness, origin_offset) half_width = width / 2; offset = is_undef(origin_offset) ? [-half_width, -half_width] : origin_offset; + + noisy_f = is_undef(noisy_factor) ? 1 : noisy_factor; + seed = rand(0, 256); for(wall = walls) { for(i = [0:len(wall) - 2]) { p0 = ptf_circle(wall[i], offset); p1 = ptf_circle(wall[i + 1], offset); - hull_polyline2d([p0, p1], width = wall_thickness); + pn0 = pnoise2(p0[0], p0[1], seed); + pn1 = pnoise2(p1[0], p1[1], seed); + hull_polyline2d([p0 + [pn0, pn0] * noisy_f, p1 + [pn1, pn1] * noisy_f], width = wall_thickness); } } } -circle_maze( +noisy_circle_maze( start = [1, 1], - r_blocks = 5, - block_width = 2, - wall_thickness = .75 + r_blocks = 7, + block_width = 5, + wall_thickness = 2, + noisy_factor = 2 ); \ No newline at end of file