xbdev - software development
Wednesday February 21, 2024
home | contact | Support


Fractals and the Mandelbulb



Fractals make you see everything differently. When you first read and learn about fractals, it's like Pandora's box. A hidden magic of unlimited possibilities. Not only are fractals incredibly powerful, but they are also beautiful and fun. In particular, graphical fractals possess infinite detail combined with unpredictability, that is really amazing. Once you get past all of the mathematics and visualization challenges, you'll never look at the world the same again ;)

A particular fractal with interesting visual properties is the Mandelbulb.

Famous 2D Mandelbrot Equation

2D Mandelbrot equation:

$z{n+1} = z{n}^2+c$.

Squaring complex numbers has a simple geometric interpretation: if the complex number is represented in polar coordinates, squaring the number corresponds to squaring the length, and doubling the angle (to the real axis).

Taking the Mandelbrot equation to higher dimensions leads us to what is now known as the Mandelbulb fractal.

Output for the above Python program. Show the cross sectional view of a Mandelbulb.

The various depths are shown in different colours.

MandelBulb Ray Tracer (Stripped)

A minimum working Mandelbulb ray tracing implementation. All you need is a C++ compiler. Of course, you could port it to Python, as it's relatively straightforward, but it would be slow! It's slow in C++, it takes a few seconds to create the image in C++, so it might take a few minutes in Python.

The implementation should hopefully let you see how it all fits together. Also a fun demo for you to tinker with and experiment with as you learn about geometric fractals.

The following implementation creates a ppm image file. You should be able to open this image file in most image editors (e.g., XNView is a free image viewer/formatter if you don't have Photoshop).

[1] [Wikipedia Mandelbulb](https://en.wikipedia.org/wiki/Mandelbulb) - Explains the history and the mathematics (helps you understand where and why of the equations in the code)
[2] [WebGL MandelBulb Ray Marching 3D rendering](https://github.com/BrutPitt/wglMandelBulber) [Nice web-based demo on GitHub]
[3] Dual-Quaternion Julia Fractals (Kenwright) - Exploring fractals (alternative mathematical models and methods for representing and defining geometric surfaces)
[4] [Python Mandelbulb Slice Receipe](http://code.activestate.com/recipes/578198-mandelbulb-fractal/) Sweet little python program to show a minimal working example of a mandelbulb 'slice'
[5] [Daniel White's site](https://www.skytopia.com/project/fractal/mandelbulb.html) Mandelbulb and its history, very well documented details, and continue to discuss various distance estimators for the concept
[6] [WebGPU WGSL Demo - Ray Tracing](https://webgpulab.xbdev.net/index.php?page=editor&id=mandelbulbbasic2&)

Advert (Support Website)

Copyright (c) 2002-2024 xbdev.net - All rights reserved.
Designated articles, tutorials and software are the property of their respective owners.