L-System Aristid Lindenmayer (1968), biologist. L-System A method of constructing a FRACTAL that is...

28
L-System Aristid Lindenmayer (1968), biologist

Transcript of L-System Aristid Lindenmayer (1968), biologist. L-System A method of constructing a FRACTAL that is...

L-System

Aristid Lindenmayer (1968), biologist

L-System

A method of constructing a FRACTAL that is also a MODEL for plant growth.

The Computational Beauty of Nature – Gary William Flake

Fractal graphics

Plant model

L-System

L-systems use an AXIOM as a starting STRING and ITERATIVELY apply a set of PARALLEL string substitution rules to yield one long string that can be used as instructions for drawing the fractal.

Production systems

String : concatenation of alphabets (symbols).Axiom : the first initial symbol(s).Production rules : the description of how one string of symbols generate another.

An example

Alphabets: a, bAxiom: b

Rules: a -> abb -> a

Test the generation

Step Result

0 b

1 a

2 ab

3 aba

4 abaab

5 abaababa

6 abaababaabaab

Another example

Alphabets: a, bAxiom: b

Rules: a -> bab -> ab

Test the generation

Step Result

0 b

1 ab

2 baab

3 abbabaab

4 baababbaabbabaab

Terminal and non-terminal symbols

We can use lower and UPPER case alphabets to represent the terminal and non-terminal symbols.

Terminal symbols are those need no further expansion. Non-terminal symbols are those can further expand using the production rules.

Terminal and non-terminal symbols

Rules: A -> bA -> bA

In this case, A is a non-terminal symbol; b is a terminal symbol. The rules state that A can generate b and stop. A can also expand to bA where the A on the right hand side can expand again using the two rules.

Terminal and non-terminal symbols

Rules: A -> b (terminal)A -> bA (non-terminal)

The results will be,b, bb, bbb, bbbb, …

Remember the regular expression last time, bb*

Exercise time

Alphabets: A, a, bAxiom: ARules: A -> ab (terminal)

A -> aAb (non-terminal)

Let’s see what can be generated.

Answer

Step Result

0 A A

1 ab aAb

2 aabb aaAbb

3 aaabbb aaaAbbb

4 aaaabbbb aaaaAbbbb

5 aaaaabbbbb aaaaaAbbbbb

Language

Remember that the Finite State Automata can generate a language we called Regular Expression.

The L-system can also generate another language we named Context-Free language.

Language

According to Noam Chomsky, there are 4 types/hierarchies of Formal Language. We have learnt the,• Regular expression,• Context-free language.

There are two more, namely the,• Context-sensitive language,• Unrestricted language.

Production rules

Regular expression uses the rules,A -> b or A -> bC;

While Context-Free language uses the rules like,A -> α;where α is any string of both terminal and non-terminal symbols.

Simple exercise

Alphabets: F, -, +Axiom: FRules: F -> F + F - - F + F

We have only one production rule with the symbol F. Let’s see what happens.

Any meaning?

We have not touched on any ideas about meaning – semantics yet. The language we generated is pure syntactic.

We can, however, assign external meaning to the symbols and see what happens.

Any meaning?

Any meaning?

Any meaning?

The meaning

Now we assign meaning to the symbols.F : draw a line segment forward+ : turn anti-clockwise 60°- : turn clockwise 60 °

The rule F -> F + F - - F + F will become:

The meaning

F

F F

F+

- -

+

Turtle graphics

That is the Turtle Graphics (Logo) we learnt in primary school. The commands are,

Command Turtle action

F Draw forward by a fixed length.

f Move forward by a fixed length.

+ Turn anti-clockwise by a fixed angle.

- Turn clockwise by a fixed angle.

[Save the current location and orientation.

]Restore the last saved location and orientation.

L-system applet

Try to create the graphics using the applet at

http://www.cs.utah.edu/~jshepher/java/Lsystems/Lsystems.html

Exercise time

Can you figure out the rule for this plant?