Home • Gallery • Tutorials • Download • Purchase • Site Map

Processing Optimization

There are 4 major processing steps taken when the Fractal Science Kit generates a Mandelbrot or an Orbital fractal:

  1. Generate the sample data.
  2. Generate the normalization data.
  3. Generate the color data.
  4. Generate the image.

Each of the fractal's properties and each of the programs used to process the fractal, is associated with exactly 1 of these steps. When you change a program's Instructions or 1 or more properties on the Properties Pages and regenerate the fractal, the Fractal Science Kit will analyze the changes you have made and attempt to minimize the processing by skipping those steps not affected by your changes. For example, if you simply change properties associated with 1 or more of the color controllers that map the sample data to colors or you decide to try a different set of controllers altogether, only steps 3 and 4 need to be performed since the data generated in steps 1 and 2 are still valid. Since step 1 is the primary cause of long processing delays, any changes that only affect steps 2-4 are relatively painless. Unfortunately, many of the changes you make will affect step 1. However, once the sample data has been generated, you can make changes to properties that affect data normalization, sample to color mapping, adaptive smoothing, embossing, and/or image processing, and none of your changes will cause step 1 to execute, so the time required for regenerating the fractal image is relatively short.

If you change 1 or more of your Inline Functions, Inline Methods, or #Define Statements, the Fractal Science Kit does not attempt to determine if those changes will have an impact on any open fractals so you will need to run the Display Fractal / Compile All command on the Tools menu of the Fractal Window for each open fractal to force the Fractal Science Kit to recompile the code based on the new macros as required.

If you execute the Clear Sample Data command on the Tools menu of a Fractal Window, processing optimization is disabled since the sample data generated in step 1 is no longer available.

Program Optimization

Program optimization is performed when instructions are compiled. The most important aspect of this phase is to evaluate expressions involving constants/literals. For example, consider the following statements:

zRotate1 = Cis(DegreeToRadian(30))
zRotate2 = Cis(DegreeToRadian(Angle))

Clearly, the expression Cis(DegreeToRadian(30)) can be evaluated during compilation resulting in a constant assignment statement at runtime. The same can be said of the expression Cis(DegreeToRadian(Angle)) if Angle is a constant. This type of optimization can have a major impact on your program's execution speed.


switch (Projection) {
  case ProjectionTypes.Stereographic
    r = z.r*0.5
    w = 0.5 - Sqrt(0.25-r^2)
    z = PolarToComplex(z)/(1-w)
  case ProjectionTypes.AzimuthalEquidistant
    z.r = Asin(z.r)
    z = PolarToComplex(z)
  case ProjectionTypes.CircleLimit
    z.r = Atanh(z.r)
    z = PolarToComplex(z)

If Projection is a constant with the value ProjectionTypes.Stereographic, the optimized code reduces to:

    r = z.r*0.5
    w = 0.5 - Sqrt(0.25-r^2)
    z = PolarToComplex(z)/(1-w)

The switch statement processing is entirely eliminated in the optimized code. Constants are the key to making this type of optimization work. All options defined in the properties section and all variables declared const in the global section are constants.


Copyright 2004-2019 Ross Hilbert
All rights reserved