Tutorial Chapter 10
WHAT ARE THEY?
Generator iteration is easy - all you have to do is take a shape and substitute it with a different one several times. For the computer, however having a picture of the base and motif is not enough. We need a way of storing data about fractals that doesn’t take up a lot of memory with pictures and makes it easy to create algorithms for drawing fractals. The best way of doing it is by using l-systems. L-systems were developed by A... L... (the "L" in l-systems is his initial). They are composed of an angle definition, an axiom, and at least one rule. The axiom is the initial shape (base) used in the process of generating a fractal. The rules tell what symbols in the axiom should be replaced with other symbols. The symbols used are the following:
F draw forward
G move forward (without drawing)
+ turn counterclockwise
- turn clockwise
| turn back (180 degrees rotation)
@n multiply the length of the segment by n
I before the number means take inverse (divide instead of multiplying)
Q before the number means take the square root
! reverse the meaning of + and --
[ push (store current position on a stack)
] pop (go back to the last stored position)
Cn set the color to n
<n increment the color by n
>n decrement the color by n
Other symbols, such as X do not have any special meaning, but are often very important in intermediate steps.
A SIMPLE EXAMPLE
For example, the Koch snowflake uses the following base and motif:
As an l-system, we can write it as:
Axiom F - - F - - F
F = F + F - - F + F
|; start l-system by the name followed by a
; since Koch Snowflake uses equilateral triangles, 60 degrees makes most sense to use
; this is the way to code an equilateral triangle - sides (F) are followed by turning clockwise 60 degrees twice
; substitute each side (F) by the motif (F + F - - F + F)
; closed bracket means repeat the rules
Most fractals with fractal dimension from 0 to 2 can be expressed using an l-system. The combination of other symbols and more than one rule can create very complex ones. Such l-systems are used to make realistic models of plants.
Algorithmic Beauty of Plants
Przemyslaw Prusinkiewicz, A. Lindenmayer
Written by the founders of l-systems, this books is great for that topic.It mostly focuses on using l-systems to model plants and contains a lot of beautiful pictures. It is not very hard to read, especially because the topic is very visual.