koch {alphahull} | R Documentation |
This function uses recursion to construct a Kock snowflake curve.
koch(side = 3, niter = 5)
side |
Side length of the initial equilateral triangle. |
niter |
Number of iterations in the development of the snowflake curve. |
The Koch snowflake is a fractal curve described by the Swedish mathematician Helge von Koch in 1904. It is built by starting with an equilateral triangle, removing the inner third of each side, building another equilateral triangle at the location where the side was removed, and then repeating the process.
vertices |
A 2-column matrix with the coordinates of the snowflake vertices. |
von Koch, H. (1904). Sur une courbe continue sans tangente, obtenue par une construction geometrique elementaire. Arkiv for Matematik, 1, pp.681-704.
## Not run: # The first four iterations of a Koch snowflake # with side length of the initial equilateral triangle equal to 3. vertices <- koch(side = 2, niter = 4) plot(vertices[, 1], vertices[, 2], type = "l", asp = TRUE, main = "Koch snowflake", xlab = "", ylab = "", col = 4) polygon(vertices[, 1], vertices[, 2] , col = 4) ## End(Not run)