Fractint L-System Variations

A tutorial by William McWorter
version 1.4
January 1997

Back to Tutorial Index


When Benoit B. Mandelbrot described Heighway's Dragon in his out-of-print book Fractals: Form, Chance, and Dimension, He pointed out that the curve does not cross itself but it does touch itself. To create a curve that does not touch itself, he suggested connecting the midpoints of the segments in the Dragon with line segments. He called such curves median curves.

Median L-systems can be made by modifying an existing L-system. For example, to create an L-system for FRACTINT to draw the median of Heighway's Dragon, look at the order 1 Dragon and its median.

The Dragon itself is a horizontal line pointing East followed by a vertical line pointing North. The median, which joins the midpoints of these line segments is a line oriented Northeast. This suggests the script below.

Hiwaymed {
  Angle 8  ; Smallest turn is 45=360/8 degrees
  Axiom -X ; Turn whole thing 45 degrees so that all lines of X are horizontal or vertical
  X=X+F+Y  ; Do X, turn left, forward, turn left, do Y
  Y=X-F-Y  ; Do X backwards

(drawing of Heighway's Dragon median using the displayed script)

Notice that this script is very close to that for Heighway's Dragon. Instead of X=FX+FY, we have X=X+F+Y; FX is replaced by just X and + (turn 90 degrees) is replaced by +F+ (+= turn 45 degrees).

Hilbert's spacefilling curve is also a median L-system. It joins the centers of adjacent squares with a line segment rather than joining midpoints of line segments.

(drawings of Hilbert's curve at orders 1, 2, and 3 with the underlying squares)

The pictures above display Hilbert's curve at orders 1, 2, and 3. For each picture the curve begins at the center of the upper left square and ends at the center of the upper right square. The curve joins the centers of adjacent squares. How did Hilbert decide in what order to traverse the squares? Look at the order 2 curve above. The upper left four squares are traversed the same way as the mirror image of the order 1 curve oriented down so that FRACTINT is in position to traverse the lower left four squares. These four squares are traversed as in the order 1 curve oriented horizontally. In this way FRACTINT is in position to traverse the lower right four squares the same way as the lower left four were traversed. This leaves FRACTINT in position to traverse the upper right four squares as the mirror image of the order 1 curve. If you now examine the order 3 curve, you'll see that the same traversing plan is used, begining with the upper left 16 squares and ending with the upper right 16 squares, each group of squares traversed according as the order 2 curve dictates. Here is an L-system which implements this median curve.

Hilbert {       ; Ken Philip, from The Science of Fractal Images
  axiom x
  x=-YF+XFX+FY- ; cup interior on left during trace
  y=+XF-YFY-FX+ ; cup interior on right during trace
  angle 4

The x represents tracing the curve one way and y represents tracing the curve the opposite way.

The L-systems Fass1 and Fass2 in the file fractint.l are also median curves based on dissecting a square into 9 and 16 squares, respectively.

As another example of a median curve, consider the dissection of an isosceles right triangle into two isosceles right triangles.

(drawing of isosceles right triangle dissected into two triangles with median)

Here is an L-system to draw this curve.

Sierpinski {
  Angle 8
  Axiom L--F--L--F

(drawing of Sierpinski)

This picture is very close to that produced by Peano2 in fractint.l. However, I believe that this curve is due to Sierpinski rather than Peano, although I could be wrong.

As a final example of a median curve based on a dissection, here is one using a dissection of a 30-60-90 degree triangle dissected into three such triangles. The curve joins the centers of consecutive triangles with a line segment.

Lace { 
  ; A 30-60-90 triangle dissects into three
  ; congruent 30-60-90 triangles
  ; This script traverses the centers of the congruent triangles
  Angle 12
  Axiom w

(drawing of Lace using the displayed script)

Sometimes you may want to combine a system and its median. For example, to "round off" the corners of Heighway's Dragon so that one can see how the Dragon is traced, look at the script below.

Dragonrnd {
  Angle 8
  Axiom X

Look at the replacement string for X. FX draws the first half of Heighway's dragon. This is followed by a left turn of 45 degrees and a half-length line forward followed by restoring the original line length, another left turn, and finally, draw the second half of the Dragon.

The replacement strings for X and Y have the elements of both Heighway's dragon and its median. The extra symbol Z is there because we don't want to lose the F's for the median part of the script but we do want to lose the F's adjacent to X and Y. The symbol Z keeps replacing the middle F's that the line "F=" removes.

Although L-systems whose graphic objects are only line segments don't usually have the visual impact that other kinds of fractals do, there are some things you can do with them to improve their looks. By replacing some f's with g's in a given L-system, you can sometimes create interesting patterns. For example, here is an L-system for Heighway's Dragon yet again with half of its line segments missing.

DragonCurd { 
  Angle 4
  Axiom su

Another thing you can do is string L-systems together to form an attractive border around something.

For example, the script below creates a border. This one creates a closed string of copies of the Cross curve.

Border1 { ; William McWorter
  Angle 4

Still another thing you can do is have the colors of the line segments depend on `when' it is drawn. The script below modifies an L-system to include color changes. The string "<1" means "use next color in the color palette".

Since the color of a line segment is a function its position in the tracing order rather than a function of the design of the L-system, interesting things can happen. This L-system looks best when drawn at a high order. Note that the patterns of color are evenly spaced yet there seems to be no visible regularity.

Xmastree { 
  Angle 10
  Axiom ++p  ; The +'s are there to make the tree stand upright

On to The next chapter or back to the Tutorial Index

Back to The Fractint Home Page. or back to The Fractint Index Page.

This page maintained by

Noel Giffin,