About Me

Tobias
A 30+ year old Msc. Graduate in Computing Science currently working in the financial technology sector.
View my complete profile
Showing posts with label Fractals. Show all posts
Showing posts with label Fractals. Show all posts
Wednesday, August 4, 2010

L-system


Here is a personal favorite of mine. L-system is short for Lindenmayer system, as in Aristid Lindenmayer the hungarian biologist who introduced this technique in 1968. L-system is related towards formal grammar mostly known for describing the growth process of plants. The growth algorithm itself is recursive and often pretty simple, but the result is far more complex. The very nature of the process makes the L-system categorized to self-similarity, meaning that even a small part of the plant is similar to it's whole structure.

The plant has its point of origin which never changes, however how the plant grow is formalized recursivly through a number of iterations where every iteration has one or several sets of rules which discribes the growthprocess. This is an important difference between L-system and formal grammar where there only is one rule.

There are many offsprings of Lindenmayers original L-system, but we for now only focus on one - The Fractal plant. I'm going to use the wiki example because I think it's self-explanatory.

variables
: X F
constants
: + −
start
: X
rules
: (X → F-[[X]+X]+F[+FX]-X), (F → FF)
angle
: 25°
Here, F means "draw forward", - means "turn left 25°", and + means "turn right 25°". X does not correspond to any drawing action and is used to control the evolution of the curve. [ corresponds to saving the current values for position and angle, which are restored when the corresponding ] is executed.


Pretty life-like wouldn't you say? This is just an example of how L-system may be used, as I said earlier there are many variations. The emergent part is the simplicity, two rules howto draw lines produces this. If you look closely you can see the self-similarity in every branch. So what can we do next, well the video below is one thing.



I will return to L-system later to do some deeper analysis. For now ... as allways ... I leave it to you to find out more for yourself.

- Tobias
Tuesday, June 15, 2010

Fractals


F
irst of all, fractals are a bloody huge area which we are going to come back to several times, but for now I will settle with a brief introduction. The short description is - A fractal is natures answer to lego. Well, not quite but to some extent.

A fractal is a rough or fragmented geometric shape that can be split into parts, each of which is (at least approximately) a reduced-size copy of the whole, a property called self-similarity.
This is a fairly fitting description, but I will try to level it out even more. Note that I do not intend that readers must have a M.Sc degree in physics, mathematics or computing science to understand what I'm talking about. This blog is for everyone with an interest nomatter background. I may at times digg deeper in certain areas, applying theories with programming which WILL be hard to understand if you lack certain knowledge. But, I will do my best explaining it in simpler form.

So, back to fractals. They can take many forms and shapes, litteraly and the applicible areas are numerous. But as I said from the begining fractals can roughly be described as natures lego. By applying fractal design you can generate objects taken from real life and the varity is huge. From mountains and landscapes down to trees, bushed and plants. Fractals, when combined produce patterns and the most famous must be the Mandelbrot Set displayed to the left in the picture below.

Notice the pattern, you see it? Now look att the second picture to the right. Do you see it? Same pattern and doesn't that remind you of a snowflake? I'm not going into the mandelbrot fractal further, it's to complex for me to describe on this blog and there are several mathematical aspects of it so I'm just going to leave it up to you.

Moving on - life will find a way. Or God found a way, the lazy bastard , to generate land, mountains, trees and plants using "only" one key element. Building fractal mountains is fairly simple and a quick way of illustrating this is done in here. The site contains code for all you programmers out there, and at the end of the article the owner has posted links and compiled code for you none-programmers.

Download the Win32 binary, unzip it and execute the exe file and play around to get an idea how fractal mountains are generated. The more iterations you make, the more detailed mountains you get. If you were to add texture to this model you would get something like the picture to the right. Of course this mountain has been generate in a more complex way, but the same theory is applied.

If we take it down a notch or two, we get trees and plants. If generating mountains and landscapes were fun, this will surely twist your eyes.

To the left we have beautiful corals and to the right every kids favorite - Broccoli. See the twists and re-appearing patterns, fractals in its most exquisite form.

- Tobias