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

Friday, August 20, 2010

Fractals folding out new lands

In keeping with my apparent intense dislike of doing anything constructive (like say my work or my masters), here is another fractal image. This one a bit different from the others in that it is mathematically much simpler and its construction is animated. This is called (at least by me) a divided line fractal (not to be confused with a cantor set). It is very similar to the Koch Curve but with an element of randomness that creates intricate and varied shapes that come to resemble islands or coastlines. This similarity between coast lines and fractals was one of the earliest observations by Benoît Mandelbrot, resulting in his well known paper "How Long Is the Coast of Britain?". Similar techniques are used for artificial world creation in computer simulations and games.

The fractal itself is simple to construct. Start with an initial state of two vertical lines, one from the top to the bottom and the other from the bottom to the top of the frame. The for each line take the mid point and move it to a random location around where it was, creating two new line segments. Repeat this step until all the line segments are really small.

In this implementation every time a line segment is broken up the triangle that is created is filled with a translucent yellow. The resulting shape is then filled black. I like to think of the effect as looking like the world is slowly being unfolded, or fanned out from a really simple shape to complete outline

To draw a new shape hit the "Redraw" button. Once again this is done using the HTML5 canvas so you will need a decent browser (Chrome,Safari,Firefox,Opera) to get it to work. It also probably work work through an aggregator like Google reader or buzz since I think they disable scripting, so you will have to visit my original blog page to see it work.

Saturday, June 5, 2010

Julia sets and more fractals

Following on from my last post on the Mandelbrot set I've created a Julia set generator. Julia sets are a similar sort of fractal to the Mandelbrot set. The Julia sets I am showing are all generated using the function zn+1 = zn2+c. Thus for every possible value of c we get a different Julia set. In this viewer the Julia sets are shown in red. There are many other types, but these are the classic Julia sets that led to the development of the Mandelbrot set.

The Julia sets come in two varieties; connected and disconnected sets. Either all the points in the Julia set are connected to each other (forming a single central entity) or all the points are disconnected (forming a Cauchy set, also called Fatou dust). The Mandelbrot set is generated from this fact, basically the Mandelbrot set is all the values of c such that the generated Julia set. In fact the Mandelbrot set forms a pictographic index of all the connected Julia sets. If you zoom in enough into the Mandelbrot set you will eventually find a copy of every conceivable Julia set. Which is pretty cool.

Some of the Julia sets form incredibly beautiful shapes, while others can be pretty mundane, I have put a list of some interesting sets below the viewer, just click on the links and the values will load into the viewer. Otherwise please explore the space and try your own values. If you find a combination of values that looks particularly impressive please leave the values as a comment for other people to try. The instruction for use are the same as the previous Mandelbrot viewer with the addition of being able to change the values for c by giving the real and the imaginary parts.

Real:
Imaginary:
Precision:

Some interesting sets

Click links to load:

Thursday, June 3, 2010

The Mandlebrot Set

So I have been reading allot about fractals lately (you should start with this cool book), and of course the Everest of fractals is the Mandelbrot set. The Mandelbrot set is (for those of your who don't know) an intriguing mathematical object, but I won't go into the math of it. Just take my word for it that this set is one of the coolest things ever discovered) Visually though it has boundary that is infinitely complicated, containing myriads of twisting patterns and curves (in fact in a sense it contains every possible curve somewhere on it boundary. You can zoom in on the curve and it will remain detailed at any level of zoom, never becoming a simple shape.

I've also been wanting to try out the HTML5 canvas for a while, so I decided to make a Mandelbrot set viewer with javascript. doing something like this in a browser would have been impossible a few years ago, but now with modern browsers (this excludes Internet Explorer, sorry this wont work for you but I don't care) even computationally difficult tasks are becoming feasible using javascript.

Anyway,play around with it, maybe you get a little interested, maybe you check out some of the ideas. Maybe not.

Instructions

  • Below is the Viewer (If you don't see a cool shape it probably doesn't work on your browser, you should upgrade).
  • You are going to want to zoom in on a specific spot on the boundary of the black object in the middle (which is the Mandelbrot set), to do this click and drag around the place you want to zoom in on.
  • Eventually when you zoom in too far the shape will get boring, this is simply because the computer only renders an approximation. You can increase the precision by increasing the precision value in the text box and pressing the reset button. The higher the precision the longer in takes to render the picture.
  • Pressing the reset button will also let you zoom all the way out and start exploring and new part of the set.
Precision: