Sunday, September 23, 2007

Fractal

“Most of the nature is very very complicated. How could one describe a cloud? A cloud is not a sphere…A mountain? It’s not a cone…
If you want to speak of clouds of mountains of rivers of lightning the geometric language of school is inadequate."
Benoît Mandelbrot

You might wonder how the beauty of nature can be created within a computer. Trees, Mountains, Clouds, Landscapes doesn't have proper geometry so it is very complicated to model such objects.
The beauty of the Nature always combines with its mysteries. One good example is the Iterated behavior of the objects. What that means is that, a larger object is made of combining scaled copies of its own. It's like a big cube consist of many smaller cubes. once we combined the smaller cubes in a such pattern, we end up with the big cube.


Above picture is a Fern, created by plotting points which results in iterating very simple functions for several thousands of times.



Once we Zoom above picture, this is what we get. When observing carefully we can see its leafs are made of small sized copies of the main picture. This is the fundamental concept behind Iterated function systems.
The function we used to create the above leaf is :
x(n+1) = ax(n) + by(n) + e -------(a)
y(n+1) = cx(n) + dy(n) + f -------(b)
where a, b, c, d, e, f are constants of scaling and shifting of the main shape of the object.
Eg: we used 4 levels of details for the above Fern and the constants used were
a = [0.0 0.2 -0.15 0.75];
b = [0.0 -0.26 0.28 0.04];
c = [0.0 0.23 0.26 -0.04];
d = [0.16 0.22 0.24 0.85];
e = [0.0 0.0 0.0 0.0];
f = [0.0 1.6 0.44 1.6];
and the probabilities for assigning points for each level are
p = [0.1 0.08 0.08 0.74];
Equations (a) and (b) can be used to simulate any form of self simillar object in 2-D.