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.

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).

## No comments:

Post a Comment