*** Welcome to piglix ***

Sierpinski carpet


The Sierpinski carpet is a plane fractal first described by Wacław Sierpiński in 1916. The carpet is one generalization of the Cantor set to two dimensions; another is the Cantor dust.

The technique of subdividing a shape into smaller copies of itself, removing one or more copies, and continuing recursively can be extended to other shapes. For instance, subdividing an equilateral triangle into four equilateral triangles, removing the middle triangle, and recursing leads to the Sierpinski triangle. In three dimensions, a similar construction based on cubes produces the Sierpinski sponge and the Menger sponge.

The construction of the Sierpinski carpet begins with a square. The square is cut into 9 congruent subsquares in a 3-by-3 grid, and the central subsquare is removed. The same procedure is then applied recursively to the remaining 8 subsquares, ad infinitum. It can be realised as the set of points in the unit square whose coordinates written in base three do not both have a digit '1' in the same position.

The process of recursively removing squares is an example of a finite subdivision rule.

The Sierpinski carpet can also be created by iterating every pixel in a square and using the following algorithm to decide if the pixel is filled. The following implementation is valid C, C++, and Java.

Menger 0.PNG Menger 1.PNG Menger 2.PNG Menger 3.PNG Menger 4.PNG Menger 5.PNG


...
Wikipedia

...