chaos_polygon: Chaos Polygon

Description Usage Arguments References Examples

View source: R/chaos_game.R

Description

Start with the vertices of a regular polygon. Randomly place a tracepoint at one of them. Each step of the iteration choose a random vertex and move the tracepoint some distance towards that.

Usage

1
chaos_polygon(vertices = 3, proportion = 0.5, iterations = 10000)

Arguments

vertices

The number of vertices.

proportion

The proportion of the distance to move from the point to the target vertex.

iterations

The number of iterations.

References

The Numberphile video featuring Ben Sparks and Brady Haran: Chaos Game.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
p <- list(
    chaos_polygon(),
    chaos_polygon(4, 0.55),
    chaos_polygon(5, 0.62),
    chaos_polygon(6, 2/3),
    chaos_polygon(30, 0.91),
    chaos_polygon(proportion = 1.5)
)
par(mfrow = c(2, 3), mar = rep(0, 4))
for (xy in p) {
    plot(xy, pch = 20, axes = FALSE, ann = FALSE, asp = 1, cex = 0.25)
}

BastiHz/numberphile documentation built on Oct. 12, 2020, 6:03 p.m.