Fractal Explorer

Fractal Explorer - For Programmers

Fractal Programming Basics

When you want to program fractals you need to stick to some principles in order to succeed.

Programm Architecture


Fractals are self-similar. Because of this your programm architecture will be self-similar in the most cases. Self calling methods and attributes of the own class are needed when you want to programm fractals. Object Oriented Programming is extremly helpful for this task. Think of the fractal in theory, its creation process etc., then think of a main class which can describe every part of the fractal. This main class will need methods like iterate and draw.

These methods then should be recursiv. They check if the part already has been iterated. If not the iteration algorithm will be called and the child objects will be created, if so the method will call the iteration method of its childs.

When you engineer a software you need to think simple and in patterns. The simplest solution is in generally the best.

Programm Optimization


It is very important to optimize your code because fractals need alot of calculating capacity. But not only the algorithm needs to be optimized, especially the painting can be time intensiv if you choose the wrong methods. Take your time and test several graphic engines for their performance!

To optimize your algorithm it may be helpful to write the crucial code parts in assembler. That may safe you some calculating cycles per method call. No compiler is perfect. Good, manually coded assembler code is often faster than compiled assembler code!

Modern computers often use more than one core. To use all the calculating power of a modern computer it is necessary to know the concept of multi-threading. You can for example divide the fractal into different parts and assign one thread per part (This works for fractals like the Mandelbrot set where an iteration over the complex plane is executed). An other possibility is to divide the calculating and the drawing algorithms.