sierpinski: Sierpinski carpet

View source: R/fractals.R

sierpinskiR Documentation

Sierpinski carpet

Description

Returns a matrix of 0s and 1s that form a Sierpinski carpet. This is a two dimensional fractal, which is generated using a recursive algorithm that is built on a grid of eight black squares surrounding a white square. Each level of recursion replaces each black square by the same pattern.

Usage

sierpinski(n = 5)

Arguments

n

an integer value controling the number of recursive levels.

Value

a square matrix with 0s and 1s.

Examples

g <- sierpinski(n=5)
image(g,col=c('white','black'),axes=FALSE,asp=1)

geostats documentation built on Jan. 7, 2023, 5:32 p.m.