next up previous contents
Next: FRACTINT conventions Up: L-systems Previous: Paperfolding and the Dragon

Turtle graphics and L-systems

 

Seymour Papert invented ``Turtle graphics'' as a system for translating a sequence of symbols into the motions of an automaton (the ``turtle'') on a graphics display (see [Pap80]; the original idea was to provide a programmable object that children could learn to think geometrically with). This turned out to be an ideal system for giving a geometrical interpretation to the dynamics of L-systems. The basic system is as follows. We fix a ``step length'' d to be the distance covered by the turtle in one step. We also set tex2html_wrap_inline5530 to be a given angle, usually tex2html_wrap_inline5532 for some integer n. Following FRACTINT's conventions, we make the following definitions.

F:
Draw forward one step in current heading
+:
Turn heading by tex2html_wrap_inline5530 counterclockwise
-:
Turn heading by tex2html_wrap_inline5530 clockwise

The reader may wish to consult the complete set of FRACTINT conventions for L-systems, which we also reproduce in a later section of these notes.

As a first example of the use of these symbols, we introduce the Koch curve L-system:

align458

Without specific productions mentioned for some symbols (in this case + and -), we assume they are constants in the sense that the implied production rule is tex2html_wrap_inline5554 . Generation 0 is just a straight line; we will assume the heading at the start is along the positive horizontal axis. We take the angle tex2html_wrap_inline5530 to be tex2html_wrap_inline5558 (in FRACTINT terminology, this convention is represented by the instruction angle=6. Geometrically, this production means replace a straight line segment F by the following arrangement of four line segments.

  figure462
Figure 10: The production for the Koch curve

In this figure, the actions taken in traversing the path are marked by the corresponding symbol in F+F-F+F. If we scale by a factor of three so that the starting and ending points of the curve remain the same, we may describe this production by saying that the middle third of the original line segment was replaced by the top of the equilateral triangle spanned by that middle third.

Some generations of the Koch curve are displayed below.

   figure468
Figure 11: Koch curve generations

The limit is a fractal curve of the type that caused some anxiety among the mathematicians (Weierstrass and others) of the nineteenth century who were at work building the rigorous foundations of the calculus. This curve is an example of a one-to-one continuous mapping of the unit interval into the two-dimensional plane which does not have a well-defined tangent line anywhere. In fact, the curve ``seems'' to be turning at an angle of tex2html_wrap_inline5564 or tex2html_wrap_inline5566 at all points.

The Koch L-system grows quite rapidly in terms of the number of line segments plotted. Since each line segment is replaced by four more at the next generation, the n-th generation has tex2html_wrap_inline5572 segments. For instance, generation 8 plotted above has 65536 segments.

Now would be an opportune time to play with the L-systems routines in FRACTINT. Choose the fractal type to be ``lsystem.'' FRACTINT will then display a set of L-system definitions, retrieved from some file, usually fractint.l. In this file may be found:

align476

The name of this L system, ``KochCurve,'' is followed by a comment (beginning with ;) indicating the creator of this L-system, a statement indicating that the angle is tex2html_wrap_inline5582 , the axiom, and the production rules. After typing the ``order'' or generation number, and pressing Enter, FRACTINT displays the resulting shape. You can press the letter z to easily change the order, and t to change the fractal type.

You may load another file of L-systems by pressing the function key F6 on a PC. This makes it possible for you to create your own L-system definitions and try them out in FRACTINT. For now, select the L-system called ``Dragon,'' given below:

align489

This is the FRACTINT L-system that realizes the Dragon Curve of the preceding section. The angle increment is tex2html_wrap_inline5592 . This L-system has two extra symbols X,Y that have no geometric meaning, that is, they are ignored when it is time to draw the desired curve. They are used to ensure the correct evolution of the drawing commands. Each line segment drawn by an F is tagged with an X or a Y symbol. So an FX segment is replaced on the next generation by two segments of each type with a left tex2html_wrap_inline5502 turn in between (specified by the ++), while an FY segment is replaced by a right turn. The tex2html_wrap_inline5610 turns at the ends ensure that all the turns between FY and FX are correctly oriented. This is a very elegant encoding of the process we described before, and it requires some checking to see that it really works. The first few generations are as follows:

 

Gen. 0 FX
Gen. 1 -FX++FY-
Gen. 2 -FX++FY-+++FX-FY+-
Gen. 3 --FX++FY-+++FX-FY+-+++-FX++FY--+FX-FY++-
Table 6: Dragon Curve Generations

Even though the number of +,-'s between segments increases, the net turn is always tex2html_wrap_inline5502 . It's an interesting exercise to design an L-system that modifies the Dragon system so that the corners are truncated slightly so that we can more easily see the path of the curve. We will see something of this nature a little later.


next up previous contents
Next: FRACTINT conventions Up: L-systems Previous: Paperfolding and the Dragon

David J. Wright
Mon Aug 19 17:21:15 CDT 1996