For my final project I have implemented a system which uses bracketed
context-free Lindenmayer systems (OL-systems) to generate realistic
plants. The end result is a set of polygons which can then be rendered
using conventional techniques to get a photorealistic picture of a plant.
An OL-system is a context-free grammar that is used to generate a
control string which is then used by a turtle-graphics system to generate
the output image. The L-system has two attributes which are:
- A default turn angle
delta, measured in degrees,
which is the angle the turtle should turn when it turns
- A recursion depth
n, which is the number of times
the production rules should be applied to the control string
The turtle has an attribute length which is the default amount
to move when it moves forward and several commands which are as follows:
- F
- Move forward by line length drawing a line
- f
- Move forward by line length without drawing a line
- +
- Yaw left by delta degrees
- -
- Yaw right by delta degrees
- &
- Pitch down by delta degrees
- ^
- Pitch up by delta degrees
- \
- Roll left by delta degrees
- /
- Roll right by delta degrees
- |
- Turn around (yaw left by 180 degrees)
- [
- Push current turtle onto stack
- ]
- Pop current turtle from stack
- {
- Start a new polygon
- }
- Complete and draw the current polygon
Here is a gallery of images generated using this software:
 |
n=7, delta=22.5 degrees
A
A -> [&FL!A]/////'[&FL!A]///////'[&FL!A]
F -> S/////F
S -> F L
L -> ['''^^{-f+f+f-|-f+f+f}]
|
 |
 |
 |
n=5, delta=25.7 degrees
F
F -> F[+F]F[-F]F |
n=5, delta=20 degrees
F
F -> F[+F]F[-F][F] |
n=5, delta=22.5 degrees
F
F -> FF-[-F+F+F]+[+F-F-F] |
 |
 |
 |
n=7, delta=20 degrees
X
X -> F[+X]F[-X]+X
F -> FF |
n=7, delta=25.7 degrees
X
X -> F[+X][-X]FX
F -> FF |
n=5, delta=22.5 degrees
X
X -> F-[[X]+X]+F[+FX]-X
F -> FF |
This software is not limited to just plants. It can also be used to
generate and render a set of curves known as FASS curves (for space-
filling self-avoiding simple and self-
similar) such as the Peano and Hilbert curves:
 |
 |
n=2, delta=90 degrees
L
L -> LFRFL-F-RFLFR+F+LFRFL
R -> RFLFR+F+LFRFL-F-RFLFR |
n=2, delta=90 degrees
A
A -> B-F+CFC+F-D&F^D-F+&&CFC+F+B//
B -> A&F^CFB^F^D^^-F-D^|F^B|FC^F^A//
C -> |D^|F^B-F+C^F^A&&FA&F^C+F+B^F^D//
D -> |CFB-F+B|FA&F^A&&FB-F+B|FC// |
It can also generate fractal curves such as the quadratic Koch island
and a system known as "islands and lakes":
 |
 |
n=3, delta=90 degrees
F-F-F-F
F -> F-F+F+FF-F-F+F |
n=2, delta=90 degrees
F+F+F+F
F -> F+f-FF+F+FF+Ff+FF-f+FF-F-FF-Ff-FFF
f -> ffffff |
J. Scott Hofmann
Return to my home page.
Last modified: Tue May 5 14:24:24 EDT 1998