hebbianloop / Muscatupa

Multi-scale Turing patterns generator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Muscatupa - Multi-Scale Turing Patterns

There are many visual patterns that occur naturally: zebra stripes, leopard spots, tribal tattoos... Ah well, maybe not the last one. Anyway, it turns out that some of these patterns can be described mathematically and computer-simulated. Starting with a grid of pixels of random values, and applying a simple set of rules over and over again, you see unexpected patterns emerge. Maybe you know Conway's game of life, that's the same kind of idea. Right now we're interested in Turing patterns, or reaction-diffusion patterns, which have been first described by Alan Turing. We owe him a lot, don't we?

Jonathan McCabe published an algorithm to generate "Cyclic Symmetric Multi-Scale Turing Patterns". Multi-scale because the patterns exist and evolve at different levels and at different timesteps (e.g. small wobbly mazes wobbling along with big wobbly mazes), and cyclic-symmetric because there's some circular averaging involved in the process, which gives a kind of mandala feeling to the generated pictures.

His published pictures and the videos that can be created with his algorithm are amazing. Think of a Windows Media Player visualization who quit her job and started doing LSD and listening to aggrotech. McCabe was nice enough to give lots of additional details about his algorithm to Jason Rampe, who published them in this blog post. Originally, I became aware of McCabe's work thanks to that post by Frederik Vanhoutte.

Some developers have already put their implementation online, see for instance this and that. I wanted to write my own so I can really understand the algorithm and play with it to discover different kinds of patterns (hopefully). At first I tried in Python, because I'm learning it so I thought it would be a good exercise. It was, but the generation was also really, really slow. Now I'm working with C because it's my favorite language and it's much faster for this application.

The source code uses the gifsave89 library to generate gifs, static or animated. I just took that one because the API is really simple, but I might pick another library later. The documentation is generated with Doxygen. To understand the main algorithm, everything that you need to know is explained in the abovementioned blog post.

As of today, the program runs and it's quite fast, so I got that going for me, which is nice. Generated animated gifs can get huge, though. For the moment, it works only with square images.

About

Multi-scale Turing patterns generator


Languages

Language:C 76.0%Language:HTML 23.9%Language:Makefile 0.1%