Lindenmeyer and Przemyslaw noticed that you could treat the long text strings resulting from multiple replacements as commands to build objects. In two dimensions, the interpertation is:

  • Start at x=0, y=0, facing along the x-axis.
  • Capital F means "draw a line of length=1 in the direction you are now facing".
  • + means turn left.
  • - means turn right.

Let's look at the result of applying the rule in the first paragraph 3 times. The string length grows fast. The three output strings are shown below, followed by the resulting geometric interpertation, assuming that left and right turns are each 90 degrees.

  1. Resulting string:
    F-F-FF+F-F-F
  2. Resulting string:
    F-F-FF+F-F-F-F-F-FF+F-F-F-F-F-FF+F-F-FF-F-FF+F-F-F+F-F-FF+F-F-F-F-F-FF+F-F-F-F-F-FF+F-F-F
  3. Resulting string:
    F-F-FF+F-F-F-F-F-FF+F-F-F-F-F-FF+F-F-FF-F-FF+F-F-F+F-F-FF+F-F-F-F-F-FF+F-F-F-F-F-FF+F-F-F-F-F-FF+F-F-F-F-F-FF+F-F-F-F-F-FF+F-F-FF-F-FF+F-F-F+F-F-FF+F-F-F-F-F-FF+F-F-F-F-F-FF+F-F-F-F-F-FF+F-F-F-F-F-FF+F-F-F-F-F-FF+F-F-FF-F-FF+F-F-F+F-F-FF+F-F-F-F-F-FF+F-F-F-F-F-FF+F-F-FF-F-FF+F-F-F-F-F-FF+F-F-F-F-F-FF+F-F-FF-F-FF+F-F-F+F-F-FF+F-F-F-F-F-FF+F-F-F-F-F-FF+F-F-F+F-F-FF+F-F-F-F-F-FF+F-F-F-F-F-FF+F-F-FF-F-FF+F-F-F+F-F-FF+F-F-F-F-F-FF+F-F-F-F-F-FF+F-F-F-F-F-FF+F-F-F-F-F-FF+F-F-F-F-F-FF+F-F-FF-F-FF+F-F-F+F-F-FF+F-F-F-F-F-FF+F-F-F-F-F-FF+F-F-F-F-F-FF+F-F-F-F-F-FF+F-F-F-F-F-FF+F-F-FF-F-FF+F-F-F+F-F-FF+F-F-F-F-F-FF+F-F-F-F-F-FF+F-F-F

Here are the images resulting from following the geometric instructions for each string. Repititions 4 and 5 have been included. The strings would have filled pages. you can see that the application of this simple rule makes very complex structures which are constructed of repeated, modular units, much like a plant or animal.

As you can guess by the drawing rules given above, without some further commands, all structures will be a single (very twisted) line. We need to be able to make branches, so we are going to add two new commands to the strings, [ and ]. These two commands are interperted as:

  • [ means "store the current drawing position and orientation". This storage is done on a stack so that several drawing states may be saved (in order) without losing any of them.
  • ] means "retrieve the last drawing position and orientation stored on the stack and make it your current configuration"

As an example, start with the string G. The geometry used will be that G means "draw a line of length 0.5 in the direction you are facing, and color it green". There are two replacement rules:

  • F is replaced by FF
  • G is replaced by F[+G][-G]F[+G][-G]FG

Note that each bracket, [ or ] will cause a branch. After 3 repetitions, with a turning angle of 25 degrees, you get the following image. Each brown branch is an F-type line, each green branch a G-type line.

Obviously it would be nice to have a fully 3D geometric interpertation so that we can construct 3D plants and animals. To go to 3D we need to define 7 different turning commands. We need to turn left/right, pitch up/down, roll left/right. It is very handy to also have a "turn around and go back" command. The symbols we will use are:

  • + means turn left by angle Delta, Using rotation matrix R_U(Delta).
  • - means turn right by angle Delta, Using rotation matrix R_U(-Delta).
  • & menas pitch down by angle Delta, Using rotation matrix R_L(Delta).
  • ^ means pitch up by angle Delta, Using rotation matrix R_L(-Delta).
  • \ means roll left by angle Delta, Using rotation matrix R_H(Delta).
  • / means roll right by angle Delta, Using rotation matrix R_H(-Delta).
  • | means turn around, Using rotation matrix R_H(180).

The rotation matrices refered to above are a mathematical way of keeping track the order of rotation operations and will be explained further below. The state of the drawing entity now has an orientation in 3-space which is defined by three othonormal 3-vectors:

  • The direction it is heading (drawing) which is called the H vector.
  • The direction which is up, called the U vector.
  • The direction to the left,...
Read more »