Transactions on Computer Science and Technology June 2014, Volume 3, Issue 2, PP.41-47 Amplification Matrix Iteration Algorithm to Generate the Hilbert-

Zhengwen Peng, Xin Lu# Department of Mathematics and Computer Science, Nanchang Normal University, 330032, China #Corresponding author: [email protected] Abstract

The methods to construct the Hilbert-Peano curve are recursive and non-recursive; methods of L-grammar system, different methods have different characteristics. In this document, from the prospective of non-recursive to analyze the characteristics of Hilbert-Peano curve, adopt the amplification curve characteristic matrix iteration algorithm constructs the Hilbert-Peano curve, compares the algorithm with the non-recursive algorithm in time-space-consuming. Prove that this algorithm has more advantages on large scale than L-system of non-recursive algorithm. Keywords: Hilbert-Peano Curve; ; Iteration Matrix

1 INTRODUCTION For Euclidean geometry, consider a one-dimensional only line or line segment, the two-dimensional nature belongs to the plane. In 1890, however, mathematicians G.Peano studying G. in an attempt to use the curve to fill on the basis of two-dimensional plane, mathematician Hilbert subsequently proved feasible in 1891, and found the famous two-dimensional Hilbert-Peano plane filling curve [1], as shown in Fig. 1.

FIG. 1 THE HILBERT-PEANO CURVE GENERATED ITERATION 3 TIMES In environment at that time, mathematicians realized plane filling curve for just stay on the level of questioning curiosity, thought by the seemingly simple structure of the line can constitute a complex curve, and uninterrupted don't repeat to fill the whole plane, that curve was of no use Euclidean geometry to explain and measure it, more can't imagine after one hundred will be widely used in computer graphics, image processing technology. Such can not use Euclidean space to measure the curve was Mandelbrot particular meaning for fractal geometry [1]. The introduction of fractal theory to solve the proposed many years mathematicians can't use Euclidean geometry to solve the problem. Although there is no unified definition of fractal and its structure characteristics is clear, that is to analyze the structure has the infinite self-similarity, and the Hilbert-Peano plane filling curve, obviously is a kind of typical fractal structure. The nature of the Hilbert-Peano plane filling curve: (1) when the basic line of line length tend to zero, the curve will be covered with flat; (2) the curve have a starting point and end point, curve of disjoint forever; (3) the curve of the number of iterations is not generated at the same time with fine self-similarity structure; (4) curves are connected by a simple line of the same length;

- 41 - http://www.ivypub.org/cst

In theory, the basic element of the Hilbert-Peano curve length tends to zero when the length is infinitely long, thus complete the Hilbert-Peano curve cannot be mapped out, use the computer to draw the Hilbert-Peano curve, because screen resolution and the limitation of human eye vision, can only draw the curve of the line length is greater than 1 pixel. The article does not discuss the theoretical basis of the curve, mainly on the question from the analysis of characteristics of the Hilbert-Peano form only an amplification curve characteristic matrix iteration algorithm to map the Hilbert-Peano curve. Now generate the Hilbert-Peano curve methods mainly include recursive method, L-grammar system, a recursive method, etc. The recursive algorithm described as follows [2,3]: Step 1: set the depth n. Step 2: determine the scope of the curve, Step 3: to the initial square quarters, and its length is 2 n equal; Step 4: calculate the center of small square as a curve segment load-point coordinates; Step 5: according to the curve feature called recursive algorithm draw curves; Commonly used as L - system generated rules describe the Hilbert-Peano curve generation process [3,4,5]: Variables: L, R Constant: F, +, - The starting point: L Generate rules: L  -RF + LFL + FR - R + LF - RFR FL + F: forward painting line - : right turn 90 ° + : left turn 90 ° Through continued iteration L, R to generate the Hilbert curve - Peano curves. On the basis of L - system an improved evolutionary algorithm is proposed[6]. According to the literature data, the algorithm is obviously speed than the recursive algorithm and L - system generation algorithm, In addition, Lin ShenYi from Feng Chia University of Taiwan using tensor product, to draw the Hilbert-Peano curve[7]. 2 Related Work In this paper, through the analysis of the Hilbert-Peano curve characteristics put forward a kind of based on amplification curve characteristic matrix iteration algorithm to generate the Hilbert-Peano curve.

2.1 Split the Hilbert-Peano Curve Observe the Hilbert-Peano curve, found that the curve graphics essentially generated by four basic elements, according to certain rules generated by four basic elements generate corresponding elements connected curve, the subsequent content with a, b, c, d respectively identified that the four basic elements generate graphics, as shown in Fig. 2.

FIG. 2 BASIC GENERATED ELEMENTS

- 42 - http://www.ivypub.org/cst

2.2 Iterative Matrix Hilbert-Peano curve generating element is simple, but because of its characteristics as the growth of the number of iterations, the number of generated elements with two exponential growth, the number of iterations tends to infinity (segment length tends to 0) curve will traverse the area within the scope of the all points, obviously graphics was too complicated to use a computer simulation. According to the curve of each iteration characteristic, this article uses the amplification of iterative matrix to describe curve generation process. The generator according to the curve characteristics of the four of the first iteration, in turns, as shown in Fig.3.

FIG. 3 (a-d) FOUR TYPES OF ITERATION If the (a), (b), (c),(d) four generation element iterative transformation according to the type (a) structure ,and placed in a square which composed of 16 smaller squares, let to the end of each line is located in the center of the corresponding smaller square, we can get the following 2*2 matrices:

Same for (b), (c), (d) figure in accordance with the Hilbert-Peano curve, in turn, can get the corresponding matrix.

Use of (a) generator matrix iteration rules above the second iteration to get 4*4 matrix, the third iteration will get 8 x 8 matrix, each iteration are get a matrix of more than four times the last time, the n-th iteration might get a 2n*2n matrix.

Visible, iterative n times generated is not the Hilbert-Peano curve, but a basic generated by 2 n x 2 n elements ((a), (b), (c), (d)) generated by four basic elements of the curve of the set, and the curve is discrete. The following content is to discuss how to connect to the discrete curve to form the Hilbert-Peano curve.

2.3 The Connection between the Generated Elements According to the characters of the Hilbert-Peano curve, the curve there is only one entrance and only one export, apparently finish or repeated traversal area must demand curve continuous at all points. By the n iteration times of Hilbert-Peano curve after converted to a 2n*2n iterative matrix according to the above iteration rules, each generated element directly mapped and can't get a continuous Hilbert-Peano curve, because the matrix of each generated element is discrete, not continuous. By the curve fractal characters, that is, a fractal structure of unlimited fine, you can see that the continuity of the initial generation elements determines the subsequent iterations of the continuity of each element. It is obvious that generated the n-th (n>1) iteration of the Hilbert-continuity between the Peano curve generated elements generated by n - 1 iteration elements the continuity of the decision.

- 43 - http://www.ivypub.org/cst

For (a) if the initial generation element, from left to right, depending on the type (a) the characteristics of continuous (graphics opening facing down), the left line, the upper part of the line segment and the right line continuously, therefore, the first iteration of the resulting matrix, where the first row 0, column 0, the first one of the two adjacent elements to generate continuous, and the element of row 1 two generated disconnect. Actually guarantee the continuity of drawing is looking for direction along the curve plotting on the next generation of elements (adjacent element). How to determine the position of the element in the next, obviously is the key to the problem. Determine the adjacent generation element, we must first determine a generating element of the drawing direction, according to the Hilbert-Peano curve feature that is easy to determine the direction of each drawing elements and generated elements generated by the initial drawing direction. (a) type of paper used in the program as an initial forming element-forming element, the drawing direction of the drawing from left to right, i.e. starting point of the left and right end point of the end point, in this drawing, the drawing direction of (b), (c), (d) type generated element followed by: from right to left, top to bottom, from bottom to top. Iterative process to record the transmission continuity in an iterative process using the matrix, the matrix is called an Iterative Continuous Matrix (ICM). Fig.4 shows the continuity of the matrix elements of each generation after the first iteration generated. Where: RIGHT: right next to draw a generating element LEFT: draw a next generation element left DOWN: draw a next generation element down UP: The next generation of elements drawing up EXIT: as the last generation element

FIG. 4 EACH ITERATION OF THE CONTINUITY OF THE MATRIX ELEMENTS OF THE FIRST GENERATION AFTER Here is a drawing curves generated elements iterative process with (a) type:

First get iterative matrix , According to the continuity of a type generated elements characteristic (up, right, down, exports, Fig 5),

FIG. 5 (a) TYPE GENERATION ITERATIVE MATRIX ELEMENTS OF CONTINUITY WITH ITS MATRIX First draw (d) generating element type to (d) as the starting point of the end unit up to draw a vertical line (at a fixed space, the higher the number of iterations, the shorter the line, the line length and the length of each segment forming element line) to draw the line starting from the end point (a), followed by (a) the right end of the horizontal line drawing unit, after the starting point to the end point of the line drawing (a), then (a) the end of draw down a unit of vertical segments, and finally to the end of the line for the beginning of stippling (c), end . While generating elements corresponding n-th iteration of the continuity of the n-th iteration iteration matrix together, generate the corresponding elements of continuity with the iteration matrix elements corresponding to the respective iterative generation amplification, where each iteration EXIT values are set to the last iteration direction values. Fig.6 is a generator matrix after 2 iterations of the continuity of the matrix and the corresponding.

- 44 - http://www.ivypub.org/cst

FIG. 6 GENERATES A TYPE OF INITIAL MATRIX AND ITS MATRIX ELEMENTS OF CONTINUITY AFTER ITERATION 2 3 Algorithm The basic algorithm is as follows: Step 1: Determine the number of iterations, the starting point, line length, drawing area, initialize the initial generation elements, and initialize the continuity of the matrix; Step 2: iterative generation matrix elements of the matrix and the continuity of n times; Step 3: Based on the elements of the matrix is generated, the starting point coordinates, line length, continuous matrix of each successive draw the line; Step 4: End The algorithm has been implemented in the VC6.0 3.1 Compared with L - system If choose to draw the Hilbert-Peano curve of line segment as a basic operation, apparently two algorithms to generate n order of basic operation of the curve is the same, all is 4 n - 1 draw line segments. The following analysis of the difference between two algorithms from the space: To start with L, which replaces grammar is as follows: L → -RF+LFL+FR- R →+LF-RFR-FL+

To describe grammar iteration algorithm in the string, set the n-th grammar iterations required string space SL (n), there are:

SL(1)=7+4*11 1 2 SL(2)= 7+7*4 +4 *11 ... n 1 2 3 n-1 n 40 4 - 7 SL(n)=7+7*4 +7*4 +7*4 +…+7*4 +4 *11= . 3 In matrix iterative amplification algorithm, the n-th iteration to the use of the two matrices that is a feature of iterative matrix and the other is the continuity of the iteration matrix, as two matrix size, while also taking a single character storage matrix elements are stored, its single matrix spatial scale of 4n, so the algorithm is space consuming n somehow SM (n) = 2 * 4 . n n 34 4 - 7 SL(n)- SM(n)= -2*4 = 3 Two algorithms from the space consumption, although the complexity exponentially belong in the scale of the problem tends to be higher, the space consumption of this algorithm is obvious advantage。 3.2 The simulation results We generated L-system algorithm and amplification matrix iteration algorithm program in Visual C++6.0 environment. Program runs 40 times to get the corresponding experimental results (the algorithms’ time-consuming).

- 45 - http://www.ivypub.org/cst

Experiments involving the main parameters as follows: the number of iterations, the display area. For simplicity, the table takes the first 10 results of the experiment and the chart for all 40 results. The experimental parameters are: When the number of iteration is 9, the corresponding display area of the experiment is 2500*2500, and when the number of iteration is 10, the corresponding display area of the experiment is 5000*5000. Table.1 and Fig.7 is the experimental results of 9 iterations, Table.2 and Fig.8 is the experimental results of 10 iterations. TABLE 1 PART OF THE TEST DATA COMPARISON (10 TIMES BEFORE) ITERATIVE 9 TIMES, PIXEL: 2500*2500 Time (ms) The serial number Matrix iteration algorithm L - system (non-recursive) 1 3494 4040 2 3401 3776 3 3339 3716 4 3370 3760 5 3432 3744 6 3338 3822 7 3323 3807 8 3416 3775 9 3417 3837 10 3479 3713

Under the same machines under the same size (iterative nine times, is 2500 x 2500 pixel range, test times for 40 times) amplification matrix iteration algorithm with L - system to generate the Hilbert Peano curve comparison

5000 4000 Time (ms) Matrix iteration 3000 algorithm

time 2000 1000 Time (ms) L - 0 system (non- 0 10 20 30 40 50 recursive) Test serial number

FIG. 7 SIMULATION RESULTS TABLE 2 PART OF THE TEST DATA COMPARISON (10 TIMES BEFORE) ITERATIVE 10 TIMES, PIXEL: 5000*5000 Time (ms) The serial number Matrix iteration algorithm L - system (non-recursive) 1 12574 12948 2 12309 13011 3 12745 12933 4 12324 13541 5 12621 13556 6 12854 13432 7 12356 14134 8 12777 13416 9 12418 12964 10 12792 12980

15000

14500 Iterative 10 times, Pixel: 5000 x 5000 14000 Time (ms) Matrix iteration algorithm

13500 (ms) 13000 Iterative 10 times, Pixel: 5000 x 5000 12500 Time (ms) L - system (non-recursive) 12000 0 10 20 30 40 50

FIG. 8 SIMULATION RESULTS

- 46 - http://www.ivypub.org/cst

From the experimental data above, in the case of a large number of iterations, the time-consuming of amplification matrix iteration algorithm to generate the Hilbert-Peano curve is less than L-system significantly.

4 CONCLUSIONS Seemingly the simple Hilbert-Peano space filling curve is widely applied in computer and manufacturing, such as computer information storage, image compression encryption, printed circuit boards and other applications, hope this algorithm can have reference value in many applications.

REFERENCES [1] Heinz-Otto, Peitgen Hartmut, Jurgens Dietmar Saupe, 2004, Chaos and New Frontiers of Science Second Edition. Springer-Verlag New York, Inc [2] Bo-wen.Sun, 2004, Fractal algorithm and design: by Visual C++ implementation , Beijing, science press

[3] Jia-xin.Hu, 2013, An introduction to , Beijing ,Science press [4] http://zh.wikipedia.org/wiki/ Hilbert curve [5] http://en.wikipedia.org/wiki/Hilbert_curve#cite_ref-5 [6] Neng-chao Wang, Ning-tao Chen, Bao- Chang Shi. 2005, Peano curve evolution generation algorithm and its promotion. Computer science. 32: 208 [7] S.-Y. Lin, C.-S. Chen, L. Liu, C.-H. Huang, 2003, Tensor Product Formulation for Hilbert Space-Filling Curves, Proceedings of the 2003 International Conference on Parallel Processing, pp: 99-106

AUTHORS Zhengwen Peng, Pingxiang, Jiangxi, 1974.2. Earned Master’s Xin Lu, Zhangshu, Jiangxi, 1982.2. Earned Master’s Degree in Degree in Engineering in Nanchang University, Nanchang, Engineering in Beijing Institute of Technology, Beijing, China Jiangxi, China in 2000. in 2008.

He works as a lecture in Department of Mathematics and She works as a lecture in Department of Mathematics and Computer Science, Nanchang Normal University. Previous Computer Science, Nanchang Normal University. Current publications included: Java Programming (Beijing: China research interests include computer application and computer Railway press, 2010), C programming (Beijing: People’s Posts software development. & Telecom press, 2012). Current research interests include computer algorithm, fractal graphics and operating system etc.

- 47 - http://www.ivypub.org/cst