Implementation of the recursive escape algorithm in openscad.

**UPDATE 11/8/15**: Customiser's script rendering time limits of around 5 seconds are greatly inhibiting mould and fractal generation. As a result I have uploaded sample STLs instead of running through Customiser and I therefore recommend running the .scad file locally with openSCAD.

Simply download openSCAD (http://www.openscad.org/downloads.html), load the .scad file and press F6 to render models with any variables you like.

Fract-A-Castle is a completely customizable generator of sandcastle moulds described by 2D and 3D Julia set fractal patterns. It has never been easer to amaze onlookers with the beauty of mathematics.

**The Idea**

Fractals are perhaps one of the most strikingly beautiful areas of mathematics. Julia set fractal patterns like those in Fract-A-Castle may be generated from quadratic iterations. These iterations, such as z → z^2 + c, describe a process: take a complex number, square it, and add a constant complex number c. Repeating this process iteratively reveals a patterns known as Julia set, consisting of the set of all z on the complex plane such that z → z^2 + c does not diverge exponentially.

Through varying both the real and imaginary component of c, many different beautiful Julia set fractal patterns can be generated. I also conceived of generating 3D Julia set fractals, called capstones, each vertical level of which would be obtained from a higher number of quadratic iterations. The capstones would reveal visually how fractal patterns emerge, and are a great way to teach others about the beauty of complex dynamics.

**Implementation**

After a little tinkering around, I was eventually able to implement a Julia set fractal generator in openSCAD. This was quite challenging, especially with my fairly limited coding experience. I had to learn how to program at a functional as opposed to objective manner, and work with with the compile-time variables of openSCAD instead of the run-time variables of MATLAB and C. My final generator was achieved through a combination of recursion and pseudo-complex number representation.

The next step was building the fundamental basic designs we all associate with castles: walls, towers and battlements. I also incorporated a text mould generator to enable one to decorate or label their own fractals with text and Unicode characters.

Finally, I reworked and eliminated some of the more troublesome features of my designs for increased printability and ease-of-use with wet sand. The towers, for instance, were originally designed with customizable overhang angles, but it was very difficult to incorporate this feature with a sandcastle mould, which must be vertically convex to enable separation of sand from mould.

**Result**

Fract-A-Castle is the ultimate tool for demonstrating mathematical prowess at the beach. One can use large 2D fractal moulds like cookie cutters, leaving rows of fractal patterns in the sand. Three-dimensional capstones can be generated, enabling onlookers to better understand the emergence of fractal patterns over successive iterations. Finally, one can combine these fractals with a fully parametric classic castle design to add a new mathematical twist to the timeless art of sandcastles.

A generalization of the Mandelbrot set to 3 and 4 dimensions. Read more at:

https://christopherolah.wordpress.com/2011/08/08/the-real-3d-mandelbrot-set/