home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ARM Club 3
/
TheARMClub_PDCD3.iso
/
hensa
/
graphics
/
fractal_1
/
!Fractal
/
Help
/
Mandelbrot
< prev
next >
Wrap
Text File
|
1996-10-09
|
10KB
|
266 lines
Mandelbrot
==========
The classic fractal, supplied here in 9 different flavours. Thanks to Joyce
Haslam and Michael Rozdoba for providing the maths for the enhanced versions.
The initial zoom uses integer maths, then switches to floating point
routines. The point at which the switch occurs depends on the zoom level and
whether you have an FPA chip. Without an FPA, the floating point routines
will unfortunately be very slow.
Level Set, Continuous Potential and Distance Estimator Methods
--------------------------------------------------------------
Three methods of calculating Mandelbrots are provided. The Level Set method
(LSM) is the one seen in most other Mandelbrot generators. LSM creates a
stepped image, resulting from plotting the number of iterations it takes
before the function tends to infinity. The Continuous Potential method (CPM)
is calculated in a similar way except that the colour plotted is dependant
on the value of the result, resulting in a much smoother transition of
colours which can look very professional.
CPM requires use of floating point and so will be slow without a maths
coprocessor. You will normally need to set Limit to a value >500 to get a
smooth transition, and will need to experiment with the Slope value to get a
good colour mapping. You will also need to use a palette that has smooth
transition of colours, such as Grey256 or Landscape2, and of course a
graphics board of showing these to their best! Alternatively try the Black &
White palette for an interesting Moire pattern.
CPM also looks good in 3d Mandelbrots since it gives a much smoother
terrain. See the Script file MountMandy for an example. The image generated
is similar to that seen in books like "The Science Of Fractal Images".
The Distance Estimator Method (DEM) enhances detection of the boundary
region of the Mandelbrot set. Normally for each pixel we calculate whether
that point is in (result tends to 0) or outside (result tends to infinity)
of the Mandelbrot set. Since there is so much detail within the set it is
easy to miss an interior point near the boundary since we are dealing with
discrete values at each pixel location. The DEM overcomes this by looking
either side of the current pixel in fractional amounts (ie. less than a
pixel's width) to see if an interior region is present. The distance we look
either side is set by the Threshold parameter - smaller values limit the
search.
When using DEM on the standard Mandelbrot plot you will notice it displays
extended fine filaments. If you zoom in you will find these filaments are
very fine indeed, requiring a lot of zooming to obtain resolution. The
benefit of DEM is that these boundary regions are where all the interesting
shapes are, so using DEM allows you to see these potential locations at low
magnifications.
To use DEM you need to turn off X/Y Guessing (in the Misc->Options panel)
since we need to calculate the values at each pixel and cannot guess their
values. It is also useful to set Min_Iter=Max_Iter so that only the boundary
is plotted, and Colour=255 to display the interior in white. As you zoom in
it will be necessary to increase the value of Overflow - if it is too low
the boundary line becomes distorted.
DEM requires a lot more computation than the other techniques so it is
slower. Also DEM requires 24*Max_Iter bytes for workspace, so be careful on
high iterations. You can combine the DEM and CPM techniques.
Data Values
-----------
x0, y0, width and height: the co-ordinates in the real & imaginary plane.
Max Iter: the bailout value. If the value of Limit has not been reached
after Max Iterations, then the calculation is stopped, assuming the interior
of the set has been reached. High Max Iter values will slow down plotting
but increase detail, and becomes necessary as you zoom in. DEM requires
24*Max_Iter bytes for workspace.
Min Iter: if the calculation stops prior to Min Iter then the point will not
be plotted. Setting Min Iter allows exclusion of low iteration colour
values. With LSM, for iterations > Min Iter, the colour is set to
Iter-Min Iter to extend the colour range into higher iterations. Set
Min Iter=Max Iter to only plot the interior.
Limit: when the value of the function exceeds Limit the calculation is
stopped. The default value of 4.0 is sufficient for the Level Set method and
is hard wired into the integer routines. For the Continous Potential method
values >500 are required to get smooth transitions between values.
Slope: used to transform the potential value when using CPM into a colour
number. As you zoom in and increase Max_Iter you will need to increase the
Slope - unfortunately there is no easy way to calculate the best value for
you. Altering slope alters the spread of colours across the potential.
Max Colour: used in CPM mode, it sets the maximum logical colour to plot.
Normally this will be 255 but higher values allow a greater range of
gradients at the expense of colours wrapping around.
Threshold: a value 0-1.0, used in DEM mode. It specifies the fraction of a
pixel to examine for the interior of the set. If it is too low no extra
detail is shown, whilst if it is too high the filaments become too wide,
resulting in lost detail. This parameter needs modifying depending on
function, Max Iter, Limit, Mandelbrot or Julia_Set, which is why this
parameter cannot be set automatically.
Overflow: This is the DEM equivalent to Limit. Lowering Overflow makes the
point more likely to be considered as part of the interior - if too low then
this estimate can get inaccurate. As you zoom in it will be necessary to
increase this value in fairly large steps, eg from 1e8 to 1e9 and so on.
3d Plotting
-----------
Mandelbrots and Julias can be drawn directly in 3d by turning on the 3d X/Y
Plot option. Use the Linear height transform. See the 3d section of
!MainHelp for details.
Menu Options
------------
Julia Set: switches to the equivalent Julia set. Moving the mouse changes
the Real (x) and Imaginary (y) values as shown on top of the screen. Press
select to generate the fractal. The best places to choose are along the
Mandelbrot boundary. After seeing the Julia image you can jump back to the
Mandelbrot by using Display->Previous if you have only drawn the Julia once.
Quarternion: switches to the equivalent Quaternion map in a similar way to
above. The selected x values becomes q0 and y -> q2 in the Quaternion set.
Function: 9 different Mandelbrot functions: square, cubic, quartic,
Bruce Ikenaga's function, a function discovered by Ushiki called Phoenix,
Quazi (a variant of square), and Inverse square, cubic and quartic.
Method: selects Continuous Potential and/or Distance Estimator methods of
colouring.
Infill: provides 5 different colouring options for the interior. Colour
allows the interior to be set to any of the 256 colours - enter the value
0-255 in the menu entry provided. Max. Iter uses the value of Max Iter as
the colour. The other 3 generate a colour based on the last iterated value
of z.
Period Checking: This is a technique that attempts to predict whether a
point is in the interior of the set or not. The aim is to save calculation
time at high iteration levels (>200). At low iteration levels the mechanism
can slightly slow the calculations, so the option is provided to allow you
to turn it off. NOTE: this option currently only refers to the floating
point routines.
Accuracy
--------
Various levels of accuracy are used to give the fastest possible plot. The
accuracy is determined by calculating delta=width/x_pixels. Assuming
x_pixels=640 which it is in most modes, the following table shows the switch
over points:
Delta> Width
2.5e-4 0.16 : 16 bit fixed point
2.0e-8 1.28e-5 : 32 bit fixed point, but not if FPA fitted.
2.5e-7 1.6e-4 : 32 bit floating point if FPA fitted.
4.4e-16 3.0e-13 : 64 bit limit of accuracy.
2.2e-19 1.4e-16 : 96 bit limit of accuracy. Only used by z=z²+c routine.
In practice the 64/96 bit limits start to become apparent before those
given. When nearing the maximum resolution (width<1.0e-15) turn off X/Y
Guessing in the Misc->Options panel - for some reason this technique is
currently interfering with the display. Also note that the x/y cordinates
can only be set using 64 bit accuracy, so zooming will become imprecise at
full 96-bit resolution. At maximum resolution the Mandelbrot image is 1000
times the distance between the Earth and Sun, so don't complain!
Algorithms
----------
For each pixel we calculate the x & y value and then iterate. For LSM The
colour is the iteration number unless uu+vv>4.0, when we set the colour to 0
(or as set by the Interior menu option). To speed up processing periodicity
checking is employed to detect when near the interior of the image - this is
where the values of u & v settle down to a set pattern.
For CPM the colour is computed as:
colour=Max_Colour-sqrt(log(uu+vv)/2^iter)*slope
For the DEM algorithm, see p198 of "Science Of Fractal Images".
Square: z=z*z+c
iter=0
u=0; v=0;
repeat
uu=u*u;
vv=v*v;
m=uu-vv+x
v=u*(v+v)+y
u=m
iter+=1
until (iter>maxiter or uu+vv>4.0)
Cubic: z=z*z*z+c
iter=0
u=0; v=0;
repeat
uu=u*u;
vv=v*v;
u=uu*u-3*u*vv+x
v=3*v*uu-vv*v+y
iter+=1
until (iter>maxiter or uu+vv>4.0)
Quartic: z=z*z*z*z+c
iter=0
u=0; v=0;
repeat
uu=u*u;
vv=v*v;
m=uu*uu+6*uu*vv+vv*vv+x
v=4*u*v*(uu-vv)+y
u=m
iter+=1
until (iter>maxiter or uu+vv>4.0)
Ikenaga:
iter=0
u=0; v=0;
repeat
uu=u*u;
vv=v*v;
m=u*(uu-3*vv+x-1)-v*y-x
v=v*(3*uu-vv+x-1)+u*y-y
u=m
iter+=1
until (iter>maxiter or uu+vv>4.0)
Phoenix:
iter=0
u=0; v=0; ux=0; uy=0
repeat
uu=u*u;
vv=v*v;
m=2*u*v+y*vx
n=uu-vv+x+y*ux
ux=u
vx=v
u=m
v=n
iter+=1
until (iter>maxiter or uu+vv>4.0)
Quazi:
iter=0
u=0; v=0;
repeat
uu=u*u;
vv=v*v;
m=uu-vv;
if (m<0) r=-m;
m=m-x;
v=u*v;
v=v+v-y;
u=r;
iter+=1
until (iter>maxiter or uu+vv>4.0)
Inverse:
r=x*x+y*y
x=x/r
y=y/r
then as per Square/Cubic/Quartic
Spider:
Not really a Mandelbrot, whilst the Julia version is just a fudge, but there
are many similarities. Does not use the periodicity checker and only uses a
floating point algorithm. Function is:
c(0) = z(0) = pixel
z(n+1) = z(n)^2 + c(n)
c(n+1) = c(n)/2 + z(n+1)