Some more L-System images. A little background on L-Systems, if you care. Basically, L-Systems are a means to procedurally generate trees. It can be used to generate various fractal or repeating imagery, but mostly I’m interested in using it to generate trees and plants.
The idea is simple, you have a string made up of symbols (called a “sentence”) and the sentence tell a plotter how to draw something. Imagine the plotter like this: you’re holding a pen on a sheet of paper and someone is giving you basic drawing instructions. “Draw forward 10 inches. Turn 90 degrees left. Then, draw forward 10 inches. And so on. A sentence to a plotter could look like this:
FF[+F]FF[-F]F
‘F’ tells the plotter to draw a line forward (for some arbitrary length, let’s say 10 units. ‘+’ Tells the plotter to turn right by 90 degrees. The ‘-’ tells the plotter to turn 90 degrees left. The square brackets tell the plotter that this is a new “branch” of a tree. So in this example, the plotter would start at the origin and then move foward 20 units (“FF”) and then encounter a new branch (“[+F]“). The plotter knows then to make a new branch with the open square bracket (‘[‘), turn 90 degrees (‘+’), and draw 10 units. It encounters the closing square bracket and goes back to the main trunk (“FF”) and continues to plot from there.
L-System Alphabet
How do you generate the strings for the plotter?
First specify an alphabet, which is what symbols you’ll include when you make new strings and what each symbol will mean to your plotter. In our case:
‘F’ – draw forward 10 units
‘+’ – turn 90 degrees right (+90 degrees)
‘-’ – turn 90 degrees left (-90 degrees)
‘f’ – move forward 10 units — don’t draw anything.
The alphabet is arbitrary. You can add more symbols and have new meanings for them as well, but this is simple enough to get started with.
Building L-System Sentences with Productions
From the alphabet you make “productions” or statements that describe how certain alphabetical characters expand into sentence parts. An example:
F -> F+F-F
Here’s the break down of what that means: to the left of the arrow you have the “predecessor” symbol in this case ‘F’. The arrow (“->”) means “expands into” and the stuff on the right hand side is the “successor” and that is the sentence that the predecessor becomes. If the sentence builder encounters the letter ‘F’ it will expand that into “F+F-F”.
To kick of generating an L-System structure you give it a root. So you might start with ‘F’. You also tell the L-System builder how many times to iterate through the string it’s building for the plotter.
The builder starts with ‘F.’
The first iteration through it’ll expand F into “F+F-F”
A second iteration would make that “(F+F-F)+(F+F-F)-(F+F-F)” — I’ve put each expansion into parentheses so you can visualize it easier, but the builder will not add ‘(‘ or ‘)’.
You can imagine what a third iteration through would do… it gets complex for anyone’s brain to fathom. At least my brain.
This string is fed to a parser or directly into a renderer which will plot out a line following the instructions of each character in the final sentence.
Makes sense?
Probably not, since I’m describing this off the top of my head. If you want more information and a detailed breakdown of what I outlined above, you can download the free PDF of The Algorithmic Beauty of Plants. It’s a fun little coding project to put together. Certainly everything I’ve done here in 2D also works in 3D.Идея за подаръкикониикониПравославни икони










