Wednesday, September 22, 2010

The Splitting Spira Mirablis

Here is another spiral tree related post. This time I have used a logarithmic spiral, also known as the Spira Mirablis (Latin for the Miraculous Spiral).

This spiral appears in many places in nature and has a variety of interesting geometric properties. It was deeply studied by Jacob Bernoulli. He was infatuated with it to the point that he wanted it engraved on his tombstone along with the phrase "Eadem mutata resurgo" ("Although changed, I shall arise the same."). Unfortunately, the engraver put the wrong type of spiral on his tombstone.

Monday, September 20, 2010

South Park me

I stumbled upon this awesome little flash widget at http://www.sp-studio.de/. Its a south park character creator. So I decided to make a south park me. I present south park James.

South Park James

Friday, September 10, 2010

Spiral Trees and Tim Burton's Forest

A friend sent me the link to the MIT OpenCourseWare site for a 2007 summer school session on Gödel, Escher, Bach: A Mental Space Odyssey. I looked at the images section and saw these cool pictures (obviously from somewhere in the book that I haven't gotten to yet). So I decided to recreate them (though using a different type of spiral).

Below you will see the animation. I have made it in 2 modes, one that creates the hypnotic spiral trees and an altered form that creates haunting trees that remind me of Tim Burton's Nightmare Before Christmas. Check it out and if you are interested I will explain the mathematics below.

Normal Mode
Tim Burton Mode

So the basic spiral tree works recursively in the following manner: It starts tracing out a spiral starting from the outside going to the center. At each point it has a random chance of splitting. When a split occurs a new spiral with the same radius is created, the center of this spiral is the reflection of the previous center through the point where the split occurs and the spiral is made to rotate in the opposite direction. This continues with each new spiral, in a process that is reminiscent of the L-Systems I have blogged about before.

The normal spiral I have used is a quadratic spiral, in that if the angle of rotation of a point in the spiral is θ then the radius is r=θ2. I believe the spirals used in the original text are logarithmic spirals (r=eθ), which are mathematically more interesting but visually took up too much of the limited space available.

For the Tim Burton style trees I generalized the notion of a spiral and allowed a non-monotonic relationship between angle and radius. I instead made the relationship proportional to sin(5θ)*θ2. which gives it the distinctive kinks but still retains a smooth profile (since the function is differentiable).

Wednesday, September 1, 2010

Exploring L-Systems

Another day, another dog. Another month, another piece of dangerous productivity avoided. This month I am avoided furthering my life goals by starting to read Godel, Escher, Bach", which is an awesome book. It deals with a remarkable amount of things, including formal logical systems. This got me delving into string manipulation systems again and somehow got me onto L-Systems.

L-Systems were developed by this theoretical botanist (yes such a thing exists) to codify plant growth. Later they were taken up by mathematicians to visualise and generate a variety of interesting recursive geometric patterns. Lately they have been used extensively to generate artificial life in computer science, especially tree like entities.

L-Systems are a string rewriting system. basically they take a string of characters, and then create a new string by replacing each old character with a new string, according to some rules. This continues and iterates creating increasingly more complicated and intricate strings of characters. These characters can then be interpreted by drawing program to make beautiful patterns. You can read more about L-Systems at the Wikipedia Article, I don't want to get bogged down in the details, I want to look at some cool patterns.

Below is an L-System generator I built. You can explore the different possibilities of L Systems. The string grammar is as follows:

  • Capital Letter: Draw a line forward
  • Small Letter: Do nothing
  • +: Turn right
  • -: Turn left
  • [:Save position to stack
  • ]:load previously saved position from stack
The rules are defined in a simple way, for example "x->y" means replace every "x" with a "y". You can change a whole bunch of settings about how the drawing system interprets the strings in the settings below. This is a bit of a rushed explanation, but you can find lots of info online that should help you out. There is also a list of interesting presets at the bottom of this post, check them out, play around, leave any interesting rules you find in the comments.

Axiom:
Rule:
Number of Generations:
Starting Point: (, )
Starting Angle:
Turn Angle:
Movement Size:

Interesting Examples