Game Development Reference
In-Depth Information
After numerous iterations, a string such as F + F + F + F is then
interpreted by a drawing algorithm in which the letters represent lines
and the + a turn to the right (if - is used it means turn to the left).
It is reminiscent of turtle graphics in which a cursor on the screen is
given commands to draw a line, turn right, draw another line, etc. The
turn angle is preset. Let's say F represents draw a straight line and +
represents turn 90°. The drawn result would be a square as shown
in Figure 7.23 .
In addition to drawing and turning, an L-system can contain push and pop
points. These are represented by square braces ( [,] ). When the drawing
algorithm encounters these points it remembers its location on a [, keeps
drawing, and then returns to the remembered location when it encounters a
]. For example, F[+F]F where + is 45° would produce the L-system shown in
Figure 7.24 .
L-systems become more complex with the addition of extra rules such as
the one shown in Figure 7.25 . This is a famous fractal called the Sierpinski
FIG 7.23 An L-system that draws a square.
Search Nedrilad ::

Custom Search