
L-Systems, or Lindenmayer Systems are systems of string manipulation. You start with a string – a sequence of letters, numbers, or other characters – and a set of rules. The rules specify replacements for certain characters. For example, your string could be “ABC”. A rule could be, “replace B with X”. Applying this rule to the string gives you “AXC”. Generally, you run through the string, replacing one character at a time, so you can’t say “replace AB with XY”. Instead, you would have to say “replace A with X, replace B with Y.” Two rules. You can, however, (and usually do) replace a single character with multiple characters: “replace B with XYZ”.
L-Systems are usually iterated over multiple times, resulting in long and complex strings in which the parts wind up resembling the whole. Self-similarity! Fractals.
They are also often combined with “Turtle Graphics”-like programs for making visual pictures of fractals. Such a system would have various simple commands for drawing lines, turning left, turning right, etc. You can map different characters in an L-System string to the Turtle Graphics program, and then process the string. Common mappings are:
F Draw Forward
+ Turn Right
- Turn Left
[ Store the current angle and position in a stack
] Restore the latest stored angle and position from the stack.
Play with L-Systems: LSysWeb
No Comments »
No comments yet.
RSS feed for comments on this post. TrackBack URL