• Keine Ergebnisse gefunden

Plant Modelling

L- system rule application

interpretation by turtle

Figure 2.5.: Schematic representation or the functioning of a classical L-system using a two-stage process with turtle interpretation. The rules are applied to the start symbolα(axiom) and afterwards graphically interpreted by the turtle to obtain the final 3-d structuresS1, S2, . . . Cartesian coordinate system which is controlled by commands. Each symbol of the alphabet will be interpreted according to a defined ‘translation’ as shown in Tab.2.2. A turtle has three attributes: 1) a location, 2) an orientation, and 3) a pen, itself having attributes such as colour, width, etc. For a complete list of turtle commands refer to Prusinkiewicz and Lindenmayer (1990). The set of turtle commands becomes a subset of the alphabet of the L-system. Symbols that are not turtle commands will be ignored by the turtle during interpretation. In computer graphics, turtle geometry is classified as vector graphics (system).

Table 2.2.: Interpretation of turtle commands in 2-d (extract).

F Move the turtle forward by one step of lengthdand

draw a line. F

+ −

f Move the turtle forward by one step of lengthd.

+ Turn the turtle anticlockwise around its UP vector.

- Turn the turtle clockwise around its UP vector.

The turtle can be described by a triple(x, y, α)in 2-d wherexandyrefer to the Cartesian coor-dinates - the position the plane - andαdefines the angle/direction of movement. By adding the Z-axis and two additional angles the turtle geometry can be extended to the three-dimensional space.

Example: Koch curve, Koch (1906) Alphabet : P

={F,+,−}

Axiom : α=F

Rules : ∆ ={F →F +F − −F+F} The first four derivation steps are given below:

Step Derivation chain ] F ]+/−

0 F 1 0

1 F+F−−F+F 4 4

2 F+F− −F+F+F+F− −F+F−−F+F− −F+F+F+F− −F+F 16 20 3 F+F− −F+F +F+F− −F+F − −F+F− −F+F +F+F− −F+F+ 64 84

F+F− −F+F +F+F− −F+F − −F+F− −F+F +F+F− −F+F−−

F+F− −F+F +F+F− −F+F − −F+F− −F+F +F+F− −F+F+

F+F− −F+F +F+F− −F+F − −F+F− −F+F +F+F− −F+F

4 … 4n4/3(1−4n)

F

F F

F +

−−

+

Figure 2.6.: Turtle interpretation of ‘F +F − −F +F’. When the base angle δ is set to 60 degrees it yields the first step of the Koch curve, (Koch1906).

The (illustrated) interpretation of the first derivation stepF+F− −F+F is given in Fig.2.6 for the base angleδ= 60 degrees. In words: draw a line of lengthd, turn the viewing direction about 60 degrees clockwise. Draw another line and turn the turtle twice about 60 degrees anti-clockwise. Draw one more line before the turtle is turned the last time clockwise, and the final

n= 3 n= 6

Figure 2.7.: Graphical interpretation of the 3rd and 6th derivation step of the Koch curve.

line is drawn. The graphical interpretations of the 3rd and 6th derivation step are given in Fig.2.7.

By only changing the initial state from a single stroke to an isosceles triangle and keeping the rules and the base angleδthe same, the so-called ‘Koch snow flake’ (Fig.2.8) can be obtained.

Figure 2.8.: The ‘Koch Snow flake’; left, the initial triangle; right, the graphical interpretation of the 4th derivation step.

When it comes to the three-dimensional space the location of the turtle can be defined by a triple(x, y, z)wherex,y andzrefer to the Cartesian coordinates. To define the orientation of the turtle three angles are needed: one for tilting, one for inclining and one for turning, the so-called Euler angles or roll-pitch-yaw angles. In terms of turtle commands this refers to rotating around the left-, up-, and head-axis, respectively calledRL,RU, andRH. In Fig.2.9 these rotations are demonstrated with a box object.

Figure 2.9.: Rotations of a box in 3-d around the origin. Starting with the default situation in the middle (z-axis matches the head-axis) rotations of 10 degrees are performed around each axis.

The turtle interpretation was later further extended by Prusinkiewicz (1987) to allow for incor-porating predefined curved surfaces in the model.

2.1.5.5. Bracketed L-Systems

With the L-systems defined so far, it is only possible to create simple unbranched structures.

An important extension that allows the representation of branched structures are bracketed L-systems. By introducing a stack, the current state of the turtle can be pushed on a stack and later be popped from the stack to make it the current turtle state again. Therefore, the alphabet needs to be extended by two symbols: an open square bracket ‘[’ and a closing square bracket ‘]’. While ‘[’ represent the pushing (storage) of the current turtle state onto the stack,

‘]’ induces the popping (recovery) of the first state from the stack and its use as the new state of the turtle.

Example: A simple 2-d branching structure.

Alphabet : P

={A, B, F,+,−,[,]}

Axiom : α=A

Rules : ∆ ={A→F[−B][+B]A, B →F B}

Derivation chain:

A → F[−B][+B]A

→ F[−F B][+F B]F[−B][+B]A

→ F[−F F B][+F F B]F[−F B][+F B]F[−B][+B]A

→ …

One graphical interpretation of the symbols (cf.turtle geometry) and the derivation chain is given in Fig.2.10.

A: B: F:

=

=

0 1 2 3 4 step

Figure 2.10.: Graphical interpretation of the symbols and the first four derivations steps of a simple branching structure.

a) b) c)

n=4 n=7 n=6

δ = 22.5° δ= 25.7° δ= 22.5°

α=F α=X α=X

F F F[−F+F+F] XF[+X][−X]F X XF[[X] +X] +F[+F X]X

+ [+FFF] FF F FF F

Figure 2.11.: Examples of plant-like structures generated by bracketed L-systems (Prusinkiewicz and Lindenmayer1990).

This small extension of the formalism already allows to generate very simple but plant-like structures (Fig.2.11), which are, however, too regular to look realistic. To overcome this de-ficiency, further extensions are needed, e.g.,context-sensitive L-systems,stochastic L-systems andparametric L-systems.

2.1.5.6. Context-Sensitive L-Systems

With the current definition of L-systems (Sec.2.1.5.3) only one single symbol is allowed on the left-hand side of a rule. It is not possible to take any context into account for a rule to be applied. Therefore, such L-systems are calledcontext-freeL-systems.

To take a left and right context of a symbol into account, the former definition of context-free L-systems needs to be slightly changed with respect to the definition of∆. The resulting L-systems are calledcontext-sensitiveL-systems.

A context-sensitive L-system is thus a formal grammar which can be defined by a tripleG= (Σ, α,∆):

• Σ, a not empty, finite set of symbols called alphabet,

• α∈Σ+, an initial string called ‘axiom’,

• ∆, a set of production rules:∆⊆Σ+×Σ.

Now the left-hand side of a rule consists of a left context, the symbol to be replaced, and a right context. A context-sensitive production rule, therefore, looks also for the symbols on the string appearing before and after the symbol that it is going to modify. For instance, the production rule:

a < b > a⇒c

will replace ’b’ by ’c’ if and only if ’b’ is surrounded by two ’a’ in the input string.

Similar to context-free L-systems, a symbol is not changed and taken over to the next derivation step if no rule can be applied. In case several rules can be applied to a symbol, the rule with the longest left-hand side is assumed to take precedence.

The Chomsky hierarchy of formal languages (Chomsky1956) orders these formal languages according to their ‘power’. In contrast to L-systems where the rules are applied in parallel and simultaneously replace all characters of a given word, in Chomsky grammars rules are applied sequentially. The languages produced by context-free and context-sensitive L-systems can be included in the Chomsky hierarchy (Fig.2.12) but they will overlap with the Chomsky classes.

For example, there are languages which can be generated by context-free L-systems but not by context-free Chomsky grammars (Prusinkiewicz and Lindenmayer1990).

IL

Recursively enumerable