Fractal Simulation of Plants
Total Page:16
File Type:pdf, Size:1020Kb
Degree project Fractal simulation of plants Author: Haoke Liao Supervisor: Hans Frisk Examiner: Marcus Nilsson Date: 2020-01-29 Course Code: 2MA41E Subject: Mathematics Level: Bachelor Department Of Mathematics Abstract We study two methods of simulation of plants in R2, the Lindenmayer system and the iterated function system. The algorithm for a L-system simulates fast and efficiently the growth structure of the plants. The iterated function system can be done by deterministic iteration or by the so called chaos game. 2 Contents 1 Introduction 4 1.1 History . .5 2 L-systems 5 3 Iterated Function Systems 9 3.1 Deterministic Iteration . 10 3.2 Chaos Games . 13 4 Concluding remarks 16 3 1 Introduction Simulation of complex plant structures in nature is a popular field of com- puter graphics research [9]. In this thesis, we take the Lindenmayer systems (L- system for short) and the iterated function systems (IFS for short) as the main methods in R2. We choose Chaos and fractals [1] and The algorithmic beauty of plants [3] as the key books and study how L-system and IFS work for the frac- tals. The figures of the plants are created by Mathematica [4]. The plants can be regarded a generalization of the classical fractals. Let us introduce the fractals through 2 concepts, self similarity and Hausdorff di- mension. The objects of the classical fractals research are usually not smooth and they have an irregular geometry. A closed and bounded subset of the Eu- clidean plane R2 is said to be self-similar if it can be expressed in the form S = S1 [ S2 [···[ Sk where S1, S2 ··· , Sk are non-overlapping sets, each of which is similar to S scaled by the same factor s (0 < s < 1) [5]. The fig- ures in figure 2 are good examples to show self similarity. When it is iterated more and more times, the final figure will go towards to the Sierpinski triangle. Now we turn to the Hausdorf f dimension (also called the fractal dimension). The method of calculating Hausdorff dimension is not very easy, usually we always choose the formula for the box − counting dimension. For a bounded set a, let N(`) denote the minimum number of boxes of length ` > 0 required to cover a. Then the box dimension of a is given by [6] ln N(`) dB = lim . `!0 ln(1/`) For the classical fractals, like the Sierpinski triangle, the Hausdorff dimension is the same as the box-counting dimension. As an example, let us consider the Cantor set. Start with a segment of length 1 in figure 1. Remove the middle third and continue by removing the middle third of each segment. Figure 1: Two iterations towards the Cantor set. n 1 After iterating n times, we get 2 segments of length 3n . So ln 2n ln 2 dB = lim = n!¥ ln 3n ln 3 . The purpose of section 2 is to study the rules of plant growth by using a rewriting system. Both the edges and the nodes of the plant can be rewritten. The IFS in section 3 which is also based on iteration can be done in two ways: deterministic iteration and random iteration. We will discuss both of them and introduce some concepts like af finetransformation, contraction mapping and chaos game. 4 Figure 2: Initial triangle, one iteration (middle) and four iterations (right) to- wards the Sierpinski triangle. 1.1 History In 1872 Karl Weierstrass presented a function which is continuous but nowhere differentiable and today this function is considered as a fractal. Then the Cantor set was generated by Cantor in 1883. In 1904, Koch produced the Koch snowflake and Sierpinski showed the Sierpinski triangle in 1915. By 1918, Fatou and Julia came up with the idea of attractors. In the same year, Haus- dorff expanded the definition of "dimension" and defined what we now call the Hausdorff dimension. In the 1960s, Mandelbrot introduced the concept of self similarity and he coined the word “fractal” in 1975. The fern code developed by Barnsley is an example mentioned in his 1988 book Fractals Everywhere [2]. Lindenmayer systems, were introduced and developed in 1968 by Aristid Lin- denmayer [3]. 2 L-systems The L-system is based on a rewriting system - an object is constructed by replacing the original object step by step using a set of rules. Let us start by generating curves since it is a good way to explain the rewriting system. After that we will turn to simulation of plants. A nice way of thinking of the L- system is the so called turtle interpretation. We then see the rules as instruction for a turtle‘s trajectory. To begin with we start with a so called axiom, w, which gives the initial configuration. This can often be a length F (usually F = 1). To tell the turtle how to move a production rule, P, must be given. The turtle is allowed to move straight ahead but also turn left or right an angle d, shown with 00−00 or 00+00. Given the triplet fw, P, dg, the curve can be created. As an illustration, let us construct the snowflake curve using the turtle interpretation. For its construction only one rule is used. To keep the end 1 points fixed we scale the edges by 3 in each step. Now let the rule be F ! F + F − −F + F with the angle d = 60◦ and w = F. In figure 3 the first three iterations towards the snowflake are shown. 5 Figure 3: The initial state and the first three iterations towards the snowflake. Sometimes it is necessary to work with two types of edges, Fl and Fr, like ◦ for the dragon curve in figure 4. Here the angle d = 90 and the axiom w = Fl and the two rules are Fl ! Fl + Fr+, Fr ! −Fl − Fr. We show the first three iterations and the tenth iteration in figure 4. After two iterations the string is Fl ! Fl + Fr + Fl − Fr. Figure 4: The first three iterations and the tenth iteration of the dragon curve. Another significant aspect of rewriting systems is the node rewriting. The point where two edges meet is called a node. As for the edge rewriting, it also gives a method to create a new curve with a recursive structure. In the following example two types of nodes, L and R, are used and F is still the length step. Using the rules L ! LF + RFR + FL − F − LFLFL − FRFR+ R ! −LFLF + RFRFR + F + RF − LFL − FR and w = L and d = 90◦ will produce a space filling curve 1, see figure 5. 1The space-filling curve can be a continuous function, R ! R2, whose domain is the unit interval [0, 1] and the range has an area [8]. 6 Figure 5: One and three iterations towards the space filling curve. Both the edge and the node rewriting can be extend to branching struc- tures. To simulate growth of plants we will now turn to bracketed L-systems. The rules of a bracketed L-system also use rewriting. It also has two types of rewriting, the edge rewriting and the node rewriting and a branch is described by a bracket []. Let us start with the edge rewriting case in figure 6 where w = F and d = 22.5◦. Figure 6: The plants after one and four iterations with the rule F ! FF[− − F + F + F][+F − F − F]. An example of node-rewriting is given in figure 7 with w = X, d = 20◦. 7 Figure 7: The plants after 1, 2, 3 and 9 iterations with the rules X ! F[+X]F[−X] + X and F ! FF. Let us finish this section with some branching structures using two types of edges and/or two types of nodes. The figures of the plant simulations are shown in figure 8 with the following rules w = Fl w = L, F ! FF d = 22.5◦ d = 20◦ Fl ! Fl Fl[− − Fl][+Fr] L ! F[+F[+L]]F[−R] + R Fr ! Fl[−Fl][+Fr] R ! F[−F[−L]][+R] 8 Figure 8: The plants simulation after five iterations with two types of edges (on the left) or nodes (on the right) respectively. We generate the plants combining the edge rewriting and the node rewrit- ing in figure 9. The rules are w = L, d = 20◦, Fl ! Fl Fl[− − Fl][+Fr], Fr ! Fl[−Fl][+Fr], L ! Fl[+Fr[+L]]Fl[−R] + R, R ! Fl[−Fr[−L]][+R], . Figure 9: The plants simulation after 5 iterations with 2 types of edges and 2 types of nodes. Comparing with the plants in figure 8, it looks more dense. 3 Iterated Function Systems The iteration function system (IFS for short) can be done in two ways: deterministic iteration (section 3.1) or chaos game, also called random itera- 9 tion (section 3.2). To understand the IFS, we have to consider concepts like af fine transformation, Hausdorf f distance and contraction mapping. 3.1 Deterministic Iteration Think of a very special copy machine, the multiple reduction copy machine (MRCM for short). Starting with for example a black triangle in figure 2, it produces more than one transformation, three in the Sierpinski case. Putting again the copy in the MRCM, the outcome will be 9 small triangles, all similar to the original one. Repeating over and over again we believe we come closer and closer to the fractal. To be more mathematical we have to specify what kind of transformations are allowed and what we mean with closeness. The MRCM can be described by affine transformations, see definition 3.2 and table 1.