Fractals can be represented by means of L-systems (Development Grammars), together with a graphic interpretation. Two families of graphic interpretations have been used: turtle graphics and vector graphics. This paper describes an APL2/PC system able to draw fractals represented by L-systems, with both graphic interpretations. A theorem has been proved on the equivalence conditions for both interpretations. Another point shown is the fact that supposed deficiencies in L-systems that have prompted proposals of extensions are really deficiencies in the graphic translation scheme.
In 1890, the italian mathematician Giuseppe Peano described a certain curve, now known by his name, which displayed several monstrous properties, suchs as filling a surface (in the sense of passing through every point in it), and having a tangent at no point. Another monstrous line (the snowflake curve) was described in 1904 by Helge von Koch.
In 1919, H. Hausdorff introduced a new concept of dimension, different from the ordinary geometric dimension. According to his definition, later refined by Besicovitch, ordinary lines have a dimension of 1 and ordinary surfaces a dimension of 2, but the monstrous curves have a fractional dimension greater than 1. In fact, the Peano curve has a Hausdorff-Besicovich dimension of 2, while its value for the Koch snowflake is 1,2618595071429...
In 1975, Benoit B. Mandelbrot [Man 82] defined a fractal as an object whose Hausdorff-Besicovitch dimension is greater than its geometric dimension. Fractals have special properties, such as self-similarity (containing copies of themselves) and underivability at every point. They are appropriate for the description of natural shapes.
There are three main kinds of fractals:
In 1968, Aristid Lindenmayer [Lin 68] defined a new type of grammar (the parallel derivation grammar), which differs from the normal Chomsky grammars (sequential derivation grammars) because the grammar rules are applied simultaneously, rather than one at a time.
Parallel derivation grammars, also called L systems, can be classified in different ways:
These types may be combined: A D0L system is a deterministic context free system; a PD0L system is propagative, deterministic and context free; an EIL system is context sensitive with extensions; and so forth. A D0L system, for instance, is the three-fold (
, P, w), where
is an alphabet (a finite non-empty set of symbols); P is a set of production rules of the form A::=x, where
is a symbol in the alphabet and
is a (possibly empty) word or string of symbols in the alphabet; and
is the starting word or axiom. Every symbol appears exactly once at the left of a production rule (this makes the system deterministic).
A D0L scheme is the two-fold (
, P), of an alphabet and a set of production rules, and represents the family of all the D0L systems sharing those two components and differing in the axiom.
An example of a D0L system is:
( {F,+,-}, P, F++F++F )
where P is the following set of production rules:
F ::= F-F++F- + ::= + - ::= -
A derivation of a word in a D0L system is the new word obtained when each symbol in the first word is replaced by the right part of the production rule whose left part is that symbol. In the previous example, we can get the following derivation from the axiom:
F++F++F F-F++F-++F-F++F-++F-F++F-
The word obtained becomes the starting point of a new derivation, and so on.
L systems have been successfully applied in the simulation of biologic processes, such as plant growth, leave development, pigmentation of snail shells, etc. They are also very appropriate to represent fractal objects obtained by means of recursive transformations [Dem 85, Pru 86, Gie 91, Cul 91a, Cul 91b]. The initiator maps to the axiom of the L system, the generator to the production rules, and the recursive applications of the generator to the initiator correspond to the successive derivations of the axiom.
Something else is needed, however: a graphic interpretation that makes it possible to convert each word generated by the L system into a visible curve. The fractal object is the limit of the sequence of curves generated by the L system with the appropriate graphic interpretation.
It is very important to separate the L system from the graphic interpretation. Otherwise, a deficiency in the latter may be mistaken for one in the former. In the past, different extensions have been proposed for L systems, supposedly incapable of generating certain fractal objects, which a different graphic interpretation would make it possible to obtain.
Two different families of graphic interpretations of L systems have been used:
Created by Seymour Papert in 1980, the graphic is the spoor left by a moving invisible turtle, with a state defined by its position and the direction it is looking at. The state of the turtle may change as it moves a step forward, or as it rotates a given angle in the same position.
In the simplest turtle graphics interpretation, the alphabet of a D0L system consists of three symbols:
= {F, +, -}
The graphics interpretation of a word is as follows:
.
.
Additional rules complicate the turtle graphics and make it possible to generate more complicated fractals. Between those rules, we will mention the following:
A given fractal may be represented by means of three components: an L system, a turtle graphic interpretation (made up of a combination of the preceding rules), and an angle step.
In this family of interpretations, every symbol in the alphabet of the L system is associated to a vector in a rectangular cartesian system. A word (a string of symbols) is represented by the catenation of the vectors of the symbols that make the word.
In the simplest case, a fractal may be defined by two components: an L system, and a mathematical application
(the vector interpretation). We assume that all the vectors associated to the symbols in the alphabet generate visible movements. The graphic representation of each derivation of the L system is a set of straight connected segments.
This vector interpretation is capable of representing branching fractals, if for every symbol in the alphabet there is another associated to the opposite vector, which makes it possible to return to the start of the branch. However, a different vector interpretation is needed to build unconnected fractals. These can be covered by means of the following mathematical application:
In this case, the vector equivalent to a symbol has three elements instead of two: a visibility coefficient (0 or 1) is added, indicating that the vector displacement should be visible (a 1) or invisible (a 0).
A system has been implemented in APL2/PC to experiment with fractals using different graphic interpretations. A fractal scheme is represented by a 3-element vector (additional elements in vectors are considered to be comments):
The 0L scheme is represented by the set of production rules (a matrix of two columns), from which the alphabet may be deduced (it is the set of all the symbols appearing in the rules). The rules have the following structure:
A (x)
where A is a symbol in the alphabet, x is a word and the parentheses represent general array depth. The set of all the rules is a two-column matrix.
A ()
i.e., its right part is the empty word.
A ((x y ...)) where x, y, ... are words.
A (x1 x2 ...)where x1, x2, ... are words.
A ((x1 y1 ...) (x2 y2 ...) ...)where x1, y1, ... are words.
At this time, the graphic representation may be one of the following:
The additional information is the following:
The system includes a set of functions performing the following actions:
A x1|y1|...[ x2|y2|...]
to represent all kinds of [T][P][D]0L schemes.
The fractal schemes created may be kept in a file of APL objects using the AP211 auxiliary processor. The steps to the fractal curve are drawn using the AP207 VGA graphics auxiliary processor.
The examples given below have been designed by different authors and are common in the literature.
F ::= F-F++F-
+ ::= +
- ::= -
with axiom F++F++F, a turtle graphic interpretation, and a step angle of 60 degrees, generates the Koch snowflake curve, whose fifth iteration appears in figure 1.
In our system, it is not necessary to give the rules for symbols in the set {+, -, (, ), !,{}} , which usually remain invariable. This means that the last two rules in the preceding L-scheme may be omitted. In the following examples, these rules will not be written, but are always assumed to be there, as they will be automatically added by the program.
A ::= AFBA
B ::= BACB
C ::= CBDC
D ::= DCED
E ::= EDFE
F ::= FEAF
with axiom ACE, a vector graphic interpretation and the following two column vector definition:
ÚÎÎÎÎÎÎÂÎÎÎÎÂÎÎÎÌ
ÛSymbolÛ X Û Y Û
ÃÎÎÎÎÎÎÏÎÎÎÎÏÎÎÎÝ
Û A Û 1 Û 0 Û
Û B Û 0.5Û r Û
Û C Û-0.5Û r Û
Û D Û-1 Û 0 Û
Û E Û-0.5Û-r Û
Û F Û 0.5Û-r Û
ÀÎÎÎÎÎÎÁÎÎÎÎÁÎÎÎÙ
where r is one half of the square root of 3.
A ::= AF+F+BF-F-AF-F-BF-F-AF+F+BF+F+AF+F+BF-F-A
B ::= BF-F-AF+F+BF+F+AF+F+BF-F-AF-F-BF-F-AF+F+B
F ::= F
where {A, B} is the set of non-graphic symbols, with axiom AF, a turtle graphic interpretation, and a step angle of 45 degrees, generates the Peano plane-filling curve, whose third derivation appears in figure 2.
A ::= FQAPASH P ::= P
B ::= GRBQBPE Q ::= Q
C ::= HSCRCQF R ::= R
D ::= EPDSDRG S ::= S
E ::= DSEPEQB
F ::= APFQFRC
G ::= BQGRGSD
H ::= CRHSHPA
with axiom A, a vector graphic interpretation and the following two column vector definition:
ÚÎÎÎÎÎÂÎÎÎÂÎÎÎÂÎÎÎÎÎÂÎÎÎÂÎÎÎÌ
ÛSymb.Û X Û Y ÛSymb.Û X Û Y Û
ÃÎÎÎÎÎÏÎÎÎÏÎÎÎÏÎÎÎÎÎÏÎÎÎÏÎÎÎÝ
Û A Û 0 Û 0 Û G Û 0 Û 0 Û
Û B Û 0 Û 0 Û H Û 0 Û 0 Û
Û C Û 0 Û 0 Û P Û 1 Û 0 Û
Û D Û 0 Û 0 Û Q Û 0 Û 1 Û
Û E Û 0 Û 0 Û R Û-1 Û 0 Û
Û F Û 0 Û 0 Û S Û 0 Û-1 Û
ÀÎÎÎÎÎÁÎÎÎÁÎÎÎÁÎÎÎÎÎÁÎÎÎÁÎÎÎÙ
generates the Hilbert curve whose sixth derivation appears in figure 3.
F ::= FfF
f ::= fff
with the default sets of drawing and moving symbols, axiom F, a turtle graphic interpretation, and a step angle of any value, generates the Cantor set of the third order, whose axiom and first five derivations appear in figure 4.
A ::= ABA
B ::= BBB
with axiom A, a vector graphic interpretation and the following three column vector definition:
ÚÎÎÎÎÎÂÎÎÎÂÎÎÎÂÎÎÎÌ
ÛLetraÛVisÛ X Û Y Û
ÃÎÎÎÎÎÏÎÎÎÏÎÎÎÏÎÎÎÝ
Û A Û 1 Û 1 Û 0 Û
Û B Û 0 Û 1 Û 0 Û
ÀÎÎÎÎÎÁÎÎÎÁÎÎÎÁÎÎÎÙ
F ::= FF+(+F-F-F)-(-F+F+F)
with axiom F, a turtle graphic interpretation, and a step angle of 22.5 degrees, generates the branching fractal curve, whose fourth derivation appears in figure 5.
A ::= F-(A+A)+F(+FA)-A
F ::= FF
where {A, F} is the set of drawing symbols, with axiom A, a turtle graphic interpretation, and a step angle of 22.5 degrees, generates the fractal whose fifth derivation appears in figure 6.
This is very similar to the fractal that moved P. Prusinkiewicz [Pru 86] to propose an extension to 0L systems (pL systems), assuming that the former were not powerful enough to handle it. In fact, Prusinkiewicz fractal can be obtained by enclosing every A between additional parentheses in the preceding PD0L scheme. This indicates that his assumption was unwarranted, as an appropriate extension to the graphic interpretation is sufficient to overcome the difficulty.
F ::= FF
G ::= G
L ::= ({+G-G-G+!+G-G-G})
R ::= F(--L)(++L)F
T ::= R+(T)--(--L)R(++L)-(T)++T
where {F, G} is the set of drawing symbols, {L, R, T} is the set of non-graphic symbols, with axiom T, a fully extended turtle graphic interpretation, and a step angle of 30 degrees, generates the fractal whose fourth derivation appears in figure 7.
This is another of the fractal curves supposedly requiring an extension to D0L systems.
F ::= F-F++F- | F+F--F+
with axiom F++F++F, a turtle graphic interpretation, and a step angle of 60 degrees, is a non-deterministic variant of the Koch snowflake curve. A possible fifth iteration (depending on the random seed used) appears in figure 8.
If the first alternative were always applied, we would obtain the snowflake curve of figure 1.
The second alternative would generate a variant of the same curve, with the direction of the generator inverted. It may be seen that this drawing reminds the coastline of an island or a continent. However, it is a little too complicated, due to the fact that its Hausdorf-Besicovich dimension is (approximately) 1.26, while the dimension of real coastlines uses to belong to th interval 1.15 to 1.25.
A ::= AFBA A ::= ABFA
B ::= BACB B ::= BCAB
C ::= CBDC C ::= CDBC
D ::= DCED D ::= DECD
E ::= EDFE E ::= EFDE
F ::= FEAF F ::= FAEF
where the first table is the set of productions used above to generate the Koch snowflake, while the second table inverts the direction of the fractal generator, produces a curious variant of the snowflake whose fifth iteration may be seen in figure 9.
A ::= ABB
B ::= BC
C ::= CD
D ::= DAC
with axiom CCCC, a vector graphic interpretation and the following two column vector definition:
ÚÎÎÎÎÎÂÎÎÎÂÎÎÎÎÎÌ
ÛLetraÛ X Û Y Û
ÃÎÎÎÎÎÏÎÎÎÏÎÎÎÎÎÝ
Û A Û 8 Û 0 Û
Û B Û 0 Û 0.75Û
Û C Û-4 Û 0 Û
Û D Û 0 Û-0.75Û
ÀÎÎÎÎÎÁÎÎÎÁÎÎÎÎÎÙ
generates a fractal curve whose tenth derivation is uncannily similar to a human hand (see figure 10 ).
Since we have two different graphic interpretations for L systems (turtle graphics and vectors) the question of the possible equivalence of both interpretations jumps to the mind. In other words: given a fractal represented by an L system with turtle graphics, can we represent the same fractal by another (usually different) L system with vector graphics? In fact, in the preceding examples, we have shown that the same fractal may be obtained by means of totally different L systems, each of which uses a different graphic interpretation.
We have proved a theorem that can be considered as a first approach to the demonstration of full equivalence, which states:
, where
is the turtle incremental angle.
In a computer, the first condition is always in effect, since the turtle incremental angle is a rational number (one cannot store irrationals in a computer). Therefore, in practice, the only restrictions are the last two. The theorem, such as stated, seems to imply that turtle graphic interpretations are more powerful than vector graphics.
Our proof of the theorem is a constructive algorithm that, starting from an L system of one kind, generates an equivalent system of the other kind. In fact, the vector graphics L-system that generates the Koch snowflake curve shown in the examples, was obtained from the equivalent turtle graphics L-system, using our algorithm.
We have seen that D0L systems, given an appropriate graphic interpretation, are quite powerful to represent large families of fractal curves, even some that previous authors had assumed required nonstandard extensions.
It is thus important to isolate the D0L system from its graphic interpretation, which can be very different and belong either to the turtle or the vector family.
We have also proved a fractal equivalence theorem between L systems associated with a subset of turtle graphics and those associated with vector graphics.
Manuel Alfonseca
Professor at the Universidad Autonoma of Madrid
Escuela de Ingenieria Informatica
Universidad Autonoma de Madrid
Ciudad Universitaria de Cantoblanco
28049 Madrid SPAIN
Telephone: (34) 1 397 4467; Fax: (34) 1 397 5277
Email: Manuel.Alfonseca@ii.uam.es
and Alfonso Ortega, Ph.D. student at the Universidad Autonoma of Madrid.