This week we’ll move on to the L-system which was named after Aristid Lindenmayer, who was a Hungarian theoretical biologist and botanist. He worked with yeast, fungi, algae and he used L-systems to describe the development of such simple, multicellular organisms.
The system is based on an alphabet of symbols that are used to create strings, a collection of rules that expand the symbols into larger strings, an axiom string which is the starting point of the construction, and a mechanism that translates the string into geometric structures.
His original modelling of the growth of algae looked like the following:
alphabet: A B
rules: (A becomes AB), (B becomes A)
‘n’ is the number of iterations.
The above produces these strings:
n = 0 : A
n = 1 : AB
n = 2 : ABA
n = 3 : ABAAB
n = 4 : ABAABABA
n = 5 : ABAABABAABAAB
n = 6 : ABAABABAABAABABAABABA
n = 7 : ABAABABAABAABABAABABAABAABABAABAAB
The task at hand
Our L-system looks like this:
alphabet: X F
constants: + − [ ]
rules: (X → F−[[X]+X]+F[+FX]−X), (F → FF)
How are we going to make a plant out of this? We’ll use turtle graphics. The turtle moves according to commands relative to his own position. By the way, he also carries a pen, and draws a line as he moves.
This is how we’re going to translate the rules / strings into turtle graphics:
F: draw forward
−: turn left 25°
+: turn right 25°
X: won’t do anything, it only helps the evolution of the strings
[: save the current values for position and angle
]: restore previously saved position and angle
And here is our plant constructed with the help of the L-system: