L System
Sample Scripts I


return to main index



Introduction

The notes for this page were derived from pages 10 to 12 of "The Algorithmic Beauty of Plants" by Przemyslaw Prusinkiewicz and Aristid Lindenmayer. It is very useful when testing the implementation of a L system to have examples of axioms and rules that generate known shapes.

This page consists of 9 example curves. The first seven are similar to the Koch snowflake - a shape proposed by Niels von Koch in 1905. The last two are copies of the Sierpinski gasket, first proposed in 1915, and the Gosper curve (1976). Although the curves by von Kock, Sierpinski and Gosper can be produced by a L system they were originally produced by other techniques.


Space Filling

image
"1<z1>z1>z11<z1<z1>z1"

  The shapes in this section are based on the following script.
  Only the rule for each shape requires editing.
  The axiom itself produces a square.

  axiom "1<z1<z1<z1"
  generations 2
  rule 1 "" # refer to the rule for each shapes
  angle 90
image
"11<z1<z1<z1<z1<z1>z1"
image
"11<z1<z1<z1<z11"
image
"11<z1>z1<z1<z11"
image
"11<z1<z<z1<z1"
image
"1<z11<z<z1<z1"
image
"1<z1>z1<z1<z1"


The Sierpinski Gasket

This curve is an example of applying two rules to produce a shape. The rules are almost identical in that they each produce three sides of a hexagon, but rule "G" makes its shape "turning" to the right, while rule "H" makes it shape while "turning" to the left.

The parts of the final curve that were produced by rule "G" are colored blue, while those segements produced by rule "H" are colored red.

  axiom "H" 
  rule G   "H>zG>zH"
  rule H   "G<zH<zG"
  rule "*G" "1" # apply this rule only on the last rewrite
  rule "*H" "1" # apply this rule only on the last rewrite
  angle 60
  generations 5



Gosper Space Filling Curves

This curve is an example of a space filling curve. With increasing generations it fills its interior more and more thoroughly. Again it is based on two rules that produce "left turning" and "right turning" curves.

The parts of the final curve that were produced by rule "G" are colored blue, while those segements produced by rule "H" are colored red.

  axiom "H" 
  rule "G"   "G>zH>zzH<zG<zzGG<zH>z"
  rule "H"   "<zG>zHH>zzH>zG<zzG<zH"
  rule "*G" "1" # apply this rule only on the last rewrite
  rule "*H" "1" # apply this rule only on the last rewrite
  angle 60
  generations 5





© 2002- Malcolm Kesson. All rights reserved.