The LinF Specification

L-Systems are formal string rewriting systems introduced in 1968 by the botanist Aristid Lindenmayer that are used to model fractal images. LinF allows the definition of L-Systems that represent three-dimensional fractals and stochastic fractals.

LinF is a simple language used to describe 3D L-Systems to be interpreted according to the turtle method. A program in LinF is formed by six blocks, none of which are mandatory although it is not possible to generate fractals if some of them are missing. These six blocks are called angles, lines, blanks, axiom, rules and colors. There is no order in which the blocks should appear in a LinF program. A short description of each block is given next:

The LinF Interpreter

Before understanding how fractals are represented with the LinF formalism, it is worthwhile to comprehend the nature of a basic LinF interpreter. The LinF interpreter is a program that generates fractal figures based on the LinF description of the fractal structure. In this section will be described the structure of cFleo, a simple LinF interpreter developed in C, whose schematic view can be seem below:

The LinF Implementation

The LinF interpreter can be divided into three main constituents: the parser, the evaluator and the rendering machine. The parser is responsible for recognizing the correctness of a LinF file and retrieving from it the meaning of the user-defined symbols, for instance, the name of lines, blanks and angles.

The next component of cFleo is the evaluator. This program is responsible for applying the production rules over the axiom of the fractal and then over the successive strings obtained by the application of the rules. A production rule is formed by two parts. The left side symbol and the right side sequence of symbols. To apply a rule over a string traditionally means to substitute every occurrence of its left side that appears on the string for its right side.

In addition to the simple scheme for defining rules, LinF permits the bounding of some rules to a probabilistic chance of occurrence. This means that during the string evaluation, some symbols which are the left side of a production rule may not be expanded. This pattern of evaluation allows the creation of stochastic L-Systems that are useful to model real entities such as rivers and plants.

The last constituent of cFleo is called the rendering machine. The rendering machine is responsible for displaying the fractal that is represented by a string. In order to implement this part of cFleo, it was used the OpenGL library. This machine has always a state that is represented by the tuple (position, frame, length, color). During the rendering process, the state is continuously being updated while the segments that constitutes the fractal are being drawn according to the state elements. The meaning of each one of the four state elements is described below:

The LinF interpreter keeps processing the fractal string in a circular fashion in which firstly the string is expanded by the evaluator and next it is read by the rendering machine, which uses it to display a graphical representation of the fractal in a window. The string that represents a fractal contains symbols that force updates into the rendering machine state during the evaluation process. The semantics of each such symbol is explained in the next section.

Representation of Fractals in LinF

LinF, as an L-System-based formalism, allows fractals to be described by strings that contain finite sequences of symbols. These symbols can be terminals, non-terminals, numbers and reserved words of LinF. LinF has nine reserved symbols that are explained below: