From 9fe199404922c3cbcf3438b9498c7bee5c0513d6 Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Mon, 9 Sep 2019 09:30:25 +0800 Subject: [PATCH] refactor --- examples/maze/mobius_maze.scad | 1 + examples/maze/square_maze.scad | 17 ----------------- examples/maze/twisted_maze.scad | 18 +++++++++++++++++- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/examples/maze/mobius_maze.scad b/examples/maze/mobius_maze.scad index a72f0ebb..07599e8c 100644 --- a/examples/maze/mobius_maze.scad +++ b/examples/maze/mobius_maze.scad @@ -1,6 +1,7 @@ include ; include ; include ; +use ; rows = 48; columns = 8; diff --git a/examples/maze/square_maze.scad b/examples/maze/square_maze.scad index e6817538..c1e4e16b 100644 --- a/examples/maze/square_maze.scad +++ b/examples/maze/square_maze.scad @@ -351,22 +351,5 @@ function maze_walls(blocks, rows, columns, block_width, left_border = true, bott ] , left_walls, buttom_walls ); - -function y_twist(walls, angle, rows, columns, block_width) = - let( - x_offset = columns * block_width / 2, - x_centered = [ - for(wall_pts = walls) - [for(pt = wall_pts) [pt[0], pt[1], 0] + [-x_offset, 0, 0]] - ], - a_step = angle / (rows * block_width) - ) - [ - for(wall_pts = x_centered) - [ - for(pt = wall_pts) - rotate_p(pt, [0, pt[1] * a_step, 0]) + [x_offset, 0, 0] - ] - ]; // ========== \ No newline at end of file diff --git a/examples/maze/twisted_maze.scad b/examples/maze/twisted_maze.scad index 9f8a6805..ed8c6641 100644 --- a/examples/maze/twisted_maze.scad +++ b/examples/maze/twisted_maze.scad @@ -9,6 +9,23 @@ wall_thickness = 1; angle = 180; // $fn = 24; +function y_twist(walls, angle, rows, columns, block_width) = + let( + x_offset = columns * block_width / 2, + x_centered = [ + for(wall_pts = walls) + [for(pt = wall_pts) [pt[0], pt[1], 0] + [-x_offset, 0, 0]] + ], + a_step = angle / (rows * block_width) + ) + [ + for(wall_pts = x_centered) + [ + for(pt = wall_pts) + rotate_p(pt, [0, pt[1] * a_step, 0]) + [x_offset, 0, 0] + ] + ]; + blocks = go_maze( 1, 1, // starting point starting_maze(rows, columns), @@ -16,7 +33,6 @@ blocks = go_maze( ); walls = maze_walls(blocks, rows, columns, block_width); - for(wall_pts = y_twist(walls, angle, rows, columns, block_width)) { hull_polyline3d(wall_pts, wall_thickness); } \ No newline at end of file