Simulation of Sierpinski-Type Fractals and Their Geometric Constructions in Matlab Environment
Total Page:16
File Type:pdf, Size:1020Kb
WSEAS TRANSACTIONS on MATHEMATICS Zhiyong Zhu, Enemi Dong Simulation of Sierpinski-type fractals and their geometric constructions in Matlab environment Zhiyong Zhu* Enemi Dong Northwest A&F University Northwest A&F University College of Science College of Science Taicheng Road 3, 712100 Yangling Taicheng Road 3, 712100 Yangling China China [email protected] [email protected] Abstract: Study on properties of Sierpinski-type fractals, including dimension, measure, connectedness, Lipschitz equivalence, etc are very interesting. Although there have been some very nice results were obtained, there is still a long way to go to solve all the problems. In order to facilitate understanding of these results and further study, in this paper, we simulate this kind of fractals and their geometric constructions in Matlab environment that is more easily understood and mastered for researcher base on the recursive and iterative algorithms that are used to simulate fractals. Furthermore, our results are also interesting results to enrich the theoretical and applied research of fractal simulation. Key–Words: Sierpinski gasket-type fractal, Sierpinski carpet-type fractal, Fractal simulation, Recursive algorithm, Iterative algorithm, Matlab 1 Introduction have aroused wide concern ([2,4,7-10,13-16,18-21]). ≥ D ⊂ f − g2 Although there have been some very nice results were For an given integer n 2, let 0; : : : ; n 1 . obtained, there is still a long way to go to solve all We shall call the unique non-empty compact subset ⊂ R2 the problems. It is well know that the in-depth analy- ED satisfying the following set equation sis and understanding of topological structure of frac- tals are very important to study properties of fractals. ED = (ED + D)=n In this process, simulate the fractal and its geometric a Sierpinski carpet-type fractal throughout this construction by computer, will provide us the most in- paper. If the above set f0; : : : ; n − 1g2 is re- tuitive discussion and explanation. The computer sim- placed by ∆ = fk α + k β : k + k ≤ ulation of fractal patterns is based on the basic theory 1 2 1 2 of fractal, is one of the most popular area of study in n − 1 and k1; kp2 2 N [ f0gg;where α = (1; 0) computer graphics at present. Study the algorithms and β = (1=2; 3=2), then we call ED a Sierpinski and programs of drawing fractal not only can offer gasket-type fractal. In particular, for n = 3, D = technical support for the study of fractal theory, but f(0; 0); (1; 0); (2; 0); (0; 1); (2; 1); (0; 2); (1; 2); (2; 2)g 2 also can stimulate creative inspiration, to further en- ⊂ f0; 1; : : : ; n − 1g , ED is well-known rich the content of computer graphics, and also can Sierpinski carpet,p and for n = 2, D = drive a lot of old discipline in newborn. For exam- f(0; 0); (1; 0); (1=2; 3=2)g ⊂ ∆, ED is well- ple, the complex analysis don’t obtain further devel- known Sierpinski gasket. Let I = [0; 1]2 or be the opment for many years, until the computer graphics following set display completely the complex structures of Julia set, the mathematical theory of this discipline was once fc1α + c2β : c1 + c2 ≤ 1 and 0 ≤ c1; c2 ≤ 1g: again leap development. At present, although many 1 k+1 works(computer programming) have been devoted to We define ED = (I + D)=n, and recurrently, ED = k k the study of the computer simulation of Sierpinski- (ED + D)=n for k ≥ 1. Then ED is a union of k type fractals, especially the classic Sierpinski carpet squares(equilateral triangles) of side 1=n . Clearly, and Sierpinski gasket [1, 5, 11, 17], these source codes k+1 ⊂ k \1 k ED ED and ED = k=1ED. of computer programs that we saw in these works are In recent years, study on properties of Sierpinski- mostly written by the programming language: Java, type fractals described as above, including dimension, C++, Delphi, Java, etc. Thus these works are usually measure, connectedness, Lipschitz equivalence, etc E-ISSN: 2224-2880 992 Issue 10, Volume 12, October 2013 WSEAS TRANSACTIONS on MATHEMATICS Zhiyong Zhu, Enemi Dong not easy to be understood and applied for researchers 2 Some basic facts and concepts to engage in mathematics study, unless have the cor- responding knowledge of programming language. In 2.1 Function M-files addition, since the majority of these works came from For simple problems, entering your requests at the the researchers and engineering and technical person- Matlab command window prompt is fast and efficient. nel that engage in the fields of computer graphics and However, as the number of commands increases or digital image processing etc, thus these works usually trial and error is done by changing certain variables tend to ignore mathematical problems in study, and or values, typing the commands over and over at the focus on the design and the realization of computer Matlab command window prompt becomes tedious. algorithms of drawing fractal. So the different fine k k+1 To get around this, we enter the commands into a text structures of ED and ED mentioned as above can’t file (called M-files or Script M-files [12]), and exe- well described by these works on one hand, but on the cute them by simply typing filename at the Matlab other hand we also can’t easy to obtain any Sierpinski- command window prompt. All function M-file names type fractal pattern is what we need in the study only must end with the extension ‘.m’ (e.g. test.m). Func- by modifying a few parameters. But these contents tion M-files are like Script M-files but can pass param- just are the most important for researchers of studying eters and isolate variables. The structure of a typical the properties of such fractals. How to use a popular function M-file, say my fun.m, is as follows: and easy-to-understand way as much as possible, in function[output arguments]=my fun(input argu- a real-time information exchange interface, such that ments) the researchers can well-obtain any pattern is what they need in the study of a class of fractal patterns code by modifying a few parameters, without need to know ...... much about the knowledge of complex programming code language, at the same time complete some relative ...... functions such as color adjustment, graphical compar- Note that the word function appears at the start of the ison and storage etc, and generate fractal patterns with file. In addition, the output arguments and input argu- certain theoretical research value, has turned into one ments and name of the function are listed. If a func- of the hot problems concerned by many researchers. tion only has a single output argument, then the square For this motive and note that the powerful advan- brackets are not required. If a function does not have tages of Matlab in numerical calculation and graphic any output arguments, then neither the square brackets visual ability and its programming language is more nor the equals sign that follows are used. easily understood and mastered by mathematical re- searchers. In this paper, we study the simulation of the above-mentioned Sierpinski-type fractals and their 2.2 Recursion Theory geometric constructions in Matlab environment base Recursion is the process of repeating items in a self- on the recursive theory and iterative theory that are similar way [5]. In computer programming, recursion used to simulate fractals. Our results not only can k is a function that can directly or indirectly call itself. well-describe the different fine structures of ED and k+1 A general syntax of recursion in Matlab looks like ED in the process of constructing Siepinski-type this: fractal ED, but also can well present different patterns function Recur(n) are what we need in study only by modifying a few parameters. ...... Recur(m) ...... The rest of this paper is organized as follows. Recursion is a method of solving problems based on In section 2, some basic facts and known concepts the divide and conquer mentality. The basic idea needed in our discussion are described, for details, see is that you take the original problem and divide it [4, 7, 12, 17]. An algorithm and a computer program into smaller (more easily solved) instances of itself, of simulating the Sierpinski gasket-type fractals and solve those smaller instances (usually by using the their geometric constructions are given base on itera- same algorithm again) and then reassemble them into tive and recursive theory in section 3. In section 4, be- the final solution. In this paper, the recursive al- sides an program similar to section 3 is given, we will gorithm will be used in two places, one is to di- k 2 give the other algorithm and program of simulating vide each squares(triangles) in ED into n equal-sized the Sierpinski carpet-type fractals and their geometric squares(triangles) for any k, the other is to fill the constructions only by recursive theory. squares are removed after each division with white. E-ISSN: 2224-2880 993 Issue 10, Volume 12, October 2013 WSEAS TRANSACTIONS on MATHEMATICS Zhiyong Zhu, Enemi Dong 2.3 Theory of Iterated Function System(IFS) by certain transformation equations. For example, we may compute the lower-left coordinates of triangles in We call the finite set ffi : i = 1; 2;:::;Ng is an E1 by (2). iterated function system if each fi is a contraction D mapping on a complete metric space. Hutchinson [7] ®Assign the above calculated values to the vari- showed that, for the metric space Rd, such a system of able of lower-left coordinate of initial equilateral tri- functions has a unique nonempty compact set(closed angle respectively and ready to participate in the cal- and bounded) E such that culation.