Fractals


Download
the Chaos Game image generator (313KB zipped).

Home

The "Sierpinsky-Barnsley-Pettit-Heathfield" algorithm is modelled on Michael Barnsley's "Chaos Game", which works as follows:

  1. Identify the three corners of a triangle (an equilateral triangle works well).
  2. Pick a corner, at random. Let this be Position A.
  3. Pick either the corner to the left of the most recently picked corner, or the corner to its right, at random. Let this be Position B.
  4. Draw a point halfway between Position A and Position B.
  5. The new point becomes Position A.
  6. If you've had enough, stop. Otherwise, continue from Step 3.

If you follow this algorithm religiously, you'll get an image a bit like this:

Sierpinski Triangle
The Sierpinski Triangle

Steve Pettit and I modified the algorithm by generalising it in as many ways as we thought that we could get away with. (This was all in around 1999. I have discovered, in April 2005, that Vic Wagner pre-empted us by about 10 years, writing a program for the Amiga in 1989 which did basically the same thing that I'm about to show you. Cf Amiga Transactor, Volume 2, Issue 6, Sept 1989.)

The most obvious generalisation was the shape. We redefined Step 1 to read "Identify the n corners of a regular polygon".

Sierpinski Square
The Sierpinski -- Square?

Here we see that a relatively simple rule change results in a significant alteration to the character of the image. The thing I find most fascinating is that the image is fractal in two dimensions simultaneously. We could look at the image as being composed of four right-angled triangles, one per side (with one side of the triangle forming one side of the square), with each of those triangles being split into two halves, the bottom half of which forms the top half of the next triangle around the image.

Are you wondering yet what a Sierpinski Pentagon looks like? Let's take a look.

Sierpinski Pentagon
The Sierpinski Pentagon

It doesn't seem possible, I know, but setting n=5 has not changed the peculiar interlocking characteristic of the fractal shape. Each side of the "pentagon" interlocks with the two sides surrounding it, just as with the "square". For good measure, here's a Sierpinski Hexagon, which again has this remarkable characteristic.

Sierpinski Hexagon
The Sierpinski Hexagon

Once we'd parameterised the number of vertices on the base polygon, we realised that we had arbitrarily limited the way in which fractals were produced. Instead of just turning left or right, we could head toward any arbitrary vertex. This doesn't affect the triangle, obviously, but it certainly limits higher-order polygons. So we removed (or rather, parameterised) this limitation. Here we see the effect on three different polygons - the "square", the "pentagon", and the "hexagon", when we increase the "steering" capability of the algorithm from 1 to 2.

You really should get a browser that can do pix (or you could download these).

The pentagon image seems to be remarkably different to the square and hexagon -- more crowded. Is there a pattern here? Let's take a glimpse at the next few images in the same series:

Heptasinski Octasinski Nonasinski

The pattern seems clear -- polygons with an odd number of sides are a little more densely packed, but the central "hole" appears to oscillate around a particular size.

The next aspect of the Chaos Game that we parameterised was this business of "halfway". A half seems such a terribly arbitrary amount. So we allowed the distance of the new point to be any proportion of the total distance; i.e. we changed 0.5 to "somewhere between 0.0 and 1.0" with the value chosen by the user of our program, at runtime.

Let's see how this affects the character of the fractal algorithm, taking a single polygon as an example. Consider, for instance, the hexagon. Below, you will find a range of hexagons, with ratios varying from 0.1 (the most "flexible") to 0.9; the shorter the ratio, the more "curly" the fractal-generating path can be (which is why the earlier images are more densely packed than the later ones).

Various Hexagonal Fractals Fractals Fractals Fractals

That's with mt ("maximum turn") set to 1. Let's hike it up to 2, and look at the effect it has, for a variety of ratios:

Various Hexagonal Fractals Fractals Fractals Fractals Fractals

As we continue to increase the "steerability" of the algorithm, the fractal becomes more intricate:

Fractals Fractals Fractals Fractals

The final hack we made to Michael Barnsley's Chaos Game was to restrict (at our option, of course) the choice of corners to those that lie to the left (of a line joining the last corner chosen to the current position). The effect is significant, but I don't wish to burden this page with too many more images, so here's just one sample:

An anticlockwise fractal
Fractal generation restricted to anticlockwise motion only

Well, that's about it. Just to wrap up this page, I should add that you can get some neat effects by varying the colours of image and background. I particularly like green on black, but then I use green on black for just about everything.

The images on this page were generated by my Chaos Game program which, in an uncharacteristic fit of generosity, I've decided to make available for free download. (This screenshot is about 40KB, which is why I've linked to it here instead of displaying it directly. If you have the bandwidth, feel free to take a peek.)

I'm afraid it will only run on Windows, and has only been tested on Windows 98. The zip file is about 313KB in size, and the unzipped executable image is about 618KB. The program saves images as bitmaps. I then copied these images up to my Linux machine, and loaded them into the GIMP. For some odd reason, the background (which Photoshop assures me is correctly set to RGB(255, 255, 255)) turns up in the GIMP as RGB(248, 248, 248), but I fixed that by cranking up the contrast. Then I saved in PNG format. (That's why the images aren't twenty times as big, by the way.) If you get a kick out of using the Chaos Game generator, I'm pleased. If you don't, well, that's Not My Problem. A Linux version will be forthcoming just as soon as I find a Linux GUI programming environment that I find as easy to use as C++ Builder (and no, the Linux version of C++ Builder doesn't qualify, at least not yet). There is no installation program for the Chaos Game fractal generator. It's just a straight exe. It doesn't touch your registry, either, so uninstalling it is really simple; just delete it.