Algorithms   

Strange Attractors

Strange attractors are very easy-to-make fractals that use formula iteration. All you have to do to generate a strange attractor is start with some initial point and determine every next point using some formula. Many strange attractors use complex number formulas, which cannot be used in most computer languages. You have to modify such formulas to fit real number variables that determine the complex number coefficients. Also, many strange attractors are 3-dimensional and you have to graph points in 3D. Read programming reference to learn how to do these things.

Some strange attractors use derivatives in their formulas (don’t read this part if you are not familiar with calculus). For example, the Lorenz Attractor uses the following formulas:

dx/dt = –ax + ay
dy/dt = bx – y –xz
dz/dt = –cz + xy

In order to use ordinary algorithms for generating strange attractors, we have to change these formulas so that they express x, y, and z. Mathematically, dt is not a variable that we can perform ordinary operations with. However, in our case the computer will not calculate the change in variables continuously. Instead, it jump in certain intervals of time. In such case, we can multiply each equation by the time interval to get the change in variables after that amount of time. The smaller our interval will be, the more accurate the results. Knowing the changes in variables, you can add them to the old variables to get the new values. For example, the above formulas can be changed to these:

new x = x – ax · interval + ay · interval
new y = y + bx · interval – y · interval – zx · interval
new z = z – cz · interval + xy · interval

The above algorithm can be used to generate any strange attractor. The parts written in blue have to be used only for 3D fractals.

Constants used:

initial_x, initial_y, initial_z: coordinates of the initial point
number_of_points: more points makes it look nicer, but works slower
formula1, formula2, formula3: formulas of the strange attractor
color: the color you want your fractal to be

‘ set the variables to the initial point
x = initial_x
y = initial_y
z = initial_z
‘ perform the iteration
FOR num = 1 TO number_of_points
             new_x = formula1
             new_y = formula2
             new_z = formula3
             x = new_x
             y = new_y
             z = new_z
             x_coordinate = x
             y_coordinate = y
             ‘ refer to the programming reference to learn how to modify
             ‘ new_x and new_y to suit 3D fractals
             ‘ plot the point
             PSET (x_coordinate, y_coordinate), color
NEXT num

forward

forward