                            Retyped Copy.


Designer Fractals.
By Robert Chrismas.

There are many programs around now which draw fractals. Part of the fascination of these programs is that the program and data do not seem to give any indication of the appearance of the fractal. It is fun to see an unexpected pattern 'emerging' from a few fairly simple lines of code. With a computer, it is easy to produce the picture if you have the program. However, it is quite a different problem to look at a fractal and be able to write a program to produce it on your computer screen. Thia article will explain how to cerate 'designer fractals'.

More reflective, and perhaps more more mathematically inclined, readers may have paused at the start of this article and thought 'well I've seen some things called fractals, but I'm not at all sure what one is'. You may be encouraged by this quotation from the book 'Fractals Everywhere', by the mathematician Michael Barnsley: 'Fractals are not defined by a short legalistic statement, but by the many pictures and contexts which refer to them.'

Michael Barnsley's Collage Theorem provids the key to producing our own fractal designs. In fact, the Collage Theorem allows us to create fractals which are 'close' to any shape at all. here we will concentrate on creating 2D fractals which can be defined by small sets of 'simple' transformations.

Affine Transformations.

Affine Transformations can stretch, squeeze, rotate,mirror and also move a shape but they cannot bend or tear it. An affine transformation (in 2D) can be described with just six numbers. For each point x, y we calculate a new point x1, y1 as follows:-

x1 = ax + by + e        y1 = cx + dy + f

Take the co-ordinates of a simple shape and any six values a.b.c.d.e.f calculate a new set of co-ordinates using the equations above, plot the new
co-ordinates on squared paper and join up the dots. The shape has been transformed. One nice thing about affine transformations is that straight lines stay straight so you only need to work out where the corners are. If you like, you can take a point somewhere on a line and transform it just to make sure it ends up on the transformed line. Likewise points inside the shape stay inside.

The !Draw program can perform affine transformations on selected objects, but copying some affine transformations in !Draw requires careful combination of of rotation and enlargement (or reduction) because in !Draw shapes can only be squashed along the x and y axes*.

Similitudes.

If we restrict a, b, c, d so that

a = r cos q,  b = -r sin q    c = r sin q    d = r cos q

the transformation can only move, rotate and reduce or enlarge the shape. All the angles must stay the same. In fact, the transformation will enlarge the shape by a factor r and rotate it by ane angle q.


If we use

a = r cos q   b = r sin q   c = r sin q   d = -r cos q

then the same applies but we also mirror the shape.

It is comparatively easy to find the values of a, b, c, d, for a similitude because we can measure the enlargement (r) and the rotation (t). From these it is easy to calculate the required values. The values e and f simply move the shape across and up.

The Collage Theorem.

the Collage Theorem says that we can define a fractal 'close to' a given shape by finding a set of transformations of the shape which just cover the shape.  The transformations, which must all reduce the size of the shape, can overlap.

Barnsley gives two algorithms for producing fractals described by a set of transformations. The 'Random Iteration Algorithm' is described here. It takes any point within the fractal and applies one of the transformations (chosen at random) to it. The new point must also lie within the fractal because the tansformation maps the whole fractal onto part of itself. So the new point is plotted and the process is repeated. This should take an infinite time to fill in the whole shape, but since computer pixels are of finite size, a reasonable approximation to the fractal can be produced in no mort than a long time.

Since it can be hard to find a point within the fractal to start with, you can start with any piont and do about ten iterations before plotting any points. (Not very rigorous, but it works.)

* The !Draw program cannot produce Shear. -- Alan (See my Article).
 

                        Richards Program Notes.
                        ~~~~~~~~~~~~~~~~~~~~~~~

Notes on the program [FractalIt3]

The program could be tightened up a bit,but I am afraid that once I got it working, I was too interested in producing fractals to do so.

For better resolution, you can divert the output to a massive sprite. A full description of the method would make htis (already lengthy) article far too long.

You can include any number of fractals in the same program. the data lines have the following format:

DATA %<Fractal Number>

DATA <Name>, <Number of equations>

DATA <x scale>,<x displacement>,<y scale>,<y displacement>

Then as many equation lines as required:

DATA <a>,<b>,<c>,<d>,<e>,<f>,<probability>

The 'Fractal Number' should be different for each fractal. The value of 'set%' (line 200) selects the required fractal.

The X and Y scales and disp;acements allow the fractal to be defined with any size and then rescaled to fit the screen.

The 'probability' is the probability that the particular equation will be chosen next. The probabilities must add up to 1. Give transformations which reduce the size the most the lowest probabilities or they will fill in too quickly.
