Block Method for Convex Polygon Triangulation

Similar documents
Reverse Polish notation in constructing the algorithm for polygon triangulation

OBJECT-ORIENTED ANALYSIS AND DESIGN FOR ONE ALGORITHM OF COMPUTATIONAL GEOMETRY: FORWARD, REVERSE AND ROUND-TRIP ENGINEERING

Optimal Region for Binary Search Tree, Rotation and Polytope

The Geometry of Carpentry and Joinery

ON THE EMPTY CONVEX PARTITION OF A FINITE SET IN THE PLANE**

Geometric Streaming Algorithms with a Sorting Primitive (TR CS )

Simultaneously flippable edges in triangulations

6. Concluding Remarks

COMPENDIOUS LEXICOGRAPHIC METHOD FOR MULTI-OBJECTIVE OPTIMIZATION. Ivan P. Stanimirović. 1. Introduction

Combinatorial Enumeration of Partitions of a Convex Polygon

Which n-venn diagrams can be drawn with convex k-gons?

Ray Casting of Trimmed NURBS Surfaces on the GPU

[Me] Meisters, G. H., Polygons have ears, American Mathematical Monthly, June/July 1975, pp

Problem Set 7 Solutions

of Nebraska - Lincoln. Follow this and additional works at:

3 No-Wait Job Shops with Variable Processing Times

The Fibonacci hypercube

Hierarchical Representation of 2-D Shapes using Convex Polygons: a Contour-Based Approach

Orthogonal art galleries with holes: a coloring proof of Aggarwal s Theorem

Lecturer: Shuchi Chawla Topic: Euclidean TSP (contd.) Date: 2/8/07

Efficient minimum spanning tree construction without Delaunay triangulation

The Full Survey on The Euclidean Steiner Tree Problem

Interactive Math Glossary Terms and Definitions

Triangulation by Ear Clipping

A NOTE ON BLOCKING VISIBILITY BETWEEN POINTS

Polygon Triangulation

Planar Graphs with Many Perfect Matchings and Forests

Arizona Academic Standards

Computational Geometry [csci 3250]

2D rendering takes a photo of the 2D scene with a virtual camera that selects an axis aligned rectangle from the scene. The photograph is placed into

As a consequence of the operation, there are new incidences between edges and triangles that did not exist in K; see Figure II.9.

Uniform edge-c-colorings of the Archimedean Tilings

An Efficient Algorithm for Computing Non-overlapping Inversion and Transposition Distance

Greedy Algorithms 1 {K(S) K(S) C} For large values of d, brute force search is not feasible because there are 2 d {1,..., d}.

Partitioning Orthogonal Polygons by Extension of All Edges Incident to Reflex Vertices: lower and upper bounds on the number of pieces

Preferred directions for resolving the non-uniqueness of Delaunay triangulations

Planar Graphs. 1 Graphs and maps. 1.1 Planarity and duality

2 Approximation Algorithms for Metric TSP

arxiv: v1 [math.co] 20 Aug 2012

Grouping Genetic Algorithm with Efficient Data Structures for the University Course Timetabling Problem

γ 2 γ 3 γ 1 R 2 (b) a bounded Yin set (a) an unbounded Yin set

An implementation of hash table for classification of combinatorial objects

Pebble Sets in Convex Polygons

Derivation of an Algorithm for Calculation of the Intersection Area of a Circle with a Grid with Finite Fill Factor

CS 372: Computational Geometry Lecture 10 Linear Programming in Fixed Dimension

The geometric generalized minimum spanning tree problem with grid clustering

Cutting out polygons with a circular saw

4 Mathematics Curriculum. Module Overview... i Topic A: Lines and Angles... 4.A.1. Topic B: Angle Measurement... 4.B.1

Hamiltonian cycles in bipartite quadrangulations on the torus

Number and Operation Standard #1. Divide multi- digit numbers; solve real- world and mathematical problems using arithmetic.

An Optimal Algorithm for the Euclidean Bottleneck Full Steiner Tree Problem

Chordal deletion is fixed-parameter tractable

A Generalization of the Catalan Numbers

Noncrossing Trees and Noncrossing Graphs

Slides for Faculty Oxford University Press All rights reserved.

Range Tree Applications in Computational Geometry

arxiv:cs/ v1 [cs.ds] 20 Feb 2003

[Ba] Bykat, A., Convex hull of a finite set of points in two dimensions, Info. Proc. Lett. 7 (1978),

Triangulation Based Volume Calculation Andrew Y.T Kudowor and George Taylor Department of Geomatics University of Newcastle

MISCELLANEOUS SHAPES

Faster parameterized algorithms for Minimum Fill-In

ROBOT MOTION USING DELAUNAY TRIANGULATION

Advanced Algorithms and Data Structures

arxiv: v1 [cs.cc] 30 Jun 2017

PO 2. Identify irrational numbers. SE/TE: 4-8: Exploring Square Roots and Irrational Numbers, TECH: itext; PH Presentation Pro CD-ROM;

Notes for Lecture 24

Hypercubes. (Chapter Nine)

Monotone Paths in Geometric Triangulations

arxiv: v1 [cs.ni] 28 Apr 2015

Star Decompositions of the Complete Split Graph

JOB SHOP SCHEDULING WITH UNIT LENGTH TASKS

On the number of distinct directions of planes determined by n points in R 3

arxiv: v1 [cs.dm] 21 Dec 2015

Module 27: Chained Matrix Multiplication and Bellman-Ford Shortest Path Algorithm

A Reduction of Conway s Thrackle Conjecture

Exponential time algorithms for the minimum dominating set problem on some graph classes

A Simplex based Dimension Independent Approach for Convex Decomposition of Nonconvex polytopes

A study on the Primitive Holes of Certain Graphs

The orientability of small covers and coloring simple polytopes. Nishimura, Yasuzo; Nakayama, Hisashi. Osaka Journal of Mathematics. 42(1) P.243-P.

Polygon Partitioning. Lecture03

Two distance-regular graphs

Polygon decomposition. Motivation: Art gallery problem

6.001 Notes: Section 4.1

c 2011 BRITTANY NICOLE MOTT ALL RIGHTS RESERVED

2.2 Set Operations. Introduction DEFINITION 1. EXAMPLE 1 The union of the sets {1, 3, 5} and {1, 2, 3} is the set {1, 2, 3, 5}; that is, EXAMPLE 2

Unit Map: Grade 3 Math

SHAPE SEGMENTATION FOR SHAPE DESCRIPTION

APPROXIMATING THE MAXMIN AND MINMAX AREA TRIANGULATIONS USING ANGULAR CONSTRAINTS. J. Mark Keil, Tzvetalin S. Vassilev

Winning Positions in Simplicial Nim

Grade 7 Mathematics Performance Level Descriptors

Basic Properties The Definition of Catalan Numbers

Happy Endings for Flip Graphs. David Eppstein Univ. of California, Irvine Computer Science Department

Dynamic Programming. Design and Analysis of Algorithms. Entwurf und Analyse von Algorithmen. Irene Parada. Design and Analysis of Algorithms

HEURISTIC ALGORITHMS FOR THE GENERALIZED MINIMUM SPANNING TREE PROBLEM

The Graphs of Triangulations of Polygons

Ray shooting from convex ranges

AQA GCSE Maths - Higher Self-Assessment Checklist

Ma/CS 6b Class 26: Art Galleries and Politicians

Euler s Theorem. Brett Chenoweth. February 26, 2013

Two Polynomial Time Algorithms for the Metro-Line Crossing Minimization Problem

Transcription:

ROMANIAN JOURNAL OF INFORMATION SCIENCE AND TECHNOLOGY Volume 15, Number 4, 2012, 344 354 Block Method for Convex Polygon Triangulation Predrag S. STANIMIROVIĆ, Predrag V. KRTOLICA, Muzafer H. SARAČEVIĆ, Sead H. MAŠOVIĆ Faculty of Science and Mathematics, University of Niš Višegradska 33, 18000 Niš, Serbia E-mail: {pecko,krca@pmf.ni.ac.rs, {muzafers,sekinp@gmail.com Abstract. In this paper, the block method for convex polygon triangulation is presented. The method is based on the usage of the previously generated triangulations for polygon with smaller number of vertices. In the beginning, we establish some relations between the triangulations of the polygons having the consecutive number of vertices. Using these relations, we decompose the triangulation problem into subproblems which are themselves smaller instances of the starting problem. The recursion with memoization is used to avoid repeating the calculation of results for previously processed inputs. The corresponding algorithm is developed and implemented. Key words: Convex polygon triangulation, Catalan numbers, Recursion, Memoization, Divide & Conquer algorithms. 1. Introduction and Preliminaries Polygon triangulation is an important problem applicable in computer graphics. It is a basic primitive and preprocessing step for most nontrivial operations on polygons. Decompositions od two dimensional scenes are used, for e.g., in contour filling, hit detection, clipping and windowing (see [1, 2, 5]). Restricted on the convex case, triangulations are defined by non-intersecting internal diagonals of the polygon. Let P n denote a polygon with n vertices. In this paper, we suggest a method to triangulate P n using already produced blocks in the triangulation of a P b, with b < n.

Block Method for Convex Polygon Triangulation 345 The total number T n of n-gon triangulations is T n = C n 2 = 1 ( ) 2n 4 (2n 4)! =, n 1 n 2 (n 1)!(n 2)! n 3. (1) Here, C n represents the nth Catalan number (about the topic see e.g. [7]). The set of all triangulations of the convex polygon P n is denoted by T n. A diagonal connecting vertices i and j is denoted by δ i,j. An outer face edge can be considered as a diagonal, while non adjacent vertices are connected by an internal diagonal. The general strategy used in our method is to decompose the problem into the smaller dependant subproblems. Each subproblem is solved only once and used many times avoiding unnecessary repetitions of calculation. The algorithm for deriving the set T n from T n 1 is presented in [6]. We have been inspired by this algorithm to define our block method for convex polygon triangulation. Our method is aimed to accelerate the triangulation process of P n using T n 1 as blocks of stored internal diagonals. More precisely, our algorithm generates the set T n using all the previously generated triangulations T b, b < n. Here, the set T b is used as many times as necessary as a block, i.e. it is repeated several times in T n. Since C n = 4n 2 n + 1 C n 1, it is not difficult to verify that the inequality T n > 2T n 1 is satisfied for all n > 4. Therefore, the number of triangulations T n = C n 2 can be recursively expressed as T n = 2T n 1 + rest(r n ). (2) The following statement gives a formal background for our method. Proposition 1.1. Every triangulation from T n 1 appears as a starting part of exactly two triangulations form T n. Proof. If we consider an P n 1 and its edge δ 1,n 1, then it is obvious that in T n 1 this edge belongs to the triangle (1, i, n 1), 2 i n 2. Let the point which is out of P n 1, and labeled by n, be in the position to form (with nodes 1,..., n 1) a convex polygon. The diagonals δ 1,i and δ i,n 1 make vertices 2,..., i 1, i+1,..., n 2 closed with respect to the vertex n. Also, the vertices 1, i, n 1, and n form a quadrilateral. This quadrilateral can be triangulated in two ways, so each triangulation from T n 1 appears as a starting part in two triangulations from T n. Note that there are some other triangulations in T n which should be derived in other way. Memoization is a useful and important tool for solving heavy recursive computations (cf. [3]). The triangulation problem is, by its nature, the recursive and time consuming job. The underlying idea is to speed up recursive algorithms by avoiding recomputations caused by the overlapping subproblems. Instead of having an entry in the table for the solution of each subproblem, in this case we have stored previously generated triangulations T n 1. As it is explained above, in the significant number of cases, a triangulation from T n 1 is an initial part of two triangulations in T n. Here it is not necessary to proceed with recursion further

346 P. S. Stanimirović et al. (down to the triangle), but, in the memoization style, we just use what we already have and, suitably complementing it, we get two new triangulations. Moreover, in the case of traditional recursion, generating of T n 1 will occur twice in independent calculation subtrees. Now, this repetition is avoided. This general idea is illustrated in Fig. 1, where the transformation process from a P 5 triangulation in two corresponding P 6 triangulations is presented. In part (a) we see that the diagonals δ 2,4 and δ 2,5 make all vertices closed except vertices 1, 2, 5, and 6 which form a quadrilateral. The parts (b) and (c) show two ways to triangulate a quadrilateral which give two P 6 triangulations having the P 5 triangulation as a starting block. Fig. 1. Transformation from a P 5 triangulation into the corresponding P 6 triangulations. A vertex i is closed by an internal diagonal with respect to the vertex j if vertex i can not be an ending point of internal diagonal δ i,j because it implies the diagonal crossing (recall that a triangulation is made by non-intersecting internal diagonals). We simply say that i is the closed vertex if i is closed with respect to all other vertices in the polygon. The closed vertex has the degree 2 and it is alternatively called an ear. The algorithm presented in Section 2 is compared with algorithm developed by Hurtado and Noy and presented in [6]. For this reason, we restate here this algorithm. Algorithm 1 Hurtado algorithm Require: Positive integer n and the set T n 1 of P n 1 triangulations. Each triangulation is described as a structure containing 2n 5 vertex pairs presenting P n 1 diagonals (here diagonals means both internal diagonals and outer face edges). 1: Check the structure containing 2n 5 vertex pairs looking for pairs (i k, n 1), i k {1, 2,..., n 2, 2 k n 2, i.e. diagonals incident to vertex n 1. The positions of these indices i k within the structure describing a triangulation should be stored in the array. 2: For every i k perform the transformation (i l, n 1) (i l, n), i l < i k, 0 l n 3. 3: Insert new pairs (i k, n) and (n 1, n) into the structure. 4: Take next i k, if any, and go to Step (2). 5: Continue the above procedure with next (n 1)-gon triangulation (i.e. structure with 2n 5 vertex pairs) if any. Otherwise halt. In the Section 2 we present the algorithm for the block method, while the execution times for both algorithms are given in Section 3. Some interesting parts of the code are presented in Appendix.

Block Method for Convex Polygon Triangulation 347 2. Algorithm for block method Similarly to the definition of the edge length in [9], we define a distance between two polygon vertices. Definition 2.1. The distance between two integers i and j, where i, j {1,..., m, is defined as d(i, j) = d(j, i) = min{ i j, m i j. In the procedure used for finding and eliminating closed vertices, we should start from an ear. As a triangulation has at least two ears, and, in the worst case one ear can be a vertex n, then we always have at least one ear among the rest of the vertices. For this purpose we make a list of ordered pairs of the form L = {(1, 1), (2, 2),..., (n, n). (3) After the elimination of n l pairs the list L becomes L = {(s, i s ), s = 1,..., l, 4 l n, i l = n. (4) The values i s, s = 1,..., l are the vertex marks, while values 1,..., l represent the relative vertex positions in the list L. Algorithm 2 Pair elimination Require: List L of the form (4) and vertices i p and i q, where d(p, q) = 2. 1: Remove from the list L the pair placed between the pairs (p, i p ) and (q, i q ) in circular manner. 2: Decrease by one the first pair members in the pairs following the eliminated one. Further, we check the first n 4 columns in the table for T n looking for an ear. The ear is recognized when, for diagonal δ ip,i q, we have d(p, q) = 2. Then we eliminate the corresponding list element and decrease relative positions of the pairs following the eliminated pair. Algorithm 3 Form a qaudrilateral Require: List L of the form (3), integer n and array of n 4 diagonals (i.e. a row in the table for T n ). 1: Find a diagonal δ ip,i q where d(p, q) = 2 in the list L. 2: Call Algorithm 2 for parameters i p and i q. 3: Repeat Steps 1 2 n 4 times. After n 4 pair eliminations, we have four vertices in the list forming a quadrilateral which can be triangulated in two ways.

348 P. S. Stanimirović et al. Algorithm 4 Algorithm for block method Require: An integer n and T b with row b = C n 3 rows and col b = n 4 columns) 1: Create an empty table for T n with row n = C n 2 rows and col n = n 3 columns. 2: Fill the table for T n by the triangulations from T b duplicating each row from T b. 3: Fill the rest of entered blocks (the last column in the first 2row b rows) in the following way. for (i = 1; i <= 2row b ; i+ = 2) { Make a list L of the form (3). Call Algorithm 3 with row i from table for T n as a parameter. From the remaining four vertices in list L make diagonal δ i1,i 3 and place it in the last column of the row i and diagonal δ i2,i 4 and place it in the last column of the row i + 1. 4: Fill the rest of the table for T n containing T n 2T b rows. 4.1 Filling the first n 4 columns in the last row n 2row b rows. i = 2 row b + 1; Make the list L of the form (3). Eliminate the vertices adjacent to n calling Algorithm 2 for parameters 1 and n 1. Fill the current table row i by diagonals δ 2,n, δ 3,n,..., δ n 2,n. The first n 4 columns in the rest row n 2row b 1 rows should be filled by diagonals with the last vertex n, while the first vertices are combinations of the (n 4)th class in the set {2, 3,..., n 2. The number of these combinations is ( n 3 n 4) = n 3. 4.2 Filling the last column in the last (row n 2row b ) rows. for (i = 2row b + 2; i <= row n ; i + +) { Make the list L of the form (3). Call Algorithm 3 with row i from table for T n as a parameter. From the remaining four vertices in list L make diagonal δ i1,i 3 and place it in the last column of the row i. Example 2.1. As an example, we will present the procedure to derive T 6 on the base of T 5. As we have already presented, Algorithm 4 consists of four steps. In the first step, an empty table with the appropriate number of columns and rows is created. In the second step, the table is filled with T b in the duplicate. In the third and fourth step, the remaining empty parts of the table are filled in (Fig. 2). In Step (1) an empty table is created. Step (2) consists of copying the already derived blocks. In Step (3) we fill the last column where blocks are copied. Step (4.1) fills the first two columns in the rest of the rows and Step (4.2) completes the last column.

Block Method for Convex Polygon Triangulation 349 Fig. 2. Filling the table (step by step). The process of T 6 generation, based on a given T 5, is presented in Fig. 3. Fig. 3. Generated triangulation for n = 6. Upon the creation of the empty table and its filling by T 5 in the duplicate (Steps (1) and (2)), in Step (3) we fill the last column of the first 10 rows. For each of 5 odd rows (T 5 = 5 and even rows in first two rows contain a copy of the previous odd indexed row) we should make a list L = {(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6). Then, we try to find a diagonal whose ending points have the distance 2. Such a diagonal in the first row is δ 1,3. So, we eliminate a vertex between them, i.e. the vertex 2, decreasing the first pair element by 1 in the pairs following the eliminated one. In this way, our list becomes L = {(1, 1), (2, 3), (3, 4), (4, 5), (5, 6). Now, the ending points of the diagonal δ 1,4 also have the distance 2. The list transforms to L = {(1, 1), (2, 4), (3, 5), (4, 6). We have eliminated n 4 = 2 closed vertices, and within the list there are four remaining vertices 1, 4, 5, and 6. They form a quadrilateral which can be triangulated in two ways having δ 1,5 or δ 4,6 as a diagonal. So, in the last column of the first row we store δ 1,5 and in the last column of the second row we store δ 4,6. We fill the first 10 rows in a similar way.

350 P. S. Stanimirović et al. In Step (4) we fill the rest of the table. In this part any already present diagonal (from the first 10 rows) can not be repeated. The first 10 rows have 5 rows with diagonals not ending in the vertex 6 and 5 rows with exactly one diagonal ending in the vertex 6. Therefore, in the rest of the table we must have rows with exactly three diagonals ending in vertex 6 (there is exactly one such a row) or rows with exactly two diagonals ending in 6. After we have made a list L and eliminated vertices 1 and 5 (adjacent to 6), our list is L = {(1, 2), (2, 3), (3, 4), (4, 6). There is one possibility with three diagonals ending in 6, δ 2,6, δ 3,6, and δ 4,6. Further, there are three combinations with exactly two diagonals with ending point in 6, namely δ 2,6, δ 3,6 ; δ 2,6, δ 4,6 ; δ 3,6, δ 4,6. This is done in step (4.1). The step (4.2) completes the work. Again we make the list L = {(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6) and checking the non-completed rows we make vertex elimination as in Step (3). The diagonal δ 2,6 forces the elimination of vertex 1 transforming a list in L = {(1, 2), (2, 3), (3, 4), (4, 5), (5, 6). After this, the diagonal δ 3,6 also has the ending points on the distance 2 and implies the elimination of the vertex 2. The list becomes L = {(1, 3), (2, 4), (3, 5), (4, 6). We need a diagonal not ending in 6, so we choose δ 3,5 and store it in the last column. This step, repeated for the remaining rows, completes the algorithm. 3. Experimental Results In [8] we investigate which programming language (Java, C++ and Python) is most suitable to implement algorithms for a convex polygon triangulation. Based on comparative analysis, Java programming language gave the best results in terms of speed of generating triangulations. For implementation of Block method we used NetBeans IDE environment for Java. Table 1. The execution times for two algorithms (in seconds) n Number of Block Speedup triangulations Hurtado Method 5 5 0.25 0.16 1.56 6 14 0.34 0.26 1.31 7 42 0.43 0.34 1.26 8 132 0.49 0.41 1.20 9 429 0.67 0.46 1.46 10 1,430 1.18 0.54 2.19 11 4,862 3.81 0.85 4.48 12 16,796 12.46 1.32 9.44 13 58,786 50.51 4.40 11.48 14 208,012 119.05 24.13 4.93 15 742,900 318.63 85.30 3.74 16 2,674,440 / 529.30 The execution times for both algorithms are presented in Table 1. The table column Speedup shows the quotient of values contained in the previous two columns.

Block Method for Convex Polygon Triangulation 351 The testing is performed in NetBeans testing module Profile Main Project / CPU Analyze Performanse in configuration*: CPU - Intel(R) Core(TM)2Duo CPU, T7700, 2.40 GHz, L2 Cache 4 MB (On-Die,ATC,Full-Speed), RAM Memory - 2 Gb, Graphic card - NVIDIA GeForce 8600M GS. The algorithm produces the triangulations of an n-gon using already known triangulations of an (n 1)-gon. The number of triangulations growths rapidly with n and these triangulations are stored in a file. For any larger n, all (n 1)-gon triangulations can not be in the same time in memory. It is not important is it for n = 15, 16, or 20 (memories are getting larger in time) - the fact is: from some n we have to include time needed for reading/writing data form disk. This fact implies significant increase of the execution time. But it does happen in the same way with Hurtado s algorithm witch we try to accelerate. Experiment with larger values of n and inclusion of I/O in execution time will make the performance difference of two algorithms blurry. For n > 16, in Table 1, the RAM memory is exhausted. This problem can be overcome applying the so-called virtual memory paging file (VMPF). The better performances of the Block method with respect to the Hurtado algorithm can also be confirmed by using the so-called performance profile, introduced in [4]. The underlying metric is defined by the CPU time spanned for the construction of all triangulations for the cases n = {5,..., 15. Following the notations given in the paper [4] we have that the number of solvers is n s = 2 (Block and Hurtado) and the number of numerical experiments is n p = 11. By t p,s we denote the number of iterations required for solving the problem p by the solver s. The quantity r p,s = t p,s min{t p,s : s {Hurtado, Block is called the performance ratio. The performance of the solver s is defined by the following cumulative distribution function ρ s (τ) = 1 n p size{p P : r p,s τ, s {Hurtado, Block where τ R and P represents the set of problems. Ρ 1 0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 Hurtado Block 1 1.5 2 2.5 3 3.5 4 4.5 Τ Fig. 4. Performance profile regarding the CPU times arranged in Table 1.

352 P. S. Stanimirović et al. Figure 4 shows data arranged in Table 1. It is clear from Figure 4 that the Block method shows better performances compared to Hurtado method. Namely, the probability of being the optimal solver is in favor of the Block algorithm. 4. Conclusion We have developed the algorithm for convex polygon triangulation which uses the already made triangulations of a polygon with one vertex less. The similar approach is used in [6], so we have compared these two algorithms. Our block method uses the triangulations T n 1 as whole blocks in T n making the respectable part of the job done quickly. The achieved significant speedup is a consequence of this approach. Appendix: Application and Implementation Details The applications Hurtado-Noy order and Block method are implemented in programming language Java in NetBeans environment. The application input is an integer n, i.e. the number of vertices for the polygon which is about to be triangulated. Firstly, it is checked if there already exists the set T n 1 stored in a file. Both applications are implemented using the following classes: Triangulation, App, Node, LeafNode, Point, and PostScriptWriter. The difference between them is in the main class App containing executive method main(). In the application for Hurtado algorithm, the class App calls its own method Hurtado() while the Block method application calls the method Block(). The method Block() corresponds to Algorithm 4. This method can be divided in four parts. The first one takes triangulations T n 1 (Step 1). After this, T n 1 are copied (Step 2). In Step 3, the last column is filled with an additional diagonal. This is the job of the method contains() which is a member of the class Node. The method corresponds to Algorithm 3 and it is aimed to find the non-closed vertices forming a quadrilateral. The method contains() calls the method elimination() corresponding to Algorithm 2. The last part finds the rest of triangulations (Step 4.1). Within this part, the method contains() is called again to complete Step 4.2. Java source code for Block method - (corresponds to Algorithm 4) p u b l i c Vector<Node> Block ( i n t CatNum) throws IOException { // s t e p 1 Vector<Vector> b l = new Vector<Vector >(); t h i s. o p e n F i l e ( baze / [T +(CatNum+1)+ BAZA ]. jdb ) ; b l. add ( new Vector<LeafNode > ( ) ) ; b l. get ( 0 ). add ( new LeafNode ( ) ) ; // s t e p 2 i n t lim =2; lim=catnum ;

Block Method for Convex Polygon Triangulation 353 f o r ( i n t n=0; n <=CatNum ; n++) { Vector<Node> L = new Vector ( ) ; b l. add (L ) ; f o r ( i n t row = 0 ; row < b l. get ( n ). s i z e ( ) ; row++) { S t r i n g as= row + # +(row +1); i f ( n==lim ) System. out. p r i n t l n ( row +(row +1)); Node t = ( Node ) b l. get ( n ). get ( row ) ; Node s = new Node ( new LeafNode ( ), t. copy ( ) ) ; L. add ( s ) ; // s t e p 3 i n t remainingbranch= n 2 n1 ; f o r ( i n t k = 0 ; k < t. remainingbranch ( ) ; k++) { s = t. copy ( ) ; Node r = s ; L. c o n t a i n s ( r ) ; Vector<Node> R = new Vector ( ) ; r. e q u a l s (R) ; // s t e p 4 f o r ( i n t i =0; i < k ; i ++){ // s t e p 4. 1 s = s. g e t L e f t ( ) ; L. lastelement ( ) ; s. s e t L a s t ( new Node ( new LeafNode ( ), s. g e t L e f t ( ) ) ) ; // s t e p 4. 2 L. c o n t a i n s ( r ) ; L. add ( r ) ; r e t u r n b l. get (CatNum ) ; Java source code for method contains()-(corresponds to Algorithm 3) p u b l i c i n t c o n t a i n s ( ) { i n t a=t h i s. c o n t a i n s () t h i s. l e f t. c o n t a i n s ( ) ; i n t b=t h i s. r i g h t. c o n t a i n s () ( t h i s. c o n t a i n s () t h i s. l e f t. c o n t a i n s ( ) ) ; f o r ( i =0; i <=(n 4); i ++){ i f ( ( a b)==2) { L. e l i m i n a t i o n ( ) ; r e t u r n L. remainingbranch ( ) ; Java source code for method elimination()-(corresponds to Algorithm 2) p u b l i c i n t e l i m i n a t i o n ( ) { i n t t=t h i s. r i g h t. e l i m i n a t i o n () t h i s. l e f t. e l i m i n a t i o n ( ) ; r e t u r n t ; Java source code for method Hurtado()

354 P. S. Stanimirović et al. p u b l i c Vector<Node> Hurtado ( i n t CatNum) { Vector<Vector> H = new Vector<Vector >(); H. add ( new Vector<LeafNode > ( ) ) ; H. get ( 0 ). add ( new LeafNode ( ) ) ; f o r ( i n t n=0; n <= CatNum ; n++) { Vector<Node> l e v e l = new Vector ( ) ; f o r ( i n t i= 0 ; i < H. get ( n ). s i z e ( ) ; i ++) { Node t = ( Node )H. get ( n ). get ( i ) ; Node s = new Node ( new LeafNode ( ), t. copy ( ) ) ; l e v e l. add ( s ) ; f o r ( i n t k = 0 ; k < t. l e f t B r a n c h ( ) ; k++) { s = t. copy ( ) ; Node l = s ; f o r ( i n t i =0; i < k ; i ++) s = s. g e t L e f t ( ) ; s. s e t L e f t ( new Node ( new LeafNode ( ), s. g e t L e f t ( ) ) ) ; l e v e l. add ( l ) ; H. add ( l e v e l ) ; r e t u r n H. get (CatNum ) ; References [1] Chazelle B., Triangulation a Simple Polygon in Linear Time, Discrete Computational Geometry, Vol. 6, pp. 485-524, 1991. [2] Chazelle B., Palios L., Decomposition Algorithms in Geometry, Algebraic Geometry and its Application (ed. Ch. L. Bajaj), Springer-Verlag, Vol. 27, pp. 419 447, 1994. [3] Cormen T. H., Leiserson C.E., Rivest R. L., Stein C., Introduction to Algorithms, Second Edition, The MIT Press, 2001. [4] Dolan E. D., Moré J.J., Benchmarking optimization software with performance profiles, Mathematical Programming. Vol. 91, pp. 201 213, 2002. [5] Garey M. R., Johnson D. S., Preparata F.P., Tarjan R.E., Triangulating a simple polygon, Information Processing Letters, Vol. 7, pp. 175 180, 1978. [6] Hurtado F., Noy M., Graph of Triangulations of a Convex Polygon and Tree of Triangulations, Computational Geometry, Vol. 13, pp. 179 188, 1999. [7] Koshy T., Catalan Numbers with Applications, Oxford University Press, New York, 2009. [8] Saračević M., Stanimirović P.S., Mašović S., Biševac E., Implementation of the convex polygon triangulation algorithm, Facta Universitatis, series: Mathematics and Informatics, Vol. 27, pp. 213 228, 2012. [9] Sen-Gupta S., Mukhopadhyaya K., Bhattacharya B. B., Sinha B. P., Geometric Classification of Triangulations and Their Enumeration in a Convex Polygon, Computers and Mathematics with Applications, Vol.27, pp. 99 115, 1994.