Paul Dunn came across an interesting algorithm...and then shares that he forgot where. :-) I notice that the equation shares some general similarities with the Burning Ship fractal and wonder if that might have been his starting point. Whatever the source, Dunn implemented and enhanced it until a surprisingly complex and attractive image resulted. The core of the math is similar to trochoids but armed spirals are generated (the "bubbles" in Dunn's name) looking like spiral galaxies. Nested for loops are used where the outer loop specifies the number of spirals to create, and the inner loop generates points in each spiral. Simple arithmetic is used to generate RGB values for coloring. The red and green are directly based on the two loop counters, and blue is based on the counters' sum.
Dunn uses real numbers but a complex exponential concisely characterizes a spiral. For example, the following spirals are generated by the expressions shown. Both angle θ and radius r gradually increase from zero. (j is the square root of -1.)
This typical spiral from Bubble Universe results from the algorithm Dunn uses. Notice that the two terms are not scaled, therefore |z| ≤ 2. z' and z'' indicate that the previous z has been modified by increasing the angle (detail omitted here), resulting in a variation of the spiral and other hugely interesting properties. Without it, only one spiral is created. See the code itself, linked to below, for details. An n x n matrix of complex values is created. Each of those values represents a point on the complex plane which will be plotted using some RGB value. The points are additionally mapped to a larger square image. For example, a 200x200 matrix of complex points might be plotted in a 1000x1000 pixel area. The spreading out of points often enhances the attractiveness of the image.
I wrote a python program, bubble.py, that you can download and run:
bubble.py to generate a 250x250 image. bubble.py -N 800 250x250 calculations and 800x800 image. bubble.py -n 400 -N 800 400x400 calculations and 800x800 image. bubble.py -a b.gif -f 500 -n 400 -N 800 create animated b.gif with 500 frames, 400x400 calculations and 800x800 image.
The image below is generated with:
bubble.py -a spirals.gif -f 100 -N 500
Modifying rotation of the complex exponent results in different but still mesmerising movement. Experimentation is recommended!