Friday, 7 March 2014

Mandelbrot Mountains

I've previously posted that I'm trying to find an easy way to explain why a naive extension of 2-dimensional complex numbers to 3-dimensional ones isn't possible, and that the answer needs to be 4-dimensional quaternions.

Anyway the underlying aim was to have some kind of 3-dimensional version of the flat Mandelbrot and Julia sets. I'm still working on the quaternion issue but in the meantime, I've written up an easier approach to making 3-dimensional images which produces pleasing results.

The idea is simple - use the colour information in the calculated arrays to represent height or altitude. In this way we have all we need to define a surface or landscape. Remember that the normal calculations determine a value which is the number of iterations reached for each point in the area of interest. This value could be one of two things; (i) the number of iterations reached before the orbit escapes a threshold indicating divergence, or (ii) the maximum iterations we'll allow before we get bored and say the point is unlikely to diverge. For the normal plots this value determines the colour we use to plot the point. This results in a flat coloured area for inside the Mandelbrot set, and a graduation of colours outside. Now we use this value for the height at each point.

Doing this in IPython is very easy. Simply import the mayavi extensions and use a very simple plotting instruction. You can't currently use the pure web remote IPython services as these 3-dimensional surface plots need to use real 3-d hardware, so local installs of IPython are needed (opengl is used).

Here are some examples.