Sierpinski's gasket

Chapter: Sierpinski's gasket

Are we detecting a pattern here?

Q. 1
What is a Sierpinski Gasket?


Did you notice how, in order to define a Siepinski Gasket I needed to refer to smaller Sierpinski gaskets? That is an example of a recursive definition. The idea is to define something in terms of itself.

Q. 2
Isn't that defeating the purpose of a definition?


Artists have often used recursion. See if you can describe the picture below (by the Dutch artist Maurits Escher) without using recursion.

And recursion has been used commercially too:

Now it's back to Sierpinksi. Waclaw Sierpinski (1882 - 1969) worked in set theory, topology and number theory. At the time of his birth in Warsaw it was part of the Russian Empire. By the time of his death Warsaw was in Poland. This does not imply that Warsaw is anything but a fixed point on the map. (I apologize for this obscure mathematical joke. If you google and read some about Sierpinski's gasket, you may possibly find it amusing!) For Sierpinski, the gasket is infinitely subdivided.

For us, who are limited by pixel size, the Sierpinski gasket stops recursing at some point and devolves into a simple triangle. With very poor resolution, this could happen immediately, and our degenerate gasket would just be

With only slightly better resolution, we might make one recursive level:

As resolution improves, we might make it to three recursive levels:

And so on. It is important to realize, however, that we are not seeing the whole perfect fractal. But it's pretty.


Exercise 4

Write code to draw the gasket. The constructor will be recursive. The base case, or stopping condition, will occur when the size is less than some constant MINSIZE. The smaller your setting of MINSIZE, the greater will be the degree of detail of your gasket. It's not a good idea to make MINSIZE much less than 6 or so. Try it to see why. Two skeleton classes Sierpinksi and GasketTriangle are provided for you in the starter project.


rhyspj@gwu.edu