Main menu

Fractals, Cellular Automata, Chaos Theory, Science, Space, etc

Line based 3D Strange Attractors

I have played with 3D strange attractors in the past (see here and here). Those attractors were formed by plotting millions of points in 3D space.

The points plotted will seem to jump around randomly at first, but after a few million or so points they do start to form the attractor shapes.

The attractors in this post are slightly different. The attractor formula is still iterated in the same way, but in these attractors the points form a series of points along a curve. This curve can be plotted as a line in 3D space. I couldn’t find an official term difference between the attractors plotted by points vs the attractors plotted by lines. If there is one, let me know.

I had to have a go at adding these to Visions of Chaos as a new mode, so off I went.

The attractor formulas involved are fairly simple and the source code for each type really helped me get the attractor math going quickly. In the end I implemented 60 of the attractors on Jürgen’s page.

Displaying the attractors

If you use one of the attractor formulas you will end up with a long list of points in 3D space that need to be displayed.

I used a series of OpenGL cylinders between the points. This is OK but really doesn’t work as you have breaks where the cylinders do not join each other correctly. I need to implement some code to extrude a circle or other shapes along a curve when I get some time, but unless you look very closely at the following movie you won’t notice the breaks.

I have also added a 3D Strange Attractors album to my flickr gallery. If you have a pair of the old anaglyph red and blue glasses you can also see some anaglyph images of the attractors in this gallery.

Some quick programmer tips

If you work from Jürgen Meier’s excellent reference you may (or at least I did) notice some of the attractors do not plot the same as his. The cause of this is most likely (other than a typo in parameters) will be the delta value. The delta is that “small amount” that each iteration of the attractor is multiplied by to stop it “blowing up” and having all the points escape to infinity. If you notice your plot exploding lower the delta by a factor of ten and try again. Similarly some delta values seem too small so the plot takes a long time. Increasing delta will speed up the plot. You just need to tweak the delta until you get that sweet spot between accuracy and speed.

Another point to mention. When you calculate any strange attractor (this applies for 2D and 3D when using points or lines) you need to skip plotting the first thousand points. This allows the attractor to “settle” into the attractor’s basin. Otherwise you get a line or points that are not part of the attractor. An example is this image

That little squiggly tail at the bottom is where the plot started and is not part of the attractor.

Once you have the attractor points they will all tend to fall within different XYZ coordinate ranges. Scaling them all into a fixed range (in my case I used -0.5 to +0.5) allows them all to be centered on the screen when rendering and allows them to be easily shaded by converting XZY to RGB. All it took was a bit of whiteboard scribbling and I had nicely centered attractors.