I spent the last several weeks exploring 3D l-systems, and you can see the results of this study in the new project, 32 L-systems.
Using Cinder, I wrote a program that could generate 3D l-system fractals given a set of initial rules and parameters. The tricky part of the program was getting the transformation from local coordinates to world coordinates to work correctly. It took me several days of frustration before I realized I just had to use matrix transformations (It’s been almost 4 years since I’ve done any matrix multiplication).
The complete set of videos showing all the fractals being generated can be found here.
L-System, or Lindenmayer System, is a mathematical formalism originally developed by the biologist Aristid Lindenmayer to describe the growth of simple multicellular organisms. While Lindenmayer initially studied algae and fungi, the L-System was eventually applied to plants and other more complicated structures.
L-Systems can also be used to generate fractal patterns. While I had done something very similar in earlier studies of branching patterns, this time around I actually wanted to see the pattern being drawn. As such, I had to create a simple turtle object that takes the position, angle, and length as the initial parameters and draws a line accordingly.
From there, it was just a matter of creating an iterative structure in the software and setting the rules as to when branches should form, at what angle, and what size. Of course, when writing iterative programs, it’s important to set a breakpoint so that it stops at some point, and doesn’t continue indefinitely. In my studies, I set it so that if the length of a branch is less than 10 pixels in length, it no longer reproduces.
Below are a few images generated by the program:
Videos showing fractals being drawn using the L-System:
After using the chaos game to generate the sierpinski triangle in the last post, I wanted to see if the same iterative process worked in 3D to create the Sierpinski Tetrahedron (aka Tetrix) seen below:
As it turns out, the iterative process is exactly the same, except instead of 3 markers, you now use 4 markers, each positioned at one of the vertices of a tetrahedron. Here’s a video of the fractal being drawn:
We usually imagine images that are randomly generated to appear fairly arbitrary, without any noticeable patterns whatsoever. As it turns out, however, randomness can generate structures and patterns with some very interesting characteristics.
There’s a very interesting class of games known as the chaos games, which involve randomness. I won’t go too deeply into the topic here, but I’ll introduce a simple version.
Imagine you have an equilateral triangle, and at each vertex of the triangle, you place a marker. Now, pick a point anywhere on the plane of the triangle. It can be inside the triangle or outside the triangle, doesn’t matter. Then randomly choose one of the 3 markers, and draw a point midway between the marker and the point you picked. Move to the midpoint, and randomly choose one of the markers again and draw the new midpoint. Repeat this process.
So what happens after several thousand iterations? As it turns out, the Sierpinski Triangle is generated. This is a pretty surprising result, but below is the image after 5000 iterations, from a program I wrote that runs the chaos game iteration:
Here’s a video of the dots being drawn:
Created a sphereflake, which is a 3D version of the Koch snowflake, using spheres. It was originally developed by Eric Haines.
As I could only find photographs of the sphereflake, but not descriptions of the actual iteration, I had to do some trial and error to place the next-level iterated spheres in the right locations. I’m still not sure if this is the exact same one as Haines developed, but it looks pretty close.
There are nine spheres created in each iteration. Six of them are placed 10 degrees below the equator of the orignal sphere, spaced 60 degrees apart from one another. The other three are positioned by finding the midpoint between two of these six spheres, for every other sphere, and then moving upwards 60 degrees. It’s probably a lot clearer to just look at the code.
Playing around with fractals. A few of my favorite images so far:
Finally started studying fractals, something I’ve been interested in for a very long time. I spent the whole day trying to figure out how create branches recursively, and finally found Daniel Shiffman’s tutorial on fractals. It’s written in Processing, but the main idea is still the same, so I just translated it to cinder code.
The problem I was having was trying to create a “Branch” class which would recursively call itself. As it turns out, all I needed was a recursive function.
Anyway, here’s a screenshot of the first fractal I made.