diff --git a/examples/hex_maze_stereographic_projection.scad b/examples/hex_maze_stereographic_projection.scad index 811c5e58..ec8e613d 100644 --- a/examples/hex_maze_stereographic_projection.scad +++ b/examples/hex_maze_stereographic_projection.scad @@ -1,7 +1,7 @@ include ; include ; include ; -include ; +include ; x_cells = 5; cell_radius = 20; @@ -17,7 +17,7 @@ module hex_maze(y_cells, x_cells, maze_vector, cell_radius, wall_thickness) { module cell(x_cell, y_cell, style) { module upper_wall() { polyline2d( - [for(a = [240:60:300]) + [for(a = [60:60:120]) [cell_radius * cos(a), cell_radius * sin(a)]], wall_thickness, startingStyle = "CAP_ROUND", endingStyle = "CAP_ROUND" @@ -26,7 +26,7 @@ module hex_maze(y_cells, x_cells, maze_vector, cell_radius, wall_thickness) { module down_wall() { polyline2d( - [for(a = [60:60:120]) + [for(a = [240:60:300]) [cell_radius * cos(a), cell_radius * sin(a)]], wall_thickness, startingStyle = "CAP_ROUND", endingStyle = "CAP_ROUND" @@ -34,33 +34,24 @@ module hex_maze(y_cells, x_cells, maze_vector, cell_radius, wall_thickness) { } module up_left_wall() { - polyline2d( - [for(a = [180:60:270]) - [cell_radius * cos(a), cell_radius * sin(a)]], - wall_thickness, - startingStyle = "CAP_ROUND", endingStyle = "CAP_ROUND" - ); - } - - module down_left_wall() { polyline2d( [for(a = [120:60:180]) [cell_radius * cos(a), cell_radius * sin(a)]], wall_thickness, startingStyle = "CAP_ROUND", endingStyle = "CAP_ROUND" - ); + ); } - module up_right_wall() { + module down_left_wall() { polyline2d( - [for(a = [300:60:360]) + [for(a = [180:60:240]) [cell_radius * cos(a), cell_radius * sin(a)]], wall_thickness, startingStyle = "CAP_ROUND", endingStyle = "CAP_ROUND" ); } - module down_right_wall() { + module up_right_wall() { polyline2d( [for(a = [0:60:60]) [cell_radius * cos(a), cell_radius * sin(a)]], @@ -69,42 +60,59 @@ module hex_maze(y_cells, x_cells, maze_vector, cell_radius, wall_thickness) { ); } + module down_right_wall() { + polyline2d( + [for(a = [300:60:360]) + [cell_radius * cos(a), cell_radius * sin(a)]], + wall_thickness, + startingStyle = "CAP_ROUND", endingStyle = "CAP_ROUND" + ); + } + module right_walls() { up_right_wall(); down_right_wall(); } module cell_border_wall() { - if(y_cell == 0 && x_cell % 2 == 0) { - if(x_cell != 0) { - up_left_wall(); - } - up_right_wall(); - } - if(x_cell == 0) { up_left_wall(); down_left_wall(); } - - if(y_cell == (y_cells - 1)) { + + if(x_cell == x_cells - 1 && y_cell == y_cells - 1) { + up_right_wall(); + } + + if(y_cell == 0) { down_wall(); - if(x_cell % 2 != 0) { - down_left_wall(); + if(x_cell % 2 == 0) { + if(x_cell != 0) { + down_left_wall(); + } + down_right_wall(); } - } + } + + if(y_cell == y_cells - 1 && x_cell % 2 != 0) { + up_left_wall(); + } } module cell_inner_wall() { if(style == "upper") { - upper_wall(); - } else if(style == "rights") { - right_walls(); - } else if(style == "right") { - if(x_cell % 2 == 0) { + upper_wall(); + if(x_cell % 2 != 0) { + up_right_wall(); + } + } else if(style == "right") { + right_walls(); + } else { + if(x_cell % 2 == 0) { + down_right_wall(); + } + else { up_right_wall(); - } else { - down_right_wall(); } } } @@ -127,18 +135,16 @@ module hex_maze(y_cells, x_cells, maze_vector, cell_radius, wall_thickness) { cord = maze_vector[i]; x = (cord[0] - 1) ; y = (cord[1] - 1); - v = cord[3]; - + v = cord[2]; + if(v == 1 || v == 3) { cell(x, y, "upper"); - } if(v == 2 || v == 3) { - cell(x, y, "rights"); + cell(x, y, "right"); } - if(v == 0 || v == 1) { - cell(x, y, "right"); - } + + cell(x, y); } } @@ -156,14 +162,15 @@ module hex_maze_stereographic_projection(x_cells, cell_radius, wall_thickness, f pyramid_height = square_w / sqrt(2); // create a maze - maze_vector = go_maze(1, 1, y_cells, x_cells, init_maze(y_cells, x_cells)); + maze_vector = go_maze(1, 1, starting_maze(y_cells, x_cells), y_cells, x_cells); stereographic_extrude(square_w, $fn = fn) translate([grid_w - square_w / 2, grid_h - square_w / 2, 0]) hex_maze(y_cells, x_cells, maze_vector, cell_radius, wall_thickness); if(shadow == "YES") { - color("black") linear_extrude(wall_height) + color("black") + linear_extrude(wall_height) translate([grid_w - square_w / 2, grid_h - square_w / 2, 0]) hex_maze(y_cells, x_cells, maze_vector, cell_radius, wall_thickness); }