koch_maze {mazealls} | R Documentation |
koch_maze .
Description
Recursively draw an Koch snowflake maze. The inner part of the snowflake
maze consists of an equilateral triangle of side length 3^{depth}
pieces of length unit_len
.
Usage
koch_maze(depth, unit_len, clockwise = TRUE, draw_boundary = TRUE,
num_boundary_holes = 2, boundary_lines = TRUE, boundary_holes = NULL,
boundary_hole_color = NULL, boundary_hole_locations = NULL,
boundary_hole_arrows = FALSE, end_side = 1)
Arguments
depth |
the depth of recursion. This controls the side length. Should be an integer. |
unit_len |
the unit length in graph coordinates. This controls the width of the ‘holes’ in the boundary lines and generally controls the spacing of mazes. |
clockwise |
whether to draw clockwise. |
draw_boundary |
a boolean indicating whether a final boundary shall be drawn around the maze. |
num_boundary_holes |
the number of boundary sides which should be
randomly selected to have holes. Note that the |
boundary_lines |
indicates which of the sides of the maze shall have drawn boundary lines. Can be a logical array indicating which sides shall have lines, or a numeric array, giving the index of sides that shall have lines. |
boundary_holes |
an array indicating which of the boundary lines
have holes. If |
boundary_hole_color |
the color of boundary holes. A value of
|
boundary_hole_locations |
the ‘locations’ of the boundary holes
within each boundary segment.
A value of |
boundary_hole_arrows |
a boolean or boolean array indicating whether to draw perpendicular double arrows at the boundary holes, as a visual guide. These can be useful for locating the entry and exit points of a maze. |
end_side |
the number of the side to end on. A value of
1 corresponds to the starting side, while higher numbers
correspond to the drawn side of the figure in the canonical order
(that is, the order induced by the |
Details
Draws a maze in an Koch snowflake, starting from the corner of the
first side. Relies on generation of triangular mazes for the internals.
The triangular part has sides consisting of 3^depth
segments
of length unit_len
.
Value
nothing; the function is called for side effects only, though in the future this might return information about the drawn boundary of the shape.
Author(s)
Steven E. Pav shabbychef@gmail.com
Examples
library(TurtleGraphics)
turtle_init(2000,2000)
turtle_hide()
turtle_up()
set.seed(1234)
turtle_do({
turtle_backward(distance=400)
turtle_left(90)
turtle_forward(650)
turtle_right(90)
turtle_right(30)
koch_maze(depth=3,unit_len=14)
})