★ APPLICATIONS ★ CREATION GRAPHIQUE ★ Fractal techniques ★ |
CPC Fractals (Computing with the Amstrad) | Applications Creation Graphique |
CHRIS RATCLIFFE zooms in on the knobbly bits of the Mandelbrot set IN the March 1987 issue of Computing with the Amstrad Ian Sharpe introduced you to a branch of mathematics known as fractal geometry. You may have seen similar intricate patterns created as a demonstration of the speed of expensive mainframe computers, or played computer games such as Rescue on Fractalus which use fractal techniques to create landscapes. But micros can quite easily generate impressive fractal pictures - and you don't need a degree in maths to appreciate them. CPC Fractals is a program designed to draw different parts of the region around a set of numbers known as the Mandelbrot set, named after B.B.Mandelbrot who has done much of the work in fractal mathematics. You can think of the Mandelbrot set as a two-dimensional shape and you can see the idea in Figure I. The interesting thing about the set is that if you zoom in on its edge you can see that the knobbly bits are made up from even smaller knobbly bits. Greater magnification reveals an intricate arrangement of fine fibres and swirling patterns which connect the main Mandelbrot shape to tiny features on its extremities. Some of these fibres are like miniature versions of the whole Mandelbrot shape. The edge can be magnified again and again to reveal more and more detail. Although the area of the Mandelbrot shape is finite, its edge is infinitely complex and has infinite length. In mathematical jargon the shape is "fractal". This talk of infinitely complex edges may sound as if producing the Mandelbrot set is beyond the poor old Amstrad - it would take an infinite amount of time. But the method, or algorithm, for working out which numbers are in the set is surprisingly simple. Put mathematically, the Mandelbrot set is the set of complex numbers c , for which the iteration z -z ^ 2 + c converges. If that sounds confusing think about it this way. Let's take two numbers, say x and y, which we will use as constants, and two variables, a and b, which we will change and update in a loop. The formulae for updating a and b are: new a=(old a) ^ 2-(old b)^2+x new b=2*(old a)*(old b)+y We give a and b initial values of zero and put them into the formulae. This will give us new values of a and b number of calculations needed, especially the 100 calculations for values in the Mandelbrot set, means that the process would be very slow. To get good results in a reasonable time the main calculation and plotting loops are written in machine code, with some Basic attached to set up tables and so on. This allows most patterns to be produced in a few hours. Considering the program works in Mode 1 and calculates the colour of some 58000 pixels, this is good going. The machine code is held in data statements and if you make any mistakes typing it in you will be told which line contains the error - though it is still a good idea to save a copy of the program before testing it for the first time. When the program is run it will spend a few seconds initialising, then you will see a menu at the bottom of the screen. The available options are:
A good way to explore the Mandelbrot set is to first use the Run option to get a picture of the whole set. Enter x1 =-2.3 x2 = 1.1 y1 =-1.19 and when it has finished save it. This pattern will act as your map of the fractal terrain, so you can magnify interesting areas with the Zoom option. Also it is best to make the difference between x1 and x2 greater than about 0.002 to avoid spoiling the shapes with rounding errors in the calculations. Some good spots to try are shown in Table I. Due to the nature of fractals the program can be used to look at literally millions of interesting areas around the Mandelbrot set. When you have created and saved fractal pictures Program II can be used to produce fascinating animated displays. It will load a pattern and cycle the ink values so that the fibres appear to flow into the screen.
|