Thorn Fractals

After seeing Paul Bourke’s page about Thorn Fractals I had to have a play and add them into Visions Of Chaos.

Sample C source code is available on Paul’s page and the inner formula comes down to CX and CY parameters in the main iteration loop for each pixel;

a = ir;
b = ii;
ir = a / cos(b) + cr;
ii = b / sin(a) + ci;

Here are some sample images using the above formula. The CX and XY in this case can be anywhere between -10 and +10.

Thorn Fractal

Thorn Fractal

Thorn Fractal

Thorn Fractal

Thorn Fractal

I also experimented with changing the formulas and discovered the following three variations.

Variation 1.

ir:=a/cos(b)*sin(a)+cx;
ii:=b/sin(a)*cos(b)+cy;

For this variation the CX and CY should stay within the range of -1 and +1. Values outside this range will lead to very noisy images.

Thorn Fractal

Thorn Fractal

Thorn Fractal

Variation 2.

ir:=a/cos(b)*sin(b)+cx;
ii:=b/sin(a)*cos(a)+cy;

Again CX and CY should stay within the range of -1 and +1.

Thorn Fractal

Thorn Fractal

Thorn Fractal

Variation 3.

ir:=a/sin(cos(b)*sin(b))+cx;
ii:=b/cos(sin(a)*cos(a))+cy;

Thorn Fractal

Thorn Fractal

Thorn Fractal

When rendering these sorts of fractal images you will get lots of aliasing, noise and moire effects. These can be overcome by supersampling (rendering the image to 10 or 20 times the actual size and downsampling). Most of the images in my sample gallery used at least 10 times supersampling, so every pixel is actually the average of 100 sub-pixel calculations. Even at 20 times supersampling there are still visible areas that show aliasing in some renders.

Dane Vandeputte (mentioned on Paul’s page) uses Contrast Limited Adaptive Histogram Equalization to bring out some really nice details in these sort of fractals. I will have to try adding CLAHE to Visions Of Chaos in the future.

Jason.

3D Cellular Automata

Cellular Automata (or CA as they are often abbreviated to) have insterested me for many years (at least as long as I had an interest in fractals or maybe longer). I can still remember writing my first serious code in Turbo Pascal and being amazed at the patterns that arose from John Conway’s Game Of Life. Cellular Automata are a great example of complexity and emergence arising from simple rules.

3D CA have been implemeted in Visions Of Chaos for years, but only in a 2 state version (ie each cell is either dead or alive). Here is an older low resolution example of some of the 2 state rules I found (this used to be “high resolution” on YouTube).

I revisited the 3D CA code when testing the new JPS support in Visions Of Chaos. The most obvious progression was to allow more than 2 states per cell. This leads to more interesting results (but also a much larger possible search space to try and find good rules within).

Here are a few of the multi-state 3D Cellular Automata rules I found while testing the new 3D CA code. They are all based on the surrounding Moore neighborhood 26 cells.


4 4 5
Survival 4
Birth 4
Number Of States 5
This rule can be difficult to get started and develop (as this movie shows), but once past the initial deadness it develops many gliders and other shapes.


Amoeba 3
Survival 9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26
Birth 5,6,7,12,13,15
Number Of States 5
This one has slow growth using bulbous pulsating arms to grow. Rarely it will sprout a thin diagonal growing arm from the main body that will continue to spread until it hits a wall or other active cell(s).


Coral
Survival 4,5,6,7
Birth 6,7,8,20
Number Of States 4
Trying to get coral like growth. I have tweaked this one for hours and cannot seem to get a nice realistic coral result.


Jason’s Brain
Survival 4
Birth 4,8
Number Of States 5
Very similar to 4 4 5. Found when I was trying to find a 3D version of Brian’s Brain (hence the name).


Pyroclastic
Survival 4,5,6,7
Birth 6,7,8
Number Of States 10
Expanding rule. Reminded me of footage of pyroclastic flows from volcanos.

Finding good or interesting rules is not easy, so if you have any new rules let me know. Just comment on this post and give the details.

Finding ways to display 3D Cellular Automata can be difficult. The main issue faced is if the rule causes a dense cluster of particles you only get to see the outside and the inside of the structure(s) remian hidden. Some options I experimented with are only rendering state 1 (ie cells that have just been born) cells, and rendering the display with a chunk of cells cut out of it to see inside.

A quick side tip for other programmers. If you are rendering a large grid of 3D cubes in OpenGL you can work out which sides of each cube touch another cube and then skip passing these faces to OpenGL. The overhead of coding the face checks gives a huge speedup when there are a large amount of cubes on screen.

Jason.