AHD: Alternate Hierarchical Decomposition Towards LoD Based Dimension Independent Geometric Modeling. Final

Size: px
Start display at page:

Download "AHD: Alternate Hierarchical Decomposition Towards LoD Based Dimension Independent Geometric Modeling. Final"

Transcription

1 AHD: Alternate Hierarchical Decomposition Towards LoD Based Dimension Independent Geometric Modeling Final January 27, 2011

2 D I S S E R T A T I O N AHD: Alternate Hierarchical Decomposition Towards LoD Based Dimension Independent Geometric Modeling ausgeführt zum Zwecke der Erlangung des akademischen Grades eines Doktors der technischen Wissenschaften unter der Leitung von Univ. Prof. Dipl. Ing. Dr. techn. Andrew U. Frank E127 Institut für Geoinformation und Kartographie eingereicht an der Technischen Universität Wien Fakultät für Mathematik und Geoinformation von MS. Rizwan Bulbul Matr. Nr Gymnasiumstrasse Wien Wien, am

3 D I S S E R T A T I O N AHD: Alternate Hierarchical Decomposition Towards LoD Based Dimension Independent Geometric Modeling A thesis submitted in partial fulfillment of the requirements for the degree of Doctor of Technical Sciences submitted to the Vienna University of Technology Institute of Geoinformation and Cartography Faculty of Mathematics and Geoinformation Advisory Committee: Univ.Prof.Dr. Andrew U. Frank Institute for Geoinformation and Cartography Vienna University of Technology Univ.Prof.Dr. Walter G. Kropatsch Institute of Computer Graphics and Algorithms Pattern Recognition and Image Processing Group Vienna University of Technology Submitted by MS. Rizwan Bulbul Gymnasiumstrasse Vienna Vienna,

4 3

5 i In the name of ALLAH, the most Gracious, the most Merciful Read! in the name of your Lord, Who created. Created man from a clot of congealed blood. Read! and your Lord is most Bountiful. He Who taught knowledge by the pen. Taught man that knowledge which he knew not. Al-Qur an (Chapter 96, Verses 1-5) Dedicated to my beloved parents. Dear Aajee and Buba it was possible all because of your prayers, your efforts spent for educating me, and your encouragement.

6

7 Acknowledgments First I owe sincere and earnest gratitude to my supervisor Prof. Andrew Frank for his guidance, advice, and support. He was always available whenever I needed him, helping, motivating, and encouraging me during the whole duration of my PhD studies. I also thank Prof. Walter Kropatsch for his insightful comments and guidance in writing of the dissertation. I wish to thank my wife, my brothers and sisters for their patience, for motivating me and being always around me. I feel obliged to all of my colleagues in the department who supported me at all levels, especially Farid Karimipour, Gehard Navratil, Gwen Wilke, Ivana Wechselberger, Amin Abdalla, Eva-Maria Holy, and Christian Gruber. I cannot forget to thank my friends in Vienna for their support and encouragement especially Aamir Habib, Dr. Basanta Raj Adhikari, Syed Khuram Shahzad, Guido Petillo, Abbas Chang, M. Hanif, and Shariq Bashir. I will always remember the time we spent together. I thank all my friends in Pakistan especially Muhammad Umer, Ejaz Hussain, Dr. Khaliq Aman, Munawar Hussain, Kashif Ali Baig, Shahrzad Khattak, Shahzad Shigri, Ajmal Hussain, Imtiaz Shah, Abdeen Ali Zia, Yousaf Ali, Masood Wali, and Meraj Ali. Friends in UK especially Arif Iqbal and Ali Abbas. Your good wishes and prayers always served as motivation for my achievements in life. Finally I wish to thank Higher Education Commission of Pakistan for funding my PhD studies. This dissertation would not have been possible without their financial support. I also acknowledge the support and administrative assistance provided by the OeAD office in Vienna (Austrian agency for international mobility and cooperation in education, science and research) during my stay in Vienna. iii

8

9 Abstract The thesis shows that the separation of metric and topological processing for GIS geometry is possible and opens the doors for better geometric data structures. The separation leads to the novel combination of homogeneous coordinates with big integers and convex polytopes. Firstly, the research shows that a consistent metric processing for geometry of straight lines is possible with homogeneous coordinates stored as arbitrary precision integers (so called big integers). Secondly, the geometric model called Alternate Hierarchical Decomposition (AHD), is proposed that is based on the convex decomposition of arbitrary (with or without holes) regions into their convex components. The convex components are stored in a hierarchical tree data structure, called convex hull tree (CHT), each node of which contains a convex hull. A region is then composed by alternately subtracting and adding children convex hulls in lower levels from the convex hull at the current parent node. The solution fulfills following requirements: ˆ Provides robustness in geometric computations by using arbitrary precision big integers. ˆ Supports fast Boolean operations like intersection, union and symmetric difference etc. Supports level of detail based processing. ˆ Supports dimension independence, i.e. AHD is extendable to n-dimensions (n 2). The solution is tested with three real datasets having large number of points. The tests confirm the expected results and show that the performance of AHD operations is acceptable. The complexity of AHD based Boolean operation is near optimal with the advantage that all operations consume and produce the same CHT data structure. v

10

11 Keywords Convex decomposition, geometric robustness, geometric modeling, geometric representation, spatial data modeling, dimension independence, level of detail, Boolean operations vii

12

13 Contents Acknowledgements Table of Contents List of Tables List of Figures iii ix xv xvii 1 INTRODUCTION Motivation Research Question and Approach Objective and Hypothesis Thesis Contribution Thesis Organization GEOMETRIC DATA REPRESENTATION: SURVEY Geometric Data Model Elementary representation schemes Hierarchical representation schemes Partition based schemes Decomposition based schemes Constructive solid geometry Topological representation schemes The Issue of Robustness in Geometric Computations Examples of robustness issues in geometric computations Convex hull computation Intersection computation of two polyhedra: Approaches to address the issue of robustness ix

14 x Exact approach Inexact approach or approximate geometry An Overview of Geometric Operations Survey Summary MODEL REQUIREMENTS The Requirement for Improved Robustness Improved robustness: The requirement Proposed solution: Arbitrary precision arithmetic with homogeneous coordinates Floating point numbers Integers with special arithmetic Big integers Rational numbers with big integers Homogeneous coordinates with big integers The Requirement for Geometric Primitive Geometric Primitive: The Requirement Proposed solution: Convex polytope The Requirement for Closed Geometric Operations Geometric Operations: The Requirement Proposed solution: Intersection of convex polytopes The Requirement for Level of Detail Level of detail: The Requirement Proposed solution: Hierarchical tree data structure The Requirement for Dimension Independence Dimension independence: The requirement Proposed solution: Convex polytope Requirements Summary SOLUTION: ALTERNATE HIERARCHICAL DECOMPOSI- TION Homogeneous Coordinates and Big Integers Experiment for testing the viability of big integers Ease of programming Performance Approach I Size of representation Approach I

15 xi Performance Approach II Size of representation Approach II Discussion on the viability of big integers for GIS Alternate Hierarchical Decomposition AHD: An Overview of the Approach AHD: An Example AHD: Convex Hull Tree AHD: Functions Build function Build example Build algorithm Build complexity Eval function Eval example Eval algorithm Eval complexity AHD: Characteristics Dimension Independent AHD Pseudocode: n-dimensional AHD Convex hull Computation n-dimensional AHD AHD: Level of Detail Solution Summary Robustness Closed Boolean operations Dimension independence Level of detail Number of components AHD BASED GEOMETRIC OPERATIONS Intersection Operation AHD based intersection computation Basic intersection operation: Convex-convex intersection Convex-nonconvex intersection Generic intersection operation

16 xii Intersection special cases Intersection solution characteristics Complement Computation Union Computation Difference and Symmetric Difference Computation Line-Region Intersection Computation Point in Polygon Test The PIP problem AHD based PIP computation Operations Summary AHD AND OPERATIONS: IMPLEMENTATION IN HASKELL Input Representation Implementation of AHD D implementation of AHD Geometric data types Geometric data structure AHD Algebra Instances for AHD algebra Dimension independent implementation of AHD Implementation of AHD based Geometric Operations AHD operations algebra Implementation of intersection operation Implementation of complement operation Implementation of union operation Implementation of difference and symmetric difference operations Implementation of point in polygon Implementation of Generalized LoD Data Structure Implementation of segment-region intersection Implementation of strip tree CONCLUSION AND FUTURE WORK Conclusion Is the use of big integers practical? How slow are big integers?110

17 xiii Is the combination of convex polytope and big integers attractive? Does the model support Boolean operations? Support for level of detail Dimension independence Performance analysis Future Work Support for non simple polygons Implemention of AHD in a database AHD based geometric modeling of buildings Bibliography 119 Appendix 129 A A Brief Introduction to Haskell 129 A.1 High Order Functions-Functors A.2 Haskell Types A.2.1 Generic data types A.2.2 Algebraic data types A.3 Classes in Haskell B Prototype Application 135 C Haskell Code 137 Biography of the Author 169

18

19 List of Tables 2.1 Summary of algorithms for Boolean operations Test program approaches used in experiment Characterization of the decomposition technique Special case treatment Functions of Input and Prim classes Operations on simplexes Description of the three test data sets Region statistics where r1, r2, and r3 are input regions: c1, c2 and c3 are the clip regions intersected with regions r1, r2, and r3 respectively: i1=(r1 c1), i2=(r2 c2) and i3 =(r3 c3) Time for AHD and intersection computation B.1 Description of AHD prototype GUI xv

20

21 List of Figures 1.1 Separation of metric and topological processing; possible approaches combined Properties of a geometric data model A region with the resulting quadtree (from wikipedia) CSG tree Geometric computation components Example to show robustness issue for 3D polyhedral intersection [Hoffmann, 2001] Fixed grid: some intersecting points are not on the grid points Adding a straight line to a simplicial complex Line with an envelope Two lines intersect, but the computed point is not on either line Projection of a homogeneous point to w = 1 plane [Bloomenthal and Rokne, 1994] Average time per intersection computation in µsec with related operations-approach I Number of digits per coordinate value approach I Average time per intersection in µsec with related operationsapproach II Number of digits per coordinate value approach II Input polytope and its convex decomposition CHT for demonstration example of Figure AHD steps. L represents the level, dr represents the delta region and ch represents the convex hull Pseudocode of the algorithm build that populates the CHT xvii

22 xviii 4.9 Pseudocode of QuickHull algorithm and its helping function qhull, which computes the sub hulls of partitions recursively AHD eval using merging of convex hull regions Pseudocode of the algorithm eval that processes the CHT to extract represented region AHD characteristics Approaches for dimension independent AHD n-dimensional AHD- An example for 3D case Simplexes of dimensions 0 to 3: node, edge, triangle, and tetrahedron Pseudocode of dimension independent incremental convex hull algorithm n-dimensional AHD AHD example for a nonconvex polygon The concept of LoD in AHD for example polygon in Fig The increasing level of detail from LoD0 to LoD2 increases the quality of approximation Different polygon intersection scenarios Intersection computation approach Convex-convex intersection computation Pseudocode of convex-convex intersection Convex-convex intersection example Convex-nonconvex intersection computation Pseudocode of convex-nonconvex intersection algorithm Convex-nonconvex intersection example Generic intersection operation Pseudocode of generic intersection algorithm Nonconvex-nonconvex intersection example Some special cases for intersection computation Complement R of a given region R A B Difference computation (A \ B example) Line-region intersection Line-region intersection steps AHD based point in a polygon test

23 xix 6.1 Hierarchy of geometric data types for region representation A Region R represented by two polygons Relationship between input representation and AHD The function f(x) with three approximations One piece of a linear function approximating the given function Test datasets and clip regions Intersection regions Relationship between time per point (in µs) and max. no. of nodes for AHD operations build and eval Relationship between time per point (in µs) on logarithmic scale and max. no. of nodes for AHD intersection operation AHD based geometric modeling of buildings A.1 Hierarchy of Haskell classes B.1 Screen-shot of AHD prototype

24 Chapter 1 INTRODUCTION 1.1 Motivation GIS manage the geometry of identified geographic objects together with descriptive data. Research in the field of representation of geometry in GIS was popular in the 1980s and 1990s, but recently somewhat less attention has been paid. The current solutions, both in commercial and research software, do not separate metric and topological processing. If the two, metric and topological processing, are separated as shown in Figure 1.1 and an interface between metric and topology established, then we can investigate independently (a) approaches for metric operations and coordinate representations and (b) the representation of the topology of geometric objects. This has been proved advantageous for the construction of libraries for computational geometry (for example, Computational Geometry Algorithms Library, CGAL 1 (computational geometry algorithms library) and LEDA (Library of Efficient Data Types and Algorithms)[Mehlhorn and Naher, 1999]) and is likely useful for GIS. Figure 1.1 shows 16 possible combinations shown by linking lines between the approaches for metric and topological processing. The attractive combinations are; ˆ the combination of floating point numbers with polytopes; not attractive because rounding errors will be difficult to control, ˆ the combination of big numbers with non-topological objects relations; 1 1

25 Chapter 1 - INTRODUCTION 2 Figure 1.1: Separation of metric and topological processing; possible approaches combined topology can be deduced consistently and equality of points checked, ˆ and big integers combined with polytopes. The combination of big integers with polytopes (shown with bold link in Figure 1.1) leads to a novel approach, radically different from the approaches advocated in current research e.g. [Penninga, 2008, Thompson, 2007]. This approach is attractive, because straight lines remain straight, independent of how many intersection points are computed (see problem in Figure 3.1) and all results are consistent. The current approaches for geometric modeling have limitations; the accuracy of computational results using current approaches is approximate. The problem of dealing with approximations is further aggravated by the pressing requirement of inclusion of 3D (e.g., city models) and temporal data (e.g., movements of people or cars) causing a re-evaluation of current approaches to geometric modeling. Revisiting the topic starting with fundamental question is thus warranted: ˆ The current systems use satisfactory solutions, but the code is complex. Extension of such solutions, for handling 3D and temporal data, appears difficult. ˆ The solutions for geometric computations in CAD (Computer Aided Design), e.g., CGAL, may be helpful but are not necessarily the best solutions for the GIS domain: For GIS we may restrict geometry to straight lines and exclude arcs of circle; this is the first distinction between GIS and CAD, where complex curves are necessary. The second distinction is that in GIS most points have to be inserted and the new points are very seldom constructed from previously computed ones.

26 Chapter 1 - INTRODUCTION Research Question and Approach The objective questions of the research are; ˆ Is the use of big integers practical? How slow are computations with big numbers? ˆ Is the combination of convex polytope and big integers attractive? ˆ Does the model support all operations (like intersection, union and symmetric difference etc.)? The research is planned in following steps; 1. Test the viability of big integers 2. Design the data model 3. Explore data model support for basic Boolean operations 4. Model verification with real data set 5. Test the model for offering additional support for ˆ Level of detail ˆ Dimension independence 1.3 Objective and Hypothesis The objective of this research is to develop a geometric model for the representation of arbitrary (convex or nonconvex, with or without holes) objects. The solution that will be based on the separation of metric and topological processing must fulfill these requirements, ˆ improved robustness in geometric computations (a requirement for metric part) ˆ simple geometric primitive ˆ efficient geometric operations e.g. intersection, union, symmetric difference and other (similar) operations

27 Chapter 1 - INTRODUCTION 4 ˆ generalization to n dimensions (n 2) ˆ level of detail oriented processing Hypothesis: The separation of metric and topological processing is possible if the issues of consistency in metric processing are addressed. 1.4 Thesis Contribution In this thesis I have showed that the separation of metric and topological processing for GIS geometry is possible and opens the doors for better geometric data structures. The separation leads to the novel combination of homogeneous coordinates with big integers and convex polytopes which is shown to be practical for the representation of GIS geometry that is guaranteed to be consistent. Firstly I showed that a consistent metric processing for geometry of straight lines is possible with homogeneous coordinates stored as arbitrary precision integers (so called big integers). An experiments is performed to test the performance and storage requirements of big integers for cascaded intersection computation and to confirm the expected result that big integers (performance wise) are not expensive for doing GIS geometry. Secondly I proposed a geometric model, called Alternate Hierarchical Decomposition (AHD), that is based on the convex decomposition of arbitrary (with or without holes) regions into their convex components. The convex components are stored in a hierarchical tree data structure, called convex hull tree (CHT), each node of which contains a convex hull. A region is then composed by alternately subtracting and adding children convex hulls in lower levels from the convex hull at the current parent node. The modularization in metric processing and topological treatment gives more freedom to design a data structure which supports the most important operations in a GIS. The important requirements for GIS today are listed as: ˆ Support for robustness in geometric computations ˆ Simple geometric primitive ˆ Fast processing of intersection, union, symmetric difference and other (similar) operations ˆ Generalization to n dimensions (n 2).

28 Chapter 1 - INTRODUCTION 5 ˆ Support for level of detail oriented processing. The proposed approach, AHD, fulfills theses requirements. Robustness in geometric computations is achieved by using arbitrary precision big integers. AHD is defined following an algebraic approach and uses convex polytope as a basic building block (geometric primitive) together with its related operations. This makes possible to achieve dimension independence (as convex hull computation is the main operation). The models hierarchical data structure makes the computations efficient especially if implemented in functional languages like Haskell that support lazy evaluation. Operations on arbitrary regions lead to nested traversal of the trees representing the regions and applying the corresponding operation on the convex building blocks. The algebraic approach suggest to add an operation complement to the Boolean operation union and intersection - which is unusual in GIS geometric processing. Implementation of union follows then using duality from A B = (A B). AHD has level of detail properties in the sense that all lower levels in the tree are included in and smaller than the current node. Tree traversals are thus reduced to the relevant path. Finally, the solution is tested with three real datasets having large number of points (in thousands). The tests confirm the expected results and show that the performance of AHD operations is acceptable. The complexity of AHD based Boolean operation is near optimal with the advantage that all operations consume and produce the same CHT data structure. 1.5 Thesis Organization The thesis is organized as follows; Chapter 2: This chapter will provide a comprehensive survey of geometric data modeling schemes. The issue of robustness in geometric computations will be discussed with some examples and solutions available in literature to deal with the issue. The last section will discuss the techniques for performing geometric operations. Chapter 3: This chapter will list the requirements for the geometric data modeling. This chapter will highlight the basic requirements of the solution for the metric and the topological processing, the requirement of support for Boolean and

29 Chapter 1 - INTRODUCTION 6 other related geometric operations, and additional requirements for supporting dimension independence and level of detail. Chapter4: This chapter will discuss the solution that fulfills the requirements listed in previous chapter. First experiment will be performed to show that the use of big integers for GIS geometry is viable from performance point of view. Next it will be showm that AHD as a geometric model fulfills the requirements listed in Chapter 3. AHD based on the convex decomposition of nonconvex polytopes using homogeneous big integer coordinates for metric processing is needed for performing robust linear geometry using projective geometry. AHD uses convex polytope as the basic geometric primitive that provides support for achieving dimension independence, closed operations and level of detail. Chapter 5: This chapter will provide the details of using AHD for performing closed geometric operations. The Boolean intersection is important as the intersection of two convex hulls is always convex. In addition, it is the most expensive operation computationally and other operations like union and difference (which are not closed over convexity) use it. Intersection and complement operations will be used to compute union and other Boolean operations using AHD. The pseudocode of algorithms is provided with appropriate examples that will help in understanding the algorithmic details. Chapter 6: This chapter will provide implementation details of all the algorithms presented in Chapter 5. The algorithms will be implemented in Haskell which is attractive because of its support for lazy evaluation, higher order functions, big integers and compact code. Chapter 7: In this chapter I will give the conclusion of my work with some results of AHD for three real datasets. Suggestions for future improvements will follow.

30 Chapter 2 GEOMETRIC DATA REPRESENTATION: SURVEY Spatial data models form abstractions from reality which include discretization of reality which is needed for the reality to be implementable on a computer system [Schneider, 1997a]. The digital representation of spatial or geometric data 1 describing reality is a key issue [Frank, 1992] and consists of the representation of geometry of the spatial objects and their associated non-geometric attribute values. The representation of geometry requires a suitable geometric data model. A geometric data model provides at an abstract level the geometric primitives and geometric operations supported by those primitives. The implementation of a geometric model involves mapping of geometric primitives and operations to geometric data structures and geometric algorithms respectively. For GIS the two major models are raster and vector (topological) [Frank, 1992, De Floriani et al., 1999]. The implementation of a geometric data model is characterized by the following properties and shown in Figure 2.1 (motivated by tutorial [Schneider, 2002], page 11). 1. Closure of geometric operations: The geometric primitives should be algebraically closed under geometric operations like intersection, union, difference and so forth. The results can then be used as inputs for further 1 The terms spatial and geometric are used as synonyms as for example by Schneider [1997b] 7

31 Chapter 2 - GEOMETRIC DATA REPRESENTATION: SURVEY 8 operations. For example, the intersection operation is closed as the intersection of two convex hulls is always convex. On the other hand, the union of two convex hulls is not a closed operation as the union of two convex hulls may be nonconvex. 2. Efficient data structure: Geometric primitives describe the structure of the spatial objects and geometric data structures define the storage structure and organization of primitives facilitating geometric operations to be performed efficiently and effectively. Geometric data structures together with geometric algorithms provide implementations details for achieving the desired behaviour of operations specified in the data model. Geometric algorithms realizing the spatial operations should be processed as fast as possible using efficient data structures and methods of computational geometry [Schneider, 1997a]. 3. Robustness of geometric computations: The representational model should take into account the fixed precision arithmetic available in computers. Current systems use much improved software for geometric computations, where all known holes were plugged. Will extending this software to 3D or temporal data require the same long period of gradual improvement? Industry standards like International Standard Organization s, ISO19107, is silent on the issue of final digital representation and considering the issue as an implementation issue, that is left to individual programmer to deal with. The same is true for Open Geospatial Consortium, OGC, specifications which are based on ISO standards [Alexandroff and Aleksandrov, 1961, Thompson, 2007]. This work reports details about the robustness issue and survey of approaches to resolve the issue in section Dimension Independence: Most of the approaches in literature are dimension specific, mostly 2D, 3D (e.g. [Penninga, 2008]) or some are for specific higher dimensions (e.g. 4D [Breunig, 2001], 5D [van Oosterom and Stoter, 2010]). Although some dimenion independent methods already exist e.g. [Günther, 1988a, Paoluzzi et al., 1993, Feito and Rivero, 1998], these approaches are not truly dimension independent from an implementation point of view because the underlying algorithms need to be coded separately for each dimension. The task of seprately coding for every dimension is laborious and needs lot of programming effort if an existing implementa-

32 Chapter 2 - GEOMETRIC DATA REPRESENTATION: SURVEY 9 Figure 2.1: Properties of a geometric data model tion needs to be redone from scratch for adding more dimensions. The need arises for dimension independent models in which a single implementation of which works for all dimensions e.g. [Karimipour et al., 2008]. 2.1 Geometric Data Model A geometric data model is used to describe a formalized abstract set of spatial object classes (geometric primitives e.g. point, line, face, region, volume, simplicial complex, regular polytope, convex polytope etc.) and operations performed on them. A geometric data structure is the specific implementation of a geometric data model which fixes the storage structure (e.g. a list, a graph or a tree etc) and set of algorithms which perform geometric computations [Frank, 1992] (which have two parts, numerical and topological or combinatorial computation see Figure 2.4) on the objects stored in the associated structure. In this section I will give a brief description of related research in the field of representation of geometry of spatial objects. Günther [1988a] categorizes the representation schemes in two, namely elementary representation schemes and hierarchical representation schemes Elementary representation schemes Elementary schemes do not represent an object by some combination of simpler objects of the same dimension, but from primitives of lower dimension. Elementary representation schemes include boundary based representations, sweep representation and skeleton representation. Boundary based representation schemes include techniques for 2D objects, vertex list for general polygons and Fourier descriptors [Zahn and Roskies, 1972, Persoon and Fu, 1977] for planar curves

33 Chapter 2 - GEOMETRIC DATA REPRESENTATION: SURVEY 10 Figure 2.2: A region with the resulting quadtree (from wikipedia) and for 3D objects including BRep 2 and wireform schemes. Sweep representation schemes are used for the representation of both 2D and 3D objects using a space curve which acts as the spine or axis of the object. Skeleton schemes represent a 2D or 3D object by means of a graph. They are not a general purpose representation scheme and useful for giving a rough, short description of an object Hierarchical representation schemes In these schemes the objects are represented by some combination of simpler objects of the same dimension. The most common hierarchical schemes include partition based or decomposition based schemes, constructive solid geometry and topology based schemes Partition based schemes In partition based schemes the object space is divided into non-overlapping partitions. Partition based schemes include region quadtree Samet [1984, 2006] (Figure 2.2), octree 3, strip tree [Ballard, 1981] etc. Partition based schemes are not used as a major representation scheme because they represent an approximation of the actual object using provided primitives and are sensitive to translation and rotation operators. 2 representation 3

34 Chapter 2 - GEOMETRIC DATA REPRESENTATION: SURVEY Decomposition based schemes In decomposition based approaches, the object is divided into parts that may overlap. The spatial data representation model by Ai et al. [2005], uses hierarchical convex based polygon decomposition approach for multi scale organization of vector data on spatial data servers. Their approach has a run time 4 of O(nlog 2 n) and is complex separately dealing holes from the rest of the polygon and no implementation details provided. The work by Keil [2000] focuses on decomposition of orthogonal polygons. Another hierarchical strategy by Lien and Amato [2006] decomposes a polygon with or without holes into its approximate convex components. Their algorithm results smaller set of approximately convex components efficiently in time 5 O(nr). Chazelle and Palios [1990] have proposed a triangulation based algorithm for the problem of partitioning a polytope in R 3. algorithm requires O(n + r 2 ) space and runs in O((n + r 2 )logr) time. A similar work in the pattern recognition domain has been done by Badawy and Kamel [2005], presenting a convex hull based algorithm for concavity tree extraction from pixel grid of 2-D shapes. The Convex decomposition: The problem of decomposing a nonconvex object into its convex components is known as convex decomposition and has applications in diverse domains ranging from pattern recognition, motion planning and robotics, computer graphics and image processing, etc. [Chazelle and Palios, 1990, Lien and Amato, 2004, 2006, Xu, 2007, Liu et al., 2008]. The application of decomposition techniques in the spatial data modeling domain is seldom treated in literature, only few address the issue in the spatial database domain [Kriegel et al., 1991, Ai et al., 2005]. The object representations based on simpler geometric structures are more easily handled [Fernandez et al., 2000] than complex structures. The algorithms for convex objects are simple and run faster than for arbitrary objects [Schachter, 1978, Kriegel et al., 1991, Bajaj and Dey, 1992, Palios, 1992], for example, the decomposition of complex spatial objects into simple components considerably increases the query processing efficiency [Kriegel et al., 1991]. Classification criteria for decomposition appraoches: The decomposition approaches are classified based on the following criteria [Kriegel et al., 1991, Keil, 2000, Lien and Amato, 2006]; 4 n is the number of vertexes 5 r is the number of notches or delta regions or concavities

35 Chapter 2 - GEOMETRIC DATA REPRESENTATION: SURVEY 12 A. Type of sub-polygons (components) Depending on application, different decompositions can result in variety of components, e.g, convex, star-shaped, or fixed orthogonal shapes. B. Type of polygon being decomposed Decompositions can also be classified on the basis of input polygons, e.g., closed or open, simple or connected, with or without holes, etc. C. Relation of sub-polygons Decompositions that result in components, which do not overlap except at boundaries, are classified as partitioning. Other decompositions allowing component overlaps are classified as covering. D. Objective function Most of the decompositions are classified based on the objective function. The two broad categories are decompositions that minimize the number of convex components and decompositions that minimize computational complexity in terms of execution time. E. Dimension specific or dimension independent Decomposition approaches can also be classified depending on the input polygon dimension. The majority of the decomposition techniques in literature are dimension dependent and mostly applicable in 2-D and 3-D [Palios, 1992] cases only Constructive solid geometry 6 Constructive solid geometry (CSG) together with boundary representation is an important representation scheme in current CAD and CAM. In constructive solid geometry a 3D object is represented by 3D volumetric primitives and a set of geometric operators. Typically the primitives are simple shapes like cuboids, cylinders, prisms, pyramids, spheres, cones and operator are the Boolean set operators intersection, union and difference. The real advantage of constructive solid geometry is that basic primitives can be parametrized (thus scaling, translating 6 solid geometry

36 Chapter 2 - GEOMETRIC DATA REPRESENTATION: SURVEY 13 Figure 2.3: CSG tree and rotating the primitives) and therefore less storage space is needed [Penninga, 2008]. The data structure used is a binary tree, CSG tree (Figure 7 2.3), whose nodes correspond to the operators while the leaf nodes correspond to primitives Topological representation schemes The most common approach is the polyhedron approach in which the boundary of a 3D object is represented by polygonal faces. The polyhedron approach may have implicit topology or explicit topology. The concept of polyhedral chains by Günther [1988a] using convex chains (cells) is a representation scheme for polyhedra in arbitrary dimensions. Cells are represented as intersection of half spaces, encoded in a vector. Winged scheme [Paoluzzi et al., 1993] based on simplicial decompositions is a representation scheme for piecewise-linear polyhedra of any dimension and curved polyhedra which are approximated by simplicial maps. The objects are collected into structures which allowto combine bothother structures and primitive objects with affine transformations and higher order operators. An irregular subdivision of space contains nonconvex regions. A region is defined as a set of polygons [Rigaux et al., 2002], most of them may be nonconvex. The representation of geometry of convex regions as a collection of inequalities as y y ax + b has been proposed in [Günther, 1988a, Günther and Wong, 1989]. Penninga [2008] presents a new topological approach for 3D data modeling based on a tetrahedral network (called TIN or TEN) defined using simplicial complexes. Hui et al. [2006] proposed a representation method for non-manifold 3D shapes described as 3D simplicial complexes through a decomposition based approach. 7 Source: solid geometry

37 Chapter 2 - GEOMETRIC DATA REPRESENTATION: SURVEY The Issue of Robustness in Geometric Computations The issue of robustness in geometric computations is a well known and challenging problem in the implementation of geometric algorithms [Hoffmann, 1989, Li et al., 2005]. In general, the geometric algorithms are designed based on two assumptions. First, the inputs are in general position meaning that degenerate input is precluded [Hanniel and Wein, 2007]. Second, geometric algorithms are designed under a computational model that assumes exact computation with socalled real RAM model in which the quantities are allowed to be arbitrary real numbers 8. However, these assumptions are not reliable in practice. The input data may be erroneous and quality of the data may be questionable. Also, in real implementations of geometric algorithms, exact arithmetic is approximated by finite precision floating point arithmetic making the implementation notoriously difficult [Egenhofer et al., 1990, Burnikel et al., 1999]. The implementations based on approximations work well for majority of the geometric problem instances, but occasionally fail as the rounding errors due to fixed precision can cause catastrophic errors [Schirra, 1998] including program crashes, infinite loops, wrong and inconsistent results. The issue of robustness in geometric algorithms arises from the special nature of geometric computation as it not only consists numerical part but also the combinatorial part [Li et al., 2005]. The numerical part is further divided into two parts termed predicate and constructor [Shewchuk, 2009]. Numerical part, is therefore, used in the computation of geometric predicates (e.g. is a given point on a line?) and construction of new geometric objects (e.g. computation of the intersection point of two intersecting lines). The numerical computation, especially the predicate component is used for determining the combinatorial relations among geometric objects, shown by a bold arrow in the Figure 2.4. The fixed precision arithmetic provided by machines can produce numerical errors leading to inconsistencies, which in turn may lead to inconsistent combinatorial structures or inconsistent program states [Li et al., 2005]. The importance of the robustness in geometric algorithms is evident by the wide range of their application domains ranging from computer aided design (CAD), computer aided manufacturing (CAM), computer aided engineering (CAE), 8 jrs/meshpapers/robnotes.pdf

38 Chapter 2 - GEOMETRIC DATA REPRESENTATION: SURVEY 15 Figure 2.4: Geometric computation components image processing, computer graphics, robotics and GIS. In all these domains, the geometric operations based on fixed precision arithmetic may lead to inconsistent results or complete algorithmic crashes because of rounding errors in computations. Early GIS research focused among other things on overlay calculations (e.g., [Chrisman et al., 1992]). In the late 1980s the results on testing overlay operations in the then available commercial GIS were disastrous. The result was disastrous: none could perform the (intentionally difficult) problem without errors; many of the program s operations stopped unexpectedly and others produced substantially wrong answers. The issue of robustness makes the process of algorithm development costly and hinders full automation [Smith, 2009] and may lead to inconsistent combinatorial structures or inconsistent program states [Li et al., 2005]. First I will discuss some geometric algorithms from literature to illustrate the issue of robustness in geometric computations and then discuss the methods used to resolve the issue Examples of robustness issues in geometric computations Convex hull computation Kettner et al. [2008] have shown an example of the failure of an algorithm for the computation of incremental convex hull for a finite set of points in 2D. The incremental convex algorithm starts by taking any three non-collinear points and then adding points one by one. Whenever a point is added, it is checked whether to be inside or outside the previously computed convex hull. If it is inside the

39 Chapter 2 - GEOMETRIC DATA REPRESENTATION: SURVEY 16 convex hull, nothing changes, otherwise, the convex hull is recomputed with the new point to get an updated hull. The mathematical predicates needed for implementing the algorithm are; Orientation Predicate: Given three points p = (p x, p y ), q = (q x, q y ), and r = (r x, r y ) the predicate tells whether the points are oriented clockwise, counterclockwise or collinear. The arithmetic value that determines the value of the predicate is the signed area function defined as; twicearea(p, q, r) = (q x =p x )(r y =p y )=(q y =p y )(r x =p x ) (2.1) Equation 2.1 computes the twice the area of the triangle made by three points p, q and r. The sign of the area in equation 2.1 provides the orientation state i.e. orientation(p, q, r) = sign(twicearea(p, q, r)) (2.2) > 0 counterclockwise < 0 clockwise = 0 collinear Positive sign in equation 2.2 denotes the counterclockwise orientation, while negative denotes the clockwise and zero value shows that the points are collinear. When the orientation predicate is implemented using floating point arithmetic, the three potential ways in which the result could differ from the correct orientation are mentioned by Kettner et al. [2008]: ˆ rounding to zero: + or = signs are miss-classified as 0; ˆ perturbed zero: 0 is miss-classified as either + or = ; ˆ sign inversion: + is miss-classified as = or vice-verse. Visibility Predicate: Given an edge e = (p i, p i+1 ) and a point q, the predicate determines whether the point q is visible to edge e or not. The visibility predicate is deduced from the orientation predicate. visible((p i, p i+1 ), q) = orientation(p i, p i+1, q) (2.3) Negative orientation i.e. (twicearea(p i, p i+1, q)) < 0 means that the point q is visible to edge e = (p i, p i+1 ), and weakly visible if (twicearea(p i, p i+1, q)) 0.

40 Chapter 2 - GEOMETRIC DATA REPRESENTATION: SURVEY 17 Kettner et al. [2008] have identified two key properties for the operation of the algorithm; Property A: A point p is outside a convex hull, ch, iff p is visible to any edge of the ch. Property B: For a point outside ch, the weakly visible edges of ch make a nonempty subset of consecutive edges of ch. Likewise the edges not weakly visible make a nonempty subset of consecutive edges of ch. The algorithm is based on these two properties. Suppose that (v i, v i+1 ),..., (v j=1, v j ) is the sub-sequence of weakly visible edges of ch, then the updated hull is obtained by replacing the sub-sequence (v i+1,...,v j=1) by p. Thus the key algorithmic steps are; 1. Determination of any visible edge from p: This is done iteratively using the visibility predicate over the list of convex hull edges L. If no visible edge, then p is neglected. Otherwise, continue with a any visible edge e to next step. 2. Determination of weakly visible edges from p: This is also done by using visibility predicate. Starting with any visible edge e, iterate over L in counterclockwise direction until a non weakly visible edge is encountered. The step gives the subset sequence (v i, v i+1 ),..., (v j=1, v j ) of L. 3. Updating of Convex hull: The edges of subset sequence determined in previous step (v i, v i+1 ),..., (v j=1, v j ) are removed from L and two new edges (v i, p) and (p, v j ) are added to L. The properties A and B may not, however, may not hold for computations done with floating point arithmetic.kettner et al. [2008] have identified four logical ways to negate the properties A and B: Failure 1: There is not any visible edge for a point outside the current hull. Failure 2: There is a visible edge for a point inside the current hull. Failure 3: All the edges of the convex hull are visible for a point outside the current hull. Failure 4: There is a non-contiguous set of visible edges for a point out the current hull. Kettner et al. [2008] have provided concrete examples to demonstrate these failures. The effects of these failures could be as shown by Kettner et al. [2008] are;

41 Chapter 2 - GEOMETRIC DATA REPRESENTATION: SURVEY 18 (a) Intersection of a cube with a tetrahedron (b) Possible inconsistent face partitions Figure 2.5: Example to show robustness issue for 3D polyhedral intersection [Hoffmann, 2001] ˆ The algorithm computes a convex polygon, but misses some of the extreme points. ˆ The algorithm crashes or does not terminate. ˆ The algorithm computes a non-convex polygon Intersection computation of two polyhedra: Another example of failure of geometric computation drawn from polyhedral intersection is given by Hoffmann [2001] as shown in Figure 2.5a. The intersection is done by computing the face-face intersection points i.e. by computing the intersection points of edges of one solid with the faces of the other solid. Assuming that the the front edge of the tetrahedron, e FT, cuts the top face of the cube, f TC, at a steep angle and the front face of the cube, f FC, at a shallow angle, it is possible that the intersection e FT f TC deemed to be in the interior of the face as shown by A in Figure 2.5b while the intersection e FT f FC may be deemed to lie on e FT as shown by B in Figure 2.5b. The two partitions resulted from incidence decisions are logically inconsistent, because the front face of the tetrahedron, f FT, now intersects twice, one with f TC and one with f FC at A and B respectively as shown in Figure 2.5b. This situation leads to the failure of the intersection algorithm.

42 Chapter 2 - GEOMETRIC DATA REPRESENTATION: SURVEY Approaches to address the issue of robustness The state of the art is best reflected by libraries like CGAL and LEDA[Mehlhorn and Naher, 1999]. It has been pointed out that one way out of the rounding problem is to compute each value only once [Knuth, 1992]; contradiction is then logically impossible (also described as Do not ask stupid questions [Fortune, 1989]). This had been the guiding idea for Frank and Kuhn [1986] earlier. Hoffmann [2001] identifies three categories of strategies to address the robustness problem; 1. Using exact arithmetic (integer arithmetic, extended precision arithmetic, nonstandard or symbolic arithmetic). 2. Using symbolic reasoning (reuse previously computed results) 3. Using reliable calculations (interval arithmetic) These approaches can broadly be divided into two categories based on either using inexact or exact arithmetic[li et al., 2005, Smith, 2009]; 1. Inexact approaches: Approaches based on inexact arithmetic - making fixed precision robust. 2. Exact approaches: Approaches based on exact arithmetic - making exact approach viable Exact approach This approach uses the exact rational arithmetic to avoid the problems associated with fixed precision floating point arithmetic. The computation is done with a precision that is sufficient to keep the theoretical correctness of an algorithm, thus allowing exact implementation of algorithms developed for real arithmetic without modifications. However, there is criticism for using an exact approach as it is thought to be slow computationally, especially for cascaded operations where the output of one operation is used as input of another operation [Schirra, 1998, Li et al., 2005]. The two problems that make an exact approach complicated are [Hoffmann, 2001]; 1. Proliferation: If the input representation of a geometric computation has a precision of k digits, the output may require a multiple of that precision to

43 Chapter 2 - GEOMETRIC DATA REPRESENTATION: SURVEY 20 Figure 2.6: Fixed grid: some intersecting points are not on the grid points be representable e.g. consider the intersection computation of line segments (whose point coordinates are represented by fixed precision) in a fixed grid as shown in Figure 2.6. It is seen that, while some of the intersection points are representable being on the grid points, others are not. That is, the input points have a precision of k digits, the output computed points need a multiple of input precision to be representable. For cascaded operations, this may lead to an exponential growth in the required precision. 2. Irrationality: Some computations may result in output which is not representable in the given fixed precision e.g. consider rotating a unit square, whose vertex coordinates are represented by fixed precision, by 45. The new vertex coordinates of the rotated square now involve radicals and are irrational. Franklin [1984] has also shown that scaling or rotating an object can cause a point to move to the other side of a line, thus failing point inclusion tests. Many geometric algorithms may involve computations involving integers and or rationals. Every rational value can be represented by a pair of integer values indicating the numerator and denominator. Infinite precision rational numbers are also suggested by [Franklin, 1984] has the advantage of satisfying the mathematical field axioms [Thompson, 2007]. The issue with overflow in such computations can be avoided using arbitrary precision arithmetic provided by big number software packages, arbitrary precision integer (for integers aka big integers) and arbitrary precis on rational (aka big rational represented by a pair of big integers). Many software libraries and programming languages provide support for big number packages e.g. LEDA [Mehlhorn and Naher, 1999]. The functional pro-

44 Chapter 2 - GEOMETRIC DATA REPRESENTATION: SURVEY 21 gramming language Haskell [Jones and Jones, 2003] also provides support for arbitrary precision integers, also known as big integers. However, the use of big integers is not encouraged in the literature accounting for slowing down the computation especially the cascaded computations. Karasick et al. [1991] have reported that the implementation of 2D Delaunay triangulation using arbitrary precision arithmetic is 10, 000 times slower than floating point implementation. Computing exactly may not always be needed. Thus, the computational efficiency of geometric algorithms involving exact computation using arbitrary precision arithmetic can be improved by technique of adaptive evaluation (also known as lazy evaluation). Adaptive evaluation computes exactly only if it is necessary to do so, otherwise it uses the speed of approximate arithmetic (floating point arithmetic). The simplest form of adaptive evaluation is to use filters e.g. floating point filter, which filters computations where floating point arithmetic gives the correct result. A filter compares the absolute value of the computed numerical value of the expression to the error bound. If the error bound is smaller, the computed approximation and the exact value have similar sign. Otherwise, the expression is reevaluated using exact arithmetic. Depending on the computation of error bounds, filters are classified as static or dynamic. In case of so called static filters [Fortune and Van Wyk, 1996], error bounds are computed a priori if the specific information on the input data is available. Static filter is efficient because it makes use of information known at compile time [Smith, 2009]. On the other hand, dynamic filter computes error bounds on the fly using the run time information and so is less efficient. Franklin [1984] discusses the idea of using interval arithmetic in which real numbers are represented by intervals, whose endpoints are floating point numbers. The interval representing the exact value of an operation is computed by floating point operations on the endpoints of the interval representing the operands. The lower and upper bounds of a value are thus rounded to nearest or the rounding mode is changed to rounding toward and + respectively [Schirra, 1998]. Fortune [1995] has showed that boundary based polyhedral modeling supporting regularized set operations can be implemented using exact arithmetic with minimal performance overhead compared to floating point arithmetic.

45 Chapter 2 - GEOMETRIC DATA REPRESENTATION: SURVEY Inexact approach or approximate geometry As discussed, the algorithms based on fixed precision arithmetic may fail occasionally because of the rounding off errors. Exact computation is thought as being computationally expensive, so inexact methods which can tackle the robustness issue are used. Avoiding inconsistencies among decisions is a primary goal in achieving robustness in implementations with imprecise arithmetic [Schirra, 1998]. With approximate geometry, the method of representation and the constraints that apply are selected to maintain certain properties and ensure correct behavior of the algorithm [Smith, 2009]. Some design principles for robustness under computation with imprecision as listed by Schirra [1998] follow. Representation and model approach introduced by Hoffmann et al. [1988] formalizes the compute the correct solution for an input idea [Schirra, 1998]. The model distinguishes between the models (real mathematical objects), and their computer representations. An algorithm is correct if the model corresponding to the computed output representation is the solution to the problem for the model corresponding to the input representation. For proving the robustness of an algorithm, it is needed to show that there is always a model for which the algorithm takes correct decisions. But this is a highly non-trivial task [Schirra, 1998]. Epsilon geometry introduced by Salesin et al. [1989] is a theoretical framework in which the predicate returns a real number instead of a Boolean. The technique computes an exact solution for a perturbed version of the input and returns a bound on the size of this implicit perturbation. Epsilon geometry has been applied to few basic geometric primitives and the framework seems difficult [Schirra, 1998]. Topology oriented approach focuses on the topological and combinatorial correctness than numerical correctness (e.g. simulation of simplicity [Edelsbrunner and Mücke, 1990], Realms [Güting and Schneider, 1993], ROSE algebra [Güting and Schneider, 1995]). The decisions based on numerical computations that may lead to topological inconsistencies or violations are not taken and are replaced by topology conforming decisions. This is achieved by providing set of rules, following these lead to topological consistency [Schirra, 1998]. In a most recent work, Smith [2009] has provided two algorithms for performing Boolean operations on piecewise linear shapes. The algorithms are guaranteed to generate a topologically valid result from topologically valid input. Simplex based approaches fall into the same class of topology based appraoch

46 Chapter 2 - GEOMETRIC DATA REPRESENTATION: SURVEY 23 Figure 2.7: Adding a straight line to a simplicial complex and they define the world with points, line segments and tetrahedrons. Inserting all geometry into a simplicial complex was proposed by Frank and Kuhn [1986] where presentations stress formal definitions building multi-sorted algebras. This means that every point including any intersection point is inserted in a triangulation [Egenhofer et al., 1990]; the arithmetic precision of this process is not important (it was described as oracle ). Important is that all topological relations are deduced from the topology of the triangulation no repetition of finite precision computation is permitted, to avoid inconsistencies by asking stupid questions i.e. question to which the answers are already known. The disadvantages of this solution are; (1) processes to insert new points or lines establish topology with relation to all nearby objects, which may never be of interest resulting in large amounts of unnecessary computations and (2) straight lines are broken in small pieces when they are inserted into the simplicial complex and their straightness may be lost due to rounding (Figure 2.7). The construction of the simplicial complex produces a large number of smaller objects [Egenhofer et al., 1990]. A commercial implementation (TIGRIS Intergraph, [Herring, 1991]) avoided the division to triangles and used a generalization of simplicial complexes, namely cell complexes, but lost also the advantage of the fully defined topology. The approach relates to quad edge algebra for partitions [Guibas et al., 1983]. Numerous investigations in computing geometry with integers, dubbed geometry on a grid. Such approaches often consider the envelope of a line as the set of grid points and the intersection points of this line with other lines may belong (see Figure 2.8) to this set of grid points [Greene and Yao, 1986]. The method of [Güting and Schneider, 1993] has been built on a special geometric engine to compute geometry in which certain types of errors are avoided.

47 Chapter 2 - GEOMETRIC DATA REPRESENTATION: SURVEY 24 Figure 2.8: Line with an envelope 2.3 An Overview of Geometric Operations Boolean operations on geometric data have been studied in diverse domains ranging from image processing, computer graphics [Weiler and Atherton, 1977, Thibault and Naylor, 1987, Greiner and Hormann, 1998], robotics, CAD and CAM [Lauther, 1981, Paoluzzi et al., 1993]. Here I provide a brief survey of algorithms for performing intersection, union and symmetric difference operations and Table 2.1 provides a summary of the surveyed literature for Boolean operations. In GIS Boolean set operations are essential for the manipulation of spatial data needed for performing spatial queries e.g for overlay operations, clipping etc. Traditional algorithms may fail because of the robustness issues in geometric computations and (or) may need special preprocessing of degenerate cases. Many algorithms for Boolean operations on polygons have been reported in the literature. The preliminary work by Shamos and Hoey [1976] provided a basis for geometric intersection problems. They have shown that the intersection of two simple plane n-gons can be detected in O(nlogn). The intersection of two convex n-gons and two nonconvex n-gons can be computed in O(n) and O(n 2 ) respectively. The Wieler-Atherton algorithm [Weiler and Atherton, 1977] for intersection of two simple polygons with vertexes n and m of any shape with or without holes has the worst time complexity of O(nm). Bentley and Ottmann [1979] gave the classical sweep line algorithm for counting and reporting all intersections by extending the work by Shamos and Hoey. They provided an algorithm for reporting all k intersections between two general planar objects in O(nlogn + k logn). The work by Bentley and Ottmann was further extended by Lauther [1981], and the reported sweep line algorithm for intersection computation has the expected time complexity of O(n log n). Another O(n) time algorithm was presented by

48 Chapter 2 - GEOMETRIC DATA REPRESENTATION: SURVEY 25 O Rourke etal [1998]. The algorithm is simple but is limited to convex polygons only. The two plane sweep algorithms by Nievergelt and Preparata [1982] compute the geometric intersection of two nonconvex polygons in O((n+k)logn) and two convex polygons in O(nlogn + k). The polygons can have self intersecting edges but degenerate cases are not tackled. The data structure is complex and implementation details are not given. The work by Chazelle and Dobkin [1987] provides lower bounds on algorithms for intersection of convex objects in two and three dimensions. Their work is based on the assumption that the intersecting objects are available in random access memory, eliminating reliance on linear input reading time. The time bounds for two convex polygons in 2D and two convex polyhedra in 3D cases are O(logn) and O(log 3 n) respectively (in 3D case an additional multiplicative factor of logn for data structure preprocessing for standardization). The work by Margalit and Knott [1989] presents an algorithm for set operations on polygon pairs having worst time complexity of O(n 2 ). They give partial correctness proof of their solution and implementation is discussed but is still complex and not easily understandable. The approach by Rappoport [1991] for the representation of n- dimensional polyhedra called extended convex difference tree (ECDT) extends the convex difference tree approach. The approach can deal only two polygons and can not deal with holes and islands. It also needs special topological processing to avoid the robustness issues. The state of the art for finding all intersections among segments is given by Chazelle and Edelsbrunner [1992]. The algorithm by Vatti [1992] is for clipping arbitrary polygons against arbitrary polygons. The polygons may be convex, concave or self intersecting. However, self intersecting polygon is converted to a non-intersecting polygon by inserting the points of intersection during the clipping process. The algorithm also supports polygon decomposition by allowing the output in the form of trapezoids if required. The solution is complex and implementation is not easy. Its performance has not been proved asymptotically, rather a comparison with traditional clipping methods is provided. The algorithm proposed by Greiner and Hormann [1998] also deals clipping arbitrary polygons like Vatti s algorithm. However, it is a simple algorithm based on the boundary segment manipulation and performs better than Vatti s algorithm over randomly generated general polygons. The data structure is a doubly link list or lists in case of multiple polygons. Only few degenerate cases are mentioned and it can not treat overlap degeneracies. The solution is limited for 2D polygons

49 Chapter 2 - GEOMETRIC DATA REPRESENTATION: SURVEY 26 and robustness issues related to the fixed precision floating point arithmetic are not considered. The algorithm by Rivero and Feito [2000] to calculate Boolean operations for general planar polygons (manifold and non manifold, with and without holes) is based on simplicial chains and their operations. The strategy has been demonstrated for 2D and claimed to be valid for 3D polyhedra. The algorithm does not need special treatment of degenerate cases, and has same time complexity as the Greiner s algorithm. The slight modifications in the work of Rivero and Feito by Peng et al. [2005] resulted in an algorithm which has been shown to be more efficient (execution time less than one third of that by Rivero and Feito). CGAL [Fogel et al., 2006] provides Boolean operations for polytopes in 2-dimensional Euclidean space. Robustness is ensured through the use of exact arithmetic. The regularized operations are provided for two simple polygons with or without holes. The time complexity is O(n 2 ) for simple polygons. The algorithm by Kui Liu et al. [2007] is for clipping arbitrary polygons with holes. The algorithm is based on segment manipulation and works by classification of intersection points into entry or exit points. Unlike the solutions by Vatti and Greiner, this algorithm uses a single linked list data structure and performs better than Vatti s solution for smaller number of input points. The solution is limited to 2D polygons and modifications are needed for dealing multiple polygons and holes. The degenerate cases are specially treated and the methods are demanding having difficult implementation. The algorithm by Martínez et al. [2009] is based on classical plane sweep algorithm for computing intersections performing in time O((n + k)logn). They claim the solution works for general polygons, although its working for polygons with holes is not demonstrated. Algorithmic details are given but the implementation issues are not discussed. The implementation seems difficult and edge overlaps are specially treated. Dimension independence and robustness issues are not discussed. 2.4 Survey Summary In this chapter I provided a literature survey of geometric modeling schemes. The implementation of a geometric data model is should satisfy the following requirements; (1) closed geometric computations, (2) robustness in geometric computations, (3) dimension independence, (4) efficient data structure, and (5) support for level of detail. The surveyed literature shows that the geometric modeling approaches to date satisfy some of these requirements and none of

50 Chapter 2 - GEOMETRIC DATA REPRESENTATION: SURVEY 27 Table 2.1: Summary of algorithms for Boolean operations Algorithm Operations Scheme Dim Robust Holes Complexity [Hoffmann et al., 1989] [Rivero and Feito, 2000] [Martínez et al., 2009] [Karinthi et al., 1994] [Milenkovic, 1995],, star-edge 3D yes yes,, simplicial 2D no yes chains,, plane sweep 2D no yes O((n + k)logn),, 2D no yes O(max(2logm, log 2 n)),, line segment arrangement [Lauther, 1981],, vertical line sweep [Günther, polyhedral 1988b] chains 2D yes no claimed to be linear but not proved 2D no yes O(nlogn) 3D and more no yes poly-logarithmic [Margalit and Knott, 1989],, BRep 2D yes yes O((n + m + k) log(n + m + k)) [Paoluzzi et al.,,, BSP nd yes no 1993] [Peng et al.,,, Simplex 2D no yes ] [Smith and,, BRep 3D yes yes O(nlogn) Dodgson, 2007] [Kui Liu et al.,,, Edges 2D no yes 2007] [Greiner and Vertex or 2D no yes O(n 2 ) Hormann, 1998] Edge [O Rourke, Sweep line 2D no no O(n log n + k) 1998] pages: [Bentley and Sweep line 2D no no O(nlogn + k logn) Ottmann, 1979] [Shamos and Sweep line 2D no no O(n 2 ) Hoey, 1976] [Nievergelt and plane sweep 2D no no O((n + k) log n) Preparata, 1982] [Vatti, 1992] scan beam 2D no no (classic plane sweep) [Sabau, 2008] sweep line 2D no yes - [Weiler and Atherton, 1977] Vertex or Edge 2D no yes O(n 2 ) * means regularized operations n and m stand for number of vertexes k stands for number of intersections

51 Chapter 2 - GEOMETRIC DATA REPRESENTATION: SURVEY 28 these satisfy all of the aforementioned requirements. Therefore, the need arises for a geometric data model that provides all the properties, all in one, and that provides ease of implementation and understanding.

52 Chapter 3 MODEL REQUIREMENTS The proposed model for representation of geometry of objects is based on the basic idea of separation of metric and topological processing as discussed section 1.1 and shown in Figure 1.1 on page 2. The model has been designed keeping in mind the requirements the model should fulfill. In this chapter I will discuss the model requirements and proposed solutions to fulfill these requirements. 3.1 The Requirement for Improved Robustness Improved robustness: The requirement Current commercial approaches in GIS use floating point numbers and hope that the resolution is enough to avoid problems due to finite precision arithmetic used. Computations with floating numbers may produce contradictory results difficult to deal within numeric processing and particularly difficult for geometric operations. Geometric calculations in finite precision arithmetic can yield results that contradict geometric reasoning. Years ago, Franklin in a landmark paper [Franklin, 1984], has given instructive examples. Line intersections are most important in GIS (e.g., in overlay computations). Two lines AB and CD intersect at point P as shown in Figure 3.1. If test the coordinates of point P, we may find that P is neither on line AB nor on line CD. Such cases occur and are caused by the rounding of results to finite precision. Modern floating point implementations of the IEEE 754 standard, found on most 29

53 Chapter 3 - MODEL REQUIREMENTS 30 Figure 3.1: Two lines intersect, but the computed point is not on either line current hardware, have reduced glaring shortcomings. Nevertheless, the numeric example shown in Figure 3.1 which uses single precision floating point numbers, demonstrates that the problem occurs because of the rounding errors caused by fixed precision. Figure 3.1 shows that testing whether the intersection point P is on the two lines comes out negative always. Increasing the length of the floating point numbers, which increases mostly the precision of arithmetic operations, reduces but not completely eliminates such vexing problems. Still such problems occur which are not really found and fixed during debugging. This is especially annoying concerning computation of overlay operations in GIS [Chrisman et al., 1992] Proposed solution: Arbitrary precision arithmetic with homogeneous coordinates The possible approaches for metric processing are; Floating point numbers Floating point numbers approximate real numbers with two restrictions: (1) they are bounded in the sense that there is a largest and smallest floating point number of a given representation and (2) computations give approximate results because resolution is limited. Especially annoying is that results of computations are not invariant under translation. Results may differ when a configuration is shifted, the computation performed and the result shifted back compared with the computation directly done.

54 Chapter 3 - MODEL REQUIREMENTS Integers with special arithmetic Using integers gives results, which are invariant under shifting; integers are equally spaced, whereas floating point numbers are concentrated around 0 and sparser the further away from 0. Care is necessary to remain within the bounds of standard integers (typically ). Intersections of lines do not necessarily result in an integer but a rational. The proposals for geometry on a grid avoid the problem shown in Figure 3.1 but they are complex and not easily convincing that they cover all possible unfortunate inputs Big integers Integers of varying size give arbitrary-precision arithmetic (sometimes imprecisely called infinite precision arithmetic because the number of digits is both finite and bounded in practice). The precision and the size of these integers are only limited by the size of the available memory; for this reason they are called big integers. Modern computer software includes routines for arithmetic with big numbers (packages like big integer, big floating point and big rational supporting arbitrary precision arithmetic), as this alleviates programs from errors with overflow considerations, which if not properly handled, will lead to erroneous results [Goldenhuber, 1997] or crash. Computation with big numbers is said to be very slow and complicated [Fortune and Van Wyk, 1996, Yap, 1997, Li et al., 2005]. Three issues are raised against the use of big number arithmetic for geometry in GIS: ˆ difficult implementation, ˆ slow execution, ˆ memory intensive The viability of using big integers depends on the effective performance of geometric operations typical for GIS with big integers. In the next chapter I will perform experiments to test the viability of using big integers for doing GIS geometry. I will present the results of an experiment to determine whether solutions using big numbers are realistic for GIS.

55 Chapter 3 - MODEL REQUIREMENTS Rational numbers with big integers. The geometric constructions with straight lines can be performed with rational numbers; the topological relations between regions can be derived precisely from coordinates. Floating point numbers are necessary if circles, rotations, etc. enter the picture but this is seldom for GIS geometry constructions. A pair of integers forms a rational number; packages to implement regular arithmetic are available or can be coded easily. With such rational numbers all geometric computations for geometry with straight lines are possible except for limitations such as integers that are bounded (there is a smallest and largest integer for a given size). Rational numbers represented as pair of big numbers give a domain in which all of straight line geometry can be done precisely and is limited only by the size of the available memory Homogeneous coordinates with big integers. In case of homogeneous coordinates an n dimensional point is represented by (n+1 ) tuple of big integers. Like rational numbers with big integers, all straight line geometry can be performed precisely with homogeneous coordinates with big integers, and the precision is limited by the size of the available memory. Homogeneous coordinates with big integers is a cheaper form of using rationals and the proposed model will use homogeneous big integer numbers for representing the coordinates of a point. Homogeneous coordinates form a basis for projective geometry [Bloomenthal and Rokne, 1994]. The transformations between Cartesian and homogeneous coordinates are: p c (x, y) p h (1, x, y) p h (w, x, y) p c ( x w, y w ) For a point (x, y) in Euclidean plane, its corresponding homogeneous representation is (w, x, y). The ordinary plane augmented with points at infinity is known as the projective plane which can not be represented in Euclidean coordinate system. This is a fundamental reason for using homogeneous coordinates for representing projective planes in projective geometry [Bloomenthal and Rokne, 1994]. Figure shows the projection of a homogeneous point (w, 2, 3) for w = {4,2,1,0.5,0}. As w approaches to 0, the projected Euclidean point moves away from origin in the direction of (2,3) and at w=0, the point is at infinity.

56 Chapter 3 - MODEL REQUIREMENTS 33 Figure 3.2: Projection of a homogeneous point to w = 1 plane [Bloomenthal and Rokne, 1994] 3.2 The Requirement for Geometric Primitive Geometric Primitive: The Requirement The model should use a geometric primitive that offers simple, closed and consistent framework for the representation of geometry of objects. Geometric primitives are the elementary construct used to approximate and represent the spatial objects digitally. According to ISO 1907, a geometric primitive is a geometric object that is not decomposed further into other primitives in the system. So the geometric representation of any spatial feature is done by a collection of these geometric primitives. In order to represent the geometry of nonconvex regions, a simple and consistent geometric primitive is needed that offers; ˆ ease of implementation and ˆ supports consistent topological operations Proposed solution: Convex polytope The proposed solution uses convex polytope as the basic geometric primitive, which is the convex hull in the dual space. Convexity is an important property of geometric objects and thus the use of convex polytope brings into the model the benefits associated with. However, most of the objects in real world are nonconvex, so the model should be able to deal the nonconvex objects. The proposed solution will tackle the nonconvex objects by decomposing them into their convex components i.e. convex decomposition and storing the objects in a

57 Chapter 3 - MODEL REQUIREMENTS 34 hierarchical tree data structure, the convex hull tree. An arbitrary region is then composed by alternately subtracting convex regions stored in the convex hull tree. 3.3 The Requirement for Closed Geometric Operations Geometric Operations: The Requirement The model and the associated data structure must facilitate the basic geometric operations. In the GIS domain, the geometric operations that form the basis for most of the spatial operations are intersection, union, symmetric difference, and test for point in a polygon etc. Among these operations intersection is the most important as it is used for overlay operations, the equivalent of join operation in databases and other operations (e.g. union and symmetric difference) use it. The model should offer easily understandable and implementable algorithms for performing the aforementioned operations Proposed solution: Intersection of convex polytopes Intersection of two convex objects is always convex and optimal algorithms for intersection computation are known. Using the duality principle, the complement of a region is easily computed. The algorithm for intersection and complement computation is then used for computing the union and other Boolean operations. In the next chapter I will analyze the proposed model for supporting the following closed operations; ˆ Intersection ˆ Complement ˆ Union ˆ Difference and Symmetric difference ˆ Point in a polygon

58 Chapter 3 - MODEL REQUIREMENTS The Requirement for Level of Detail Level of detail: The Requirement Level of detail (LoD) is a fundamental concept in geometric and graphical description of figures and objects. Level of detail indications are crucial for sharing geographic information, because only data structures, which can produce just the right amount of detail that is needed for an application, are capable to serve diverse applications. Keeping in view the importance of LoD, the proposed model should support level of detail. To construct an LoD data structure and the corresponding progressive algorithm, the following issues must be fixed: - a description of the original data, with a concept of gradual approximations. - a simpler description, which is capable of a piecewise gradual approximation to the original (the primitive). - a tree in which the primitives are stored. The selection of the primitive is the major design decision, which influences the design of algorithms substantially. There are two well known types of dividing data over LoD: ˆ by replacement: the next level is a complete and improved description of what is described above. Examples: linear functions approximated by linear pieces, strip tree. (in computer vision this is called lowpass pyramid Perlin and Velho [1995]), ˆ by delta: the next level is just an addition to what is described in the higher levels and the improved approximation is achieved by combining the values from this levels with the sum from above. Example: region quadtree [Samet, 1984],(in computer vision, this is called bandpass pyramid) Proposed solution: Hierarchical tree data structure The model having a hierarchical tree data structure provides support for level of detail generalization, thus enabling to write progressive algorithms for geometric computations. The convex hull tree is an LoD structure in which the data is divided over LoD by delta i.e. the convex hulls in the lower level nodes are included and smaller than the convex hull at their respective parent node. The tree evaluation is done progressively by recursive traversal of children trees of

59 Chapter 3 - MODEL REQUIREMENTS 36 a node only if the children trees are relevant otherwise the children trees are pruned and not evaluated further. This in combination with lazy evaluation provides opportunity to design generic progressive algorithms that are efficient as the computations are done up to the level needed. 3.5 The Requirement for Dimension Independence Dimension independence: The requirement The model should be dimension independent i.e. it should model objects of any dimension. The current models for the representation of geometry are dimension specific mostly 2D or 3D i.e. they have been implemented to support objects of a specific dimension, mostly 2D and few for 3D. Even if a model supporting both 2D and 3D would have separate implementations for each dimension. However, a dimension independent model has a single implementation that works for objects of any dimension. Dimension independence is important because in some cases we may need 4D or more models e.g. 3D + time and (or) movement. The proposed model should be able to deal with objects of any dimension Proposed solution: Convex polytope I will provide a single implementation of proposed model using simplexes that works for n-dimensions. Thus the two possible modeling approaches are; ˆ The model is implemented separately for each dimension e.g. 2D or 3D etc. ˆ A single implementation that works for any dimension. The second approach is more attractive, because its provides less code which means less errors and less maintenance issues. So a single implementation of representation model is needed that works for n-dimensions. The necessary topological relations in GIS are deducible from point coordinates by three computations. The dimension independent implementation is achieved by lifting these basic computations for 2D so that they generalize immediately to 3D and more dimensions. ˆ Distance between points to decide if two points have the same location.

60 Chapter 3 - MODEL REQUIREMENTS 37 ˆ Signed areas of a triangle, used to decide if a point is left, in, or right of a line[knuth, 1992]. ˆ Testing if a point is inside the circle defined by three other points. 3.6 Requirements Summary In this chapter I discussed the requirements the model should support and the proposed solutions to fulfill these requirements. The separation of metric and topological processing is the key to fulfill the geometric model requirements of the proposed solution. I discussed the model requirements and proposed solutions that fulfills the specific requirement. In the next chapter, I will discuss how the proposed solution, Alternate Hierarchical Decomposition (AHD) achieves these requirements by integrating the proposed solutions for each requirement.

61

62 Chapter 4 SOLUTION: ALTERNATE HIERARCHICAL DECOMPOSITION The solution consists of two parts motivated by the separation of metric and topological processing as discussed in section Homogeneous coordinates and big integers 2. Alternate hierarchical decomposition 4.1 Homogeneous Coordinates and Big Integers The solution uses homogeneous coordinates stored as arbitrary precision big integers. A consistent metric processing for geometry of straight lines is then possible with homogeneous coordinates stored as big integers. The use of arbitrary precision arithmetic ensures that the (nonrobustness) issues related to fixed precision arithmetic in geometric computations are avoided. However, the use of big integers is discouraged in literature as is thought to be computationally expensive especially for cascaded operations in which case the output of one operation is the input of next operation. Are big integers really slow? In order to answer this question and to see the viability of using big integers in the representation model, an experiment is performed using a cascaded operation of computing the line intersections. 39

63 Chapter 4 - SOLUTION: ALTERNATE HIERARCHICAL DECOMPOSITION Experiment for testing the viability of big integers Line intersection is the primary method to construct new points (besides importing new points from outside. Given two lines AB and CD, the intersection point P is P = (A B) (C D) where stands for ordinary vector cross on 3-vectors (note: 2D points are represented as homogeneous 3-vectors). The behavior of geometry is tested with repeatedly intersecting lines and connecting the new points to create new lines, which are then intersected again in the next iteration. This cascaded intersection computation resembles the generations of geometrically constructed points. In order to avoid artifacts two different test programs are produced. Table 4.1 gives a brief of the two test program approaches. The assessment included the observation of: ˆ the ease of programming with big integers, ˆ execution times compared to the same computation with floating point numbers, ˆ and the growth of size of the big integers Ease of programming Most modern languages (including the one, Haskell [Jones and Jones, 2003], used here) offer ready to use packages for big numbers. In Haskell big integers are implemented as data type Integer, and all ordinary meaningful operations are overloaded to work on this type. For both test approaches, the same program written as polymorph functions is used in the test for computations with big numbers (Integer) and floating point (Float or Double). Programming with big numbers is easier than when working with Float or Integer because no consideration to check for overflow is necessary and no hidden bugs may emerge later because the programmer did not think of the required test, nor are there tolerances to guess Performance Approach I In order to assess the performance penalty caused by the use of big numbers, the intersection computation is performed for ten cascaded iterations and results compared for the same program executing with big integers and with double precision

64 Chapter 4 - SOLUTION: ALTERNATE HIERARCHICAL DECOMPOSITION41 Table 4.1: Test program approaches used in experiment Initial Point Generation Line Construction (in a generation) Point Construction (in a generation) Point Selection (in a generation) Approach - I Random Pairing of points in order of their position in the data structure Taking lines one by one and calculating their intersection with all other succeeding lines in the data structure As the number of points is increasing per generation, a filter box is used to select only those points for the next generation which fall within the boundaries of filter box Stopping Criteria Explicitly stopped by specifying the number of rounds to compute Test Environment Compiler: Haskell ghc [22] Processor & Memory: 1.2 MHz, 2GB RAM Operating System: Ubuntu 7.10 Approach - II Random Pairing of points in order of their position in the Pairing succeeding lines in the data structure and calculating their intersection point. Each pair of lines thus gives a single intersection point to be used in the next generation As the number of points is decreasing per generation, no filter is used. All intersection points calculated in one generation are used as input points to the new generation Implicitly stopped when the number of input points for a generation becomes less than 4. Compiler: Haskell ghc 6.6.1[22] Processor & Memory: P4 CPU2.4 GHz, 503MB RAM Operating System: Ubuntu 7.10

65 Chapter 4 - SOLUTION: ALTERNATE HIERARCHICAL DECOMPOSITION42 Figure 4.1: Average time per intersection computation in µsec with related operations-approach I floating point numbers (there is usually no performance difference with modern computers and hardware between single and double precision float). The difference was less than expected; total time necessary to compute the intersections of one iteration was divided by the number of intersections computed. Figure 4.1 shows that the average time for floating point intersections is seconds, a constant for every iteration. However, computation with big integers takes the nearly same time for the first 4 iterations and then increasing from iteration 5 up till > 10 2 seconds for iteration Size of representation Approach I In order to answer the question, how quickly the size of big integers grows, the average length and maximum length of big integers for ten cascaded iterations is plotted in Figure 4.2. The result is unfortunately less encouraging: the average length of the representation doubles with every following iteration of the cascaded intersection computation of intersecting lines. From iteration 3 upwards, the size is larger than the (less precise) floating point numbers. As long as only a small percentage of points are from constructions, the increase in size is certainly negligible.

66 Chapter 4 - SOLUTION: ALTERNATE HIERARCHICAL DECOMPOSITION43 Figure 4.2: Number of digits per coordinate value approach I Performance Approach II Although the implementation using approach II was simpler than approach I, the results in both cases are comparable as shown in Figure 4.3 and Figure 4.4 (plotted for 700,000 initial random points both big integers and double floating point numbers). As shown in Figure 4.3, the average time for double is gradually decreasing, because the number of intersections to be calculated in subsequent iterations are decreasing while the average length is constant. Also, the graph shows that the difference in average time for double and big integers is small in initial iterations and it increases rapidly in higher iterations. This is because of the fact that the average length of intersection point coordinates using big integers is increasing rapidly in higher iterations Size of representation Approach II The behavior of average length of big integers, as shown in Figure 4.4, is same as for approach I. The average length of double is obviously constant throughout generations.

67 Chapter 4 - SOLUTION: ALTERNATE HIERARCHICAL DECOMPOSITION44 Average time per intersection in µsec with related operations- Figure 4.3: approach II Figure 4.4: Number of digits per coordinate value approach II

68 Chapter 4 - SOLUTION: ALTERNATE HIERARCHICAL DECOMPOSITION Discussion on the viability of big integers for GIS Programming is easier and straightforward than writing code using conventional Integer or Float data types. The advantage of metric calculations with big integer homogeneous coordinates is that they are accurate, not approximates and all topological relations derived are consistent. Intersection points calculated are exactly on the line, not only very near, etc. Coarsening of big number homogeneous coordinates is possible, but then the guarantee is lost. Such schemes for producing point coordinates that are approximate are common in a GIS where points are observed with finite precision. For example, points constructed in reality as forming a straight line, then measured and the deviation from a straight line computed yields never the result exactly on the line. The performance penalty is relatively small and affects only the part of GIS operations computing metric relations, when points are constructed geometrically using cascaded intersection of lines. For applications using cascaded constructions, the growth in the size of the big numbers representing the point coordinates may be problematic. The average size doubles with each cascaded iteration of the computation. Typical GIS operations do not construct long chains of cascaded intersections. The effect on GIS operations is difficult to quantify, but it is most likely small: ˆ Cascaded constructions of points that go for several iterations are rare in GIS. Time penalties for such situations are up to 4 or 5 iterations of points based on the test results negligible. The speed reduction depends therefore on the percentage of higher iteration points. ˆ Only a small amount of the execution time of GIS operations is spent in geometric operations; assume 5%. If the time for geometric operations increases by a factor of 10, the total slowing of the program is only 50%. This slowdown is compensated by the increase in the processing speed of the processor in about one year (Moore s law). It is expected that the effect will be less drastic as all necessary tests for overflow, which use up execution time, especially in modern pipelined processors, etc., are inessential.

69 Chapter 4 - SOLUTION: ALTERNATE HIERARCHICAL DECOMPOSITION Alternate Hierarchical Decomposition Alternate Hierarchical Decomposition, AHD is an algebraic approach that uses convex polytope as the basic building block for the geometric representation of an arbitrary (convex or nonconvex, with or without holes, islands or without islands) region. The arbitrary region is decomposed into convex hull component regions (convex decomposition) which are stored in a tree. The arbitrary region is then formed by alternately subtracting and adding convex hull component regions from the convex region at the root of the tree. AHD supports operations on regions which includes the nested traversal trees representing the regions and applying the corresponding operation on the component convex regions AHD: An Overview of the Approach AHD uses convex polytope as the basic geometric primitive. The use of convex polytope as the fundamental geometric construct provides simple, straight forward and consistent topological processing. Convex polytope is defined by the intersection of finite set of half planes (half spaces in case of 3D or more), however, the representation of a convex polytope in dual space is used, which is represented by a set of points and lines, depicting lines and the connection points of half planes in the Euclidean space respectively. In dual space, a convex polytope is defined as the convex hull of the dual points [De Berg et al., 2008]. The use of convex polytope as the geometric primitive requires that the nonconvex objects are decomposed into their convex hull components (convex decomposition). AHD is therefore, based on convex decomposition in which the nonconvex region is decomposed into convex hull components arranged hierarchically in a Convex Hull Tree, CHT (related concepts are convex deficiency tree [O Rourke, 1998] and concavity tree [Badawy and Kamel, 2005]), the alternate levels of which represent convex regions to be added or subtracted depending on even or odd level respectively. The hierarchical tree data structure is useful for achieving level of detail AHD: An Example In order to explain the AHD approach, an example that demonstrates the decomposition steps and shows the output CHT is presented. Suppose a 2-D nonconvex polytope with a hole (H ) (as shown in Figure 4.5a) is given as input. The ap-

70 Chapter 4 - SOLUTION: ALTERNATE HIERARCHICAL DECOMPOSITION47 (a) Input nonconvex polytope with hole H (b) Convex decomposition of input Figure 4.5: Input polytope and its convex decomposition Figure 4.6: CHT for demonstration example of Figure plication of AHD results in the decomposition of the input into its component convex hulls (Figure 4.5b) AHD: Convex Hull Tree The data structure, CHT, is a tree in which every node represents a convex hull. The root node of the CHT contains the convex hull of the input polytope, non-leaf nodes contain convex hulls of the nonconvex delta regions (notches) of the nonconvex structure whose convex hull is represented by parent node. Leaf nodes contain the convex hulls of the convex delta regions. The positive (+) and negative (-) signs at alternate levels (even levels are + and odd levels are -) of the CHT show the convex regions to be added and subtracted for forming the arbitrary region represented by the CHT (see Figure 4.6).

71 Chapter 4 - SOLUTION: ALTERNATE HIERARCHICAL DECOMPOSITION AHD: Functions Two basic functions build and eval are used for populating the data structure and evaluating the data structure to retrieve the original object respectively Build function The AHD build consists of two steps: (1) convex hull computation, and (2) delta region or regions extraction (using symmetric difference). The process is then recursively applied to the delta regions until the input region is convex or up to a specified level of detail ( see section 4.4) specified Build example In order to demonstrate the AHD build function, an example is shown to in Figure Build algorithm The pseudocode for build function is given in Figure 4.8. The pseudocode of the algorithm for computing the QuickHull [O Rourke, 1998] is given in Figure Build complexity Given a nonconvex polytope p with n points, the convex hull and delta regions of p can be computed in O(nlogn) and in liner time, respectively. If r is the number of delta regions of p then complexity becomes O(rnlogn). However, size of r is negligibly smaller than n for higher values of n. Thus, the worst case scenario can not be O(n 2 logn) and the build function of AHD has an average time complexity of O(nlogn) Eval function Given a arbitrary object represented in CHT, the eval function of AHD evaluates the tree to retrieve the object by recursive traversal of convex hulls stored in the nodes of the tree up to the level of detail (see section 4.4) specified. The function eval uses the concept of region merging i.e. given a convex hull parent and its convex hull components, the components are merged into the parent convex hull recursively.

72 Chapter 4 - SOLUTION: ALTERNATE HIERARCHICAL DECOMPOSITION49 Figure 4.7: AHD steps. L represents the level, dr represents the delta region and ch represents the convex hull

73 Chapter 4 - SOLUTION: ALTERNATE HIERARCHICAL DECOMPOSITION50 Input: A list pe of polytope edges 1 t = Node [] [] // Initialize t as an empty convex hull tree 2 if pe is empty 3 then return t 4 else if pe contains only a single edge 5 then 6 ch = list of points containing unique endpoints of the single edge 7 t = Node ch [] // a tree containing single node 8 return t 9 else 10 ch = convex hull of pe 11 che = list of convex hull edges of pe 12 dre = list of delta region edges which are not convex hull edges 13 dhp = list of delta region points which are on hull 14 dr = list of closed delta regions // region is a list of edges 15 for all delta regions in dr 16 ct = go to 1 // each region in dr results in a children tree recursively 17 t = Node ch [ ct] 18 return t Output: A convex hull tree t Figure 4.8: Pseudocode of the algorithm build that populates the CHT

74 Chapter 4 - SOLUTION: ALTERNATE HIERARCHICAL DECOMPOSITION51 Input: A list p of polytope points 1 Initialize ch as an empty list of convex hull points 2 x = point in p with max x- coordinate value 3 y = point in p with max y- coordinate value 4 s1 = list of points in p strictly above line xy 5 s2 = list of points in p strictly above line yx 6 ch = ( [x] + qhull (x, y s1) + [y] + qhull (y, x, s2)) 7 return ch Output: A list ch of convex hull points Input: Two end points a and b of a line ab and a list S of points above that line ab 1 Initialize sh as an empty list of sub hull points 2 if S is empty 3 then return [] 4 else 5 c = farthest point of S from line ab 6 parta = points in S strictly above line ac 7 partb = points in S strictly above line cb 8 cha = qhull ( a, c, parta ) 9 chb = qhull ( c, b, partb ) 10 sh = cha + [ c] + chb 11 return sh Output: A list of sub hull points sh Figure 4.9: Pseudocode of QuickHull algorithm and its helping function qhull, which computes the sub hulls of partitions recursively

75 Chapter 4 - SOLUTION: ALTERNATE HIERARCHICAL DECOMPOSITION Eval example An example is shown in Figure 4.10 to illustrate the eval function that using region merging for forming the object stored in CHT. Four scenarios are possible for merging a child hull into a parent hull: 1. An edge of child hull completely overlaps an edge of parent hull i.e. both edges have same starting and ending points. For example, in Figure 4.10f e 12 of region represented by child hull 1 edge e 03 of parent region overlap. In this this case the common edge is removed from both child and parent regions. The orientation of the remaining edges of the region represented by the child tree is reversed (as shown in Figure 4.10g). 2. An edge of child hull overlaps an edge of parent hull in the middle i.e. starting and ending points of the child edge lie on the edge of the parent edge and are not equal to the starting and ending edges of the parent edge. For example, in Figure 4.10f e 24 of child region lies on the edge e 01 of the parent region. In this this case e 24 is removed from child region while the edge e 01 is split into two edges e 011 and e 012. Also, the orientation of the remaining edges of the region represented by this child tree is reversed (Figure 4.10g). 3. An edge of the child hull overlaps an edge of the parent hull but both edges have at least one common point. For example, edge e 52 of child region overlaps the edge e 02 of the parent region and both have a common starting point. In this case a new single edge e 021 is created excluding the overlapping portion. The orientation of the remaining edges of the region represented by this child tree is reversed (Figure 4.10g). 4. There is no any edges overlap i.e. all the points of the child hull are inside the parent hull. This shows that the child hull represents a hole and the merging is done just by reversing the edges of region represented by child tree. For example, in Figure 4.10f child region 3 represents a hole region Eval algorithm The pseudocode of the algorithm for complete evaluation of a CHT, which retrieves the original object, is given in Figure 4.11.

76 Chapter 4 - SOLUTION: ALTERNATE HIERARCHICAL DECOMPOSITION53 (a) An input nonconvex region with a hole (b) Decomposed input (c) CHT of input region (d) Merging child hull 1 into parent hull 0-find common edge (e) Merging child hull 1 into parent hull 0- remove common edge from both hulls and reverse orientation of remaining edges of the child hull 1 (f) Merging all children of parent hull 0 (g) Output of eval Figure 4.10: AHD eval using merging of convex hull regions

77 Chapter 4 - SOLUTION: ALTERNATE HIERARCHICAL DECOMPOSITION54 Input: A convex hull tree t, Node x xts : x is convex hull at root node and xts is list of children trees 1 Initialize pe, cr as empty list of edges 2 if t is empty 3 then eturn pe 4 else if xts is empty // a leaf node 5 then 6 pe = list containing edges of convex hull x 7 return pe 8 else 9 pe = list containing edges of convex hull x 10 for all child trees in xts 11 cr = cr + go to 1 // each children tree in xts results in a component region recursively 12 mr = merge regions in cr into the region pe 13 pe = mr 14 return pe Output: A list pe of polytope edges Figure 4.11: Pseudocode of the algorithm eval that processes the CHT to extract represented region Eval complexity For a arbitrary simple polygon with n vertexes; Max number of possible concavities or notches = (n-3)+1 n if n is too large Max nodes of a CHT = (n-3)+1 n if n is too large If the complexity of the algorithm for point in a convex hull is logn then the worst case complexity of eval is nlogn AHD: Characteristics AHD uses convex decomposition for representation of the object in CHT. In section , the criteria for the classification decomposition techniques is mentioned. Most of the algorithms for decomposition are optimized for one of the these criteria [Kriegel et al., 1991] depending on application needs. Table 4.2 shows a characterization of AHD based on these criteria. The important characteristics of AHD as shown in Figure 4.12 are; 1. Closed operations: AHD supports Boolean operations which are closed and implementation is efficient because of hierarchical data structure. 2. Dimension independence: AHD is dimension independent as a single

78 Chapter 4 - SOLUTION: ALTERNATE HIERARCHICAL DECOMPOSITION55 Table 4.2: Characterization of the decomposition technique Criteria Type of components Type of input Relation of components Objective function Input dimension AHD Convex Polytope with or without holes Covering- as the component convex hulls at level l+1 are contained within the convex hull at level l Does not fall to any category, but the objective is to achieve generalization of data modeling framework using convex polytopes Dimension independent Figure 4.12: AHD characteristics

79 Chapter 4 - SOLUTION: ALTERNATE HIERARCHICAL DECOMPOSITION56 (a) (b) Figure 4.13: Approaches for dimension independent AHD implementation of it works for all dimensions by lifting basic geometric primitives. 3. Level of detail: AHD supports level of detail because of hierarchical data structure that facilitates generalization and design of progressive algorithms. 4.3 Dimension Independent AHD In this section the dimension independence of AHD is shown by providing a dimension independent convex decomposition algorithm. The AHD approach has two steps: 1. Convex hull computation 2. Delta region (s) or notch (s) extraction For a dimension independent AHD, the two steps need to be dimension independent. There are two possible approaches as shown in Figure First approach deals both of the aforementioned steps independent of each other (Figure 4.13a). This means any of the existing dimension independent convex hull algorithm [Barber et al., 1996, Karimipour et al., 2008] can be used and the result is transformed to the object representation model before extracting the delta regions. In second approach, a data representation model is used that supports both operations to be performed in sequence without conversions (fig. 3b). The proposed approach for n-dimensional AHD is based on the second approach which is better as it avoids unnecessary conversions. The approach is based on the simplex based data representation model which provides a consistent implementation of the two basic steps of AHD i.e. convex

80 Chapter 4 - SOLUTION: ALTERNATE HIERARCHICAL DECOMPOSITION57 Figure 4.14: n-dimensional AHD- An example for 3D case Figure 4.15: Simplexes of dimensions 0 to 3: node, edge, triangle, and tetrahedron hull computation and delta region extraction. Figure shows the decomposition example for a 3D case. A n-simplex S n (abbreviated as simplex henceforth) is defined as the smallest convex set in the Euclidean space that contains n + 1 of n-dimensional vertexes v 0,...,v n that do not lie in a hyperplane of dimension less than n [Alexandroff and Aleksandrov, 1961]. A simplex is represented by the list of its vertexes as S n =< v 0,...,v n >. Figure 4.15 shows simplexes of dimensions 0 to Pseudocode: n-dimensional AHD Dimension independent convex hull computation is the most important step for n- dimensional AHD. In this section the pseudocode of the algorithms for Inc-

81 Chapter 4 - SOLUTION: ALTERNATE HIERARCHICAL DECOMPOSITION58 Input: A set of n dimensional points LP= {p0,..., pm} 1 I = an n- simplex constructed by LP 2 E = boundary of I ( which consits of n +1 of ( n -1) - simplexes ) 3 for all points p in {pn +1,..., PM} 4 if p is outside the region delimited by all ( n -1) - simplexes in E 5 S = set of all ( n -1) - simplexes in E that make a cw turn with respect to point p 6 B = set of ( n -2) - simplexes that are on the border of S 7 N = set of ( n -1) - simplexes constructed by adding p to all ( n -2) - simplexes b in E 8 E = E-S+N 9 return E Output: A List E contains the (n-1)-simplexes that construct the convexhull of the input Figure 4.16: Pseudocode of dimension independent incremental convex hull algorithm Convexhull and n -dimensional AHD are provided Convex hull Computation The convex hull of a set of points is the smallest region that contains the points. An incremental algorithm called IncConvexhull [Barber et al., 1996, De Berg et al., 2008] is used for the convex hull computation. For some 2D points, the IncConvexhull algorithm starts with the triangle goes through the first three points, which is their convex hull. Other points are inserted one by one into the construction and after each insertion, the convex hull is modified: if the inserted point is inside the convex hull, no change is needed in the configuration of the current convex hull; If it is outside, however, its opposite edges are dropped from the convex hull and new edges are added, which are constructed by adding the inserted point to the border points of the dropped edges. Extension of IncConvexhull algorithm to n-dimensional points is possible by using the concept of simplexes as shown by Karimipour et al. [2008]. Figure 4.16 shows the pseudocode of the n-dimensional convex hull algorithm.

82 Chapter 4 - SOLUTION: ALTERNATE HIERARCHICAL DECOMPOSITION59 Input: A set of n simplexes R = S 0,...,S m 1 if sptr is empty 2 then return T 3 where 4 T = Node (chr, []) 5 else return T 6 where 7 T = Node ( chr, apply build on all elements of the list sptr ) 8 sptr = split ( symd (R, chr )) 9 chr = Convexhull ( vs) 10 vs = union of vertices of input n- simplexes R 11 symd (x,y) = (x-y)+(y-x) Output: A tree of signed convex regions that construct R Figure 4.17: n-dimensional AHD n-dimensional AHD Using the concept of simplexes, the AHD algorithm is implemented for polytopes of any dimension. The dimension independent convex hull algorithm of Figure 4.16 and the split function of Table 6.2 are used for a dimension independent AHD, the pseudocode of which is shown in Figure AHD: Level of Detail AHD supports level of detail because of the hierarchical tree data structure. Both the build and eval functions of AHD use the level of detail for building the CHT of an arbitrary region and for evaluating the CHT for forming the arbitrary region up to the specified level respectively. AHD therefore provides a level of detail approximation of an arbitrary region by convex decomposition of the region into its convex hull components. The component convex hulls are always smaller and overlap the parent convex hull. Figure 4.19 demonstrates the level of detail approximation of the given 2D nonconvex polygon using AHD (Figure 4.18). The support for level of detail facilitates in designing progressive algorithms for performing Boolean operations. The level of detail together with lazy evaluation (as supported by some programming languages e.g. Haskell) leads to efficient geometric algorithms for performing operations like point in polygon test, intersection, union and so forth. The LoD in AHD facilitates reduced number of

83 Chapter 4 - SOLUTION: ALTERNATE HIERARCHICAL DECOMPOSITION60 (a) An example nonconvex polygon (b) Convex hull components of example polygon (c) CHT of input polygon Figure 4.18: AHD example for a nonconvex polygon computations. Special cases are tested for Boolean operations like intersection, inclusion, etc., which are best treated by operations with understanding of the geometric data structure used. For example, test for the intersection detection for two polygons represented by AHD stops at the first level if the convex hulls of the given polygons do not overlap further exploration is unnecessary. Similarly, the test for point in polygon stops at the first level, if the test point is not inside the convex hull of the given polygon. The progression in such algorithms is controlled either by specifying level explicitly or specifying an error bound for the result. The LoD in AHD is based on a geometric criterion, i.e., the difference between the convex hull and the true region. Applications may need to indicate the required quality of the approximation, for example, in case of AHD different criteria may apply; ˆ percent error in area (volume), ˆ absolute error in area (volume), ˆ maximum absolute error as the distance of boundary points from the approximate boundary. The advantage of AHD compared to a region quadtree is (a) it represents exactly polytopes of n-dimension bounded by n-flats, and (b) it is invariant to shift or rotation of a coordinate system.

84 Chapter 4 - SOLUTION: ALTERNATE HIERARCHICAL DECOMPOSITION61 (a) LoD0 region approximation and the corresponding CHT node is highlighted (b) LoD1 region approximation and the corresponding CHT nodes are highlighted (c) LoD2 region approximation and the corresponding CHT nodes are highlighted Figure 4.19: The concept of LoD in AHD for example polygon in Fig The increasing level of detail from LoD0 to LoD2 increases the quality of approximation

85 Chapter 4 - SOLUTION: ALTERNATE HIERARCHICAL DECOMPOSITION Solution Summary Robustness The solution avoids the problem of numerical nonrobustness [Franklin, 1984, Mehlhorn and Naher, 1999, Li et al., 2005] by using exact algebra. This has been achieved through the use of big integers allowing arbitrary precision arithmetic. Thus, topological inconsistencies are avoided, as the underlying algorithms have been implemented keeping in mind the arbitrary precision arithmetic for numerical computations involved Closed Boolean operations The solution supports Boolean operations. The computation of Boolean operations (e.g. intersection between two regions) is done by recursively traversing the trees and applying the intersection operation on the convex hulls. The operations are discussed in detail in next chapter Dimension independence To the best of my knowledge, the algorithms for decomposition problem are not dimension independent as most work for 2-D and some deal with 3-D objects. Although for demonstration purposes 2-D polytopes are used, the solution is extendable to n-dimensional polytopes. This is achievable if the algorithm for computing convex hull is dimension independent. For this any of the existing dimension independent convex hull algorithms [Barber et al., 1996, Karimipour et al., 2008] can be used Level of detail Depending on the applications, the complete decomposition of nonconvex polygons to convex polygons may not be needed [Lien and Amato, 2006]. In such cases approximations are used by halting the decomposition process using some threshold.the solution is flexible in that the decomposition process can be stopped at any level depending on application thus allowing level of detail approximation.

86 Chapter 4 - SOLUTION: ALTERNATE HIERARCHICAL DECOMPOSITION Number of components The solutions to the problem of decomposing a nonconvex polygon into its optimal (minimum) number of convex components vary depending on whether Steiner points allowed [Lien and Amato, 2006]. Although the solution was not aiming to optimize the number of resultant components, however the solution is not as bad as the mostly used decompositions for near optimal number of components. The number of components is the number of CHT nodes, which is 13 and partitioning the example in Figure 4.5 results in 14 convex components.

87

88 Chapter 5 AHD BASED GEOMETRIC OPERATIONS Boolean operations are fundamental to geographic information processing. In GIS, spatial operations like convex hulls, buffering, distances and Boolean or settheoretic operations (intersection, union difference and symmetric difference) are extensively used for extracting useful spatial information out of stored spatial data. The chapter shows that the AHD approach allows optimal (or near optimal) computation of Boolean and other geometric operations (point in a polygon and line intersecting a polygon) using AHD approach. In a GIS a separate data structure is not possible for every operation but the same structure can be used for all operations. 5.1 Intersection Operation The intersection operation is of fundamental importance [Shamos and Hoey, 1976] as other Boolean operations union, difference and symmetric difference can be reduced to the computation based on intersection and complement. Also, it is the most expensive operation computationally, roughly taking 80 % of the running time of the program [Greiner and Hormann, 1998]. The intersection operation has two problems, intersection detection and intersection computation. The intersection detection between two convex objects is a basic geometric operation [Chazelle and Dobkin, 1987] and a description of the topic is provided by Mount [1997]. The intersection detection problem is not considered that itself is a chal- 65

89 Chapter 5 - AHD BASED GEOMETRIC OPERATIONS 66 Figure 5.1: Different polygon intersection scenarios lenging problem and algorithms exist in literature (e.g. [Shamos and Hoey, 1976, Chazelle and Dobkin, 1987]). For simplicity it is assumed that the objects under consideration for intersection computation do intersect. The Problem: Given two arbitrary regions (convex or nonconvex, with non intersecting edges, and with or without holes), compute the intersection region that may be; (a) Empty (Figure 1a) (b) Convex (Figure 1b) (c) Nonconvex (Figure 1c) (d) A set of convex and (or) nonconvex disjoint regions (Figure 1d) AHD based intersection computation The intersection computation consists of three operations; 1) Intersection between two convex objects. 2) Intersection between a convex and a CHT (nonconvex object). 3) Intersection between two CHTs (two nonconvex objects). This gives for (1) the basic and simple operation of intersection computation between two convex hulls. For (2), the traversal with basic operation in (1) and for (3), the CHT traversal with operation in (2). Only the basic operation of intersection of two convex hulls is geometric (for which well known algorithms exist e.g. [O Rourke et al., 1982]) and the other operations are repeated application of this by traversing tree structures. Figure 5.2 shows the intersection computation approach. The basic intersection operation between two convex hulls, convex-convex intersection (CCINT) is used to compute the convex-nonconvex intersection (CNINT) between a convex and nonconvex object. The CNINT operation is in turn used for computing a generic intersection operation (GINT).

90 Chapter 5 - AHD BASED GEOMETRIC OPERATIONS 67 Figure 5.2: Intersection computation approach (a) Two convex polygons (b) CHTs of A and B (c) Resultant CHT of A B Figure 5.3: Convex-convex intersection computation Basic intersection operation: Convex-convex intersection The basic operation is closed under intersection and the result is always a convex region. The intersection computation between two convex polygons is the basic operation (for which known solutions exist e.g. [Toussaint, 1985, Chazelle, 1989]). Any of the existing solutions can be used but an algorithm for intersection computation between two convex polygons using convex hulls is provided. Figure 5.3a shows two intersecting convex objects. The intersection is performed by computing the intersection of the convex hulls ( (a1 and b1) of the two convex regions as shown by two leaf nodes of CHT in Figure 5.3b. The result is a convex hull (a1 b1) region represented by a leaf node of CHT as shown in Figure 5.3c. Pseudocode of convex-convex intersection algorithm: The pseudocode of the basic intersection operation between two convex polygons is shown in Figure 5.4. The algorithm uses the QuickHull algorithm [O Rourke, 1998] for convex hull computation and compintpoints routine computes the intersection points by pairing the intersecting delta edges.

91 Chapter 5 - AHD BASED GEOMETRIC OPERATIONS 68 Input: Two convex polytopes poly1 and poly2 in vertex notation 1 Initialize set of intersection region points I as an empty set 2 ch = convex hull ( poly1 + poly2 ) 3 de = ( poly1 edges + poly2 edges ) - ch edges 4 ip = compintpoints de 5 irp = ( poly1 -poly2 ) + ( poly2 - poly1 ) + ip 6 I = convexhull irp Output: Set of intersection region points I (always a convex hull) Figure 5.4: Pseudocode of convex-convex intersection Complexity of convex-convex intersection algorithm: For two convex objects with number of points m and n, the worst case time complexity of the algorithm is O((m + n)log(m + n)). An Example of convex-convex intersection: The algorithmic steps of basic intersection are shown in the example in Figure Convex-nonconvex intersection The process of intersection computation between a convex and a nonconvex object consists the repeated application of the basic operation, CCINT, between the convex hull of the convex object and the convex hull components of the nonconvex object that are traversed recursively in CHT. The resulting convex hull of each basic operation is then placed in the resultant CHT at the position same as the position of component convex hull of the nonconvex polygon involved in the basic operation. The further recursive evaluation of children trees of a component convex hull is stopped if the basic operation involving that component convex hull is null. The support for LoD together with lazy evaluation avoids unnecessary computations reducing the overall number of operations. For example, Figure 5.6a shows a convex polygon A and a nonconvex polygon B and Figure 5.6b shows the decomposed inputs with their components numbered. Figure 5.6c shows the data structure representation of the input polygons A and B. The process starts by the computation of basic the operation between convex hull of convex polygon A (that is a1 ) and the convex hull of the nonconvex polygon B (that is the root b1 ). Since b1, the component convex hull of the nonconvex polygon is at root the result of basic operation between a1 and b1 will form the root of the resultant CHT as shown in Figure 5.6e. The process is then recursively applied to the

92 Chapter 5 - AHD BASED GEOMETRIC OPERATIONS 69 (a) Input convex polygons (b) Convex hull of (poly1 + poly2) (c) Delta edges (d) Intersecting edges (e) Poly1-poly2 (f) Poly2-poly1 (g) Computed intersection points (h) Intersection region Figure 5.5: Convex-convex intersection example

93 Chapter 5 - AHD BASED GEOMETRIC OPERATIONS 70 (a) Input polygons (b) Decomposed inputs (c) CHTs of input polygons (d) Intersection of convex hull of A, a1 and the CHT of B (e) CHT of intersection (f) Intersection CHT component hulls (g) Intersection region (A B) Figure 5.6: Convex-nonconvex intersection computation children trees of b1. Since the intersection between convex hull a1 and b3 is null, the child tree of b3 containing convex hull b4 will not be evaluated further (Figure 5.6e). The resultant intersection is a nonconvex region that is represented by two convex hull components as shown in Figure 5.6f. The evaluation (merging) of the resultant CHT, containing two component convex hulls results in the resultant intersection region as shown in Figure 5.6g. Since the intersection of a convex and a nonconvex polygon may be a set of disjoint convex or (and) nonconvex regions (e.g. Figure 5.12f ), the resultant CHT (if it does not represent a single convex region) is further evaluated for simplification, that results in multiple CHTs each representing the disjoint intersection

94 Chapter 5 - AHD BASED GEOMETRIC OPERATIONS 71 Input: A convex polytope poly1 and a nonconvex polytope poly2 (CHT): poly1 = ch and poly2 = Node x xts where x is the convex hull of poly2 and xts is the set of children CHTs 1 Initialize I as an empty tree 2 if xts is empty then 3 t = Node ( intersection of ch and x) [ ] 4 I = set of trees containing only t 5 else 6 ct = map ( CNINT ch ) xts // set of trees by recursively traversing xts with ( CNINT ch) 7 it = Node ( CCINT of ch and x) ct 8 eir = process it // set of edges of intersection region obtained by processing it 9 ir = splitregions eir // set of disjoint regions obtained by separating closed regions I = build ir // set of trees obtained by building each region in ir Output: Set of disjoint intersection regions I represented in CHT Figure 5.7: Pseudocode of convex-nonconvex intersection algorithm region. Pseudocode of convex-nonconvex intersection: The pseudocode of the CNINT is shown in Figure 5.7. Complexity of convex-nonconvex intersection algorithm: For a convex object with number of points m and a nonconvex object with number of points n and notches p, the worst case time complexity of the algorithm is O(p((m + n)log(m + n))). An Example of convex-nonconvex intersection: The example in Figure 5.8 shows the algorithmic steps for convex-nonconvex intersection computation Generic intersection operation The intersection operation for a convex and a nonconvex object, CNINT, is then used to compute the intersection between two nonconvex objects represented by CHTs. Suppose two intersecting nonconvex polygons A and B as shown in Figure 5.9a. Figure 5.9b shows the decomposed convex hull components of both nonconvex polygons and their CHTs are shown in Figure 5.9c. The intersection process starts by taking the convex-nonconvex intersection between convex hull of nonconvex polygon B (b1 ) and the CHT of the nonconvex polygon A (Figure 5.9d).

95 Chapter 5 - AHD BASED GEOMETRIC OPERATIONS 72 (a) Input polygons (b) Decomposed inputs (c) a1 and b1 (d) a1 b1 (e) a1 and b2 (f) a1 b2 (g) a1 b3 = NULL (h) A B Figure 5.8: Convex-nonconvex intersection example

96 Chapter 5 - AHD BASED GEOMETRIC OPERATIONS 73 (a) Two nonconvex polygons A and B (b) Decomposed components of A and B. A B is highlighted (c) CHTs of A and B (d) Intersection of A and b1 (convex hull of B) (e) Resultant CHT of (d) (f) a2 b1is null (g) Intersect the result of (f) with children of node b1 recursively (h) Resultant CHT of (g) (i) Result of h as b1 b2 = b2is null Figure 5.9: Generic intersection operation (j) Add or graft result of i to the its parent intersection CHT

97 Chapter 5 - AHD BASED GEOMETRIC OPERATIONS 74 Since the intersection between b1 and a2 convex components is null (Figure 5.9e ), the result is a single node CHT (Figure 5.9g) having the convex hull (a1 b1) which is then intersected recursively with all the children trees of convex hull b1 of the nonconvex polygon B. Since, b1 has only one child (which is also a single node representing a convex hull) the intersection of (a1 b1) and child tree (Figure 5.9h) results in a convex hull (a1 b2) represented in a single node CHT as shown in Figure 5.9i and Figure 5.9j. The resultant CHT containing (a1 b2) is then added (grafted) back to the parent intersection CHT containing single node (a1 b1). Thus, the result is a nonconvex region shown as shaded in Figure 5.9b and the resultant CHT shown in Figure 5.9j. If the result of convex-nonconvex intersection is a set of disjoint regions (a set of CHTs, each representing a region) then for each CHT of the disjoint region, the same process is repeated independently of the other CHTs representing the disjoint intersection regions. Pseudocode of generic intersection operation: The algorithm for generic intersection operation incorporates the previous two intersection operations. It is generic in the sense that it computes the intersection of two polygons (convex or nonconvex and with or without holes). The pseudocode of the GINT is shown in Figure Complexity of generic intersection algorithm: For two arbitrary regions with number of points m and n and notches q and p respectively, the worst case time complexity of the algorithm is O(qp((m + n)log(m + n))). An example of generic intersection operation: An example of generic intersection operation between two nonconvex polygons is shown in Figure Intersection special cases The intersection of two polygons may be a point (Figure 5.12a), a line (Figure 5.12b), polygon or a combination consisting of the three (Figure 5.12f). In cases where the intersection region is not a polygon or a set of polygons, special treatment is needed. A variety of special cases for the basic intersection have been shown by O Rourke [1998] and few are shown in Figure Since the approach is based on basic intersection operation, there is no need to tackle the special cases for convex-nonconvex or nonconvex-nonconvex intersection operations. If the special cases are tackled for basic operation, other operations based on it will also tackle the special cases. For special cases like

98 Chapter 5 - AHD BASED GEOMETRIC OPERATIONS 75 Input: Two polygonal regions (convex or nonconvex) in CHT notation: poly1 = Node x xts and poly2 = Node y yts where x and y are the convex hulls and xts and yts are the set of children trees of polygon 1 and polygon2 respectively 1 Initialize I as an empty tree 2 if xts is empty // poly1 is convex 3 then return CNINT x poly2 4 else if yts is empty // poly2 is convex 5 then return CNINT y poly1 6 else 7 oi = CNINT y poly1 8 if oi is empty 9 then return I 10 else for every tree tx in oi 11 for every tree ty in yts 12 ct = compute GINT tx ty 13 nt = addtrees ct in tree tx 14 I = addtree nt into I 15 return I Output: Set of disjoint intersection regions I in CHT Figure 5.10: Pseudocode of generic intersection algorithm complete or partial overlap, the approach do not need any special treatment. However, for cases when the intersection is a point or a line, special treatment is needed which is achieved by making changes not in the main intersection algorithms but in the QuickHull module and the eval function of the AHD. Table 5.1 lists special cases and whether these cases are specially treated in the algorithm or not Intersection solution characteristics The proposed solution to perform Boolean intersection operations on general polygons has following properties; 1. The approach is robust as it uses homogeneous big integer coordinates for representing points. Robustness is an important issue in geometric computations [Mount, 1997]. Most of the algorithms, as discussed in section 2.3 on page 24, do not cater the robustness issue. Only few address the issue [Mount, 1997, Smith and Dodgson, 2007]. 2. The approach is based on the basic intersection operation between two

99 Chapter 5 - AHD BASED GEOMETRIC OPERATIONS 76 (a) Input nonconvex polygons (b) Decomposed inputs (c) CNINT: CHT of A and convex hull of B (d) Result of (c) (e) Result in (c) is simplified and two disjoint regions result (f) r1 first child of B (g) Result of (f) (h) Remove (g) from r1 (i) Result in (h) second child tree of B (j) r2 first child of B (k) Result of (j) (l) Remove result in (k) from r2 (m) Result in (l) second child tree of B (n) Result of (m) (o) Remove (n) from (l) (p) Disjoint intersection regions Figure 5.11: Nonconvex-nonconvex intersection example

100 Chapter 5 - AHD BASED GEOMETRIC OPERATIONS 77 (a) (b) (c) (d) (e) (f) Figure 5.12: Some special cases for intersection computation Table 5.1: Special case treatment

101 Chapter 5 - AHD BASED GEOMETRIC OPERATIONS 78 (a) A given region R (b) Complement of given region R Figure 5.13: Complement R of a given region R convex polygons. Thus it exploits the benefits associated with convexity. 3. The tree data structure of AHD supports LoD and allows reduced number of computations. The children trees of a node are evaluated only if the intersection is not null. The algorithm proceeds recursively in a branch of CHT only if the intersection is not null. Rule is an object A can not intersect with the component hulls of object B, if convex hull of object A is not intersecting with the convex hull of object B. 4. In some applications, the result of Boolean operation may be needed to be decomposed. For example, Vatti [1992] mentions a case when decomposed output is useful. So the approach is useful for applications where the decomposed output is needed in the form of convex components. 5. The special cases need no special treatment like overlapping edges etc. Some require few modifications like when the result has dangling edges or points etc. 6. The approach is dimension independent. 5.2 Complement Computation Is it possible to compute the complement of a region represented in a CHT data structure using AHD approach? Since AHD can deal regions with holes, the complement of a region is just an open region with the given region as a hole as shown in Figure 5.13.

102 Chapter 5 - AHD BASED GEOMETRIC OPERATIONS 79 At data structure level, the complement of a given region R represented by AHD is simple. The CHT of R is grafted as to a special node called universal node, that represents the convex hull of the universal region (which is an open region) which makes region R a hole of the universal open region. For the sake of simplicity and understanding assume that the universal region is finite and large enough to contain the given region or regions. The complement of a polygon represented by AHD is computed in constant time as it includes the addition or removal of the universal node from the CHT representing the polygon. 5.3 Union Computation Intersection of two arbitrary shape regions represented using AHD is a simple, efficient and provable algorithm because the intersection of two convex regions is always convex. Unfortunately, the union of two convex regions is not always convex and thus no straightforward algorithm for union has been found. Duality is an approach that allows to replace a complicated algorithm into a simpler dual one using the equation; dual(a b) = (dual a) (dual b) where is the dual operation to and dual.dual=id Here a convincing approach for union computation is presented that exploits duality. The approach shows that eventually the same algorithm (for intersection) can be used to compute union with the same low complexity. From school mathematics (De Morgan s laws) the intersection and union operations are dual of each other with respect to complement: A B = A B A B = (A B) (5.1) Since the union is computed using the intersection algorithm, it has the same complexity as the intersection algorithm.

103 Chapter 5 - AHD BASED GEOMETRIC OPERATIONS 80 Figure 5.14: A B 5.4 Difference and Symmetric Difference Computation In mathematics, the symmetric difference (logical XOR) of two sets is the set of elements which are in either of the sets and not in their intersection. The symmetric difference of two regions A and B, denoted by A B, is the region containing both of the regions A and B (AUB) excluding the intersection region (A B) as shown in Figure The symmetric difference of two regions is defined as; A B = (A B) \ (A B) (5.2) A B = (A \ B) (B \ A) (5.3) So symmetric difference of two regions results in two disjoint regions, one representing A \ B and other B \ A. Like union, the closure property also do not hold for difference operation. Like for union operation, the duality is used for computing the difference using the intersection operation for computing A \ B as shown in Figure We know that: A \ B = A B (5.4) B \ A = B A (5.5) Using equations 5.1 and 5.4, the equation 5.2 for A B can be rewritten solely

104 Chapter 5 - AHD BASED GEOMETRIC OPERATIONS 81 (a) Two intersecting regions A and B (b) Complement of region B (c) Compute A B (d) A \ B = A B Figure 5.15: Difference computation (A \ B example) in intersection and complement terms as; A B = ((A B)) (A B) (5.6) Using equations 5.1, 5.4 and 5.5 the equation 5.3 for A B can be rewritten solely in intersection and complement terms as; A B = (A B) (B A) (5.7) Either of the equations 5.6 or 5.7 can be used for the implementation of symmetric difference computation. 5.5 Line-Region Intersection Computation The problem of determining the intersection of a line segment and a region (as shown in Figure 5.16a) is important for computations like removal of hidden faces, collision detection, Boolean operations etc [Segura and Feito, 1998]. For the computation of line-region intersection, another data structure called

105 Chapter 5 - AHD BASED GEOMETRIC OPERATIONS 82 segment tree is introduced. The segment tree is an arbitrary tree, like CHT, every node of which represents a list of line segments. Figure 5.17a shows the CHT of region R shown in Figure 5.16a. The algorithm for the line-region computation uses the algorithm for computation of a line with a convex hull. The algorithm starts by computing the intersection of L and the convex hull of region R which is the root of the CHT represented as node 0. If the result is empty meaning line is not intersecting the given region, then the algorithm stops. The result of L 0 which is a line segment L 0 as shown in Figure 5.16c is stored as the root of the segment tree (Figure 5.17b). The process is then repeated for every child tree of CHT. LoD enables that sub-trees of a node in CHT are not evaluated if the intersection of line L and the convex hull represented by that hull is empty e.g. nodes L 3 and L 5 are empty and will not be further evaluated even if these would have children trees. Figure 5.17 shows the intersection computation steps, the resulting component line segments are shown in Figure 5.17d and Figure 5.17c shows the corresponding final segment tree. For the output generation the segment tree is traversed in preorder. The evaluation involves the subtraction of a line segment from a given line. The line segments in the children nodes of a given node are sequentially subtracted (from left to right) from the line segments represented by that node. This is done recursively on the children trees of a node and is shown in Figure 5.17e. Root contains segment L 0 from which evaluated left most child tree is to be subtracted first. Since it is a single node containing segment L 1, simply subtract it from which results in segment L 01 updating node 0. Now second sub-tree is evaluated which means L 4 is subtracted from L 3 resulting in two segments L 34 which are then subtracted from L 01 at node 0 resulting in L 34 and the root node 0 is updated with the result. The single node then contains set of segments which are the result of the intersection computation. 5.6 Point in Polygon Test The hierarchical data structure of AHD offering LoD facilitates the spatial searching problems. This is shown with point in polygon (PIP) test which is a special case of point location problems and is most basic of spatial operations ([De Smith et al., 2007], page 86).

106 Chapter 5 - AHD BASED GEOMETRIC OPERATIONS 83 (a) A Line L intersecting a region R (b) Convex Decomposition of region R (c) L 0 = L 0 (d) L 1 = L 1 (e) L 3 = L 3 (f) L 4 = L 4 Figure 5.16: Line-region intersection (a) CHT of region R and a single segment node containing the line L (b) Line segment tree (c) Line segment tree (d) Component line segments (e) Segment tree manipulation Figure 5.17: Line-region intersection steps

107 Chapter 5 - AHD BASED GEOMETRIC OPERATIONS 84 (a) A nonconvex region and a point for PIP test (b) Decomposed input polygon for PIP test (c) CHT of input polygon for PIP test Figure 5.18: AHD based point in a polygon test The PIP problem Given a region R represented by an arbitrary polygon and a point p as shown in Figure 5.18, the problem is to determine whether p lies inside or outside of region R AHD based PIP computation Given a region R represented by AHD and a point p (Figure 5.18) a simple and efficient algorithm for PIP test is provided. The convex decomposition of the given region R is shown in Figure 5.18b while Figure 5.18c shows the corresponding CHT data structure. The algorithm for PIP test utilizes the point in convex polygon (PICP) algorithm for which efficient solutions already exist. Because of the LOD structure of AHD, determining that the given point is not inside a given region is immediate, this needs just testing the point p s inclusion in the convex hull of the region which is at the root of the CHT. If the point p is not in the convex hull 0, the tree is not evaluated further and algorithm returns with False. If the point is in the convex hull of region, then evaluate the children trees with PICP from left to right recursively. Pruning is done by filtering those

108 Chapter 5 - AHD BASED GEOMETRIC OPERATIONS 85 sub-trees whose roots do not contain the point p i.e. test PICP for point p and the root of the sub-tree is FALSE. Any child tree whose root does not contain p is pruned and not evaluated further. The pruning greatly reduces the search space thus adding to search efficiency. The result True or False depends on the level of node where the search stopped. If odd level, search returns False else it returns true. For the example in Figure 5.18, the test PICP for p and convex hull 0 returns True. Therefore, children of hull 0 are evaluated from left to right. Pruning eliminates all children trees except two children trees whose roots are hull 4 and hull 7. These trees are then recursively evaluated until the point is found in hull 5. Since the node containing hull 5 is at even level (level 2), True is returned by child tree whose root is hull Operations Summary Boolean operations are of fundamental importance for GIS processing. The chapter shows that AHD allows optimal (or near optimal) computation of Boolean and other geometric operations (point in a polygon and line intersecting a polygon) using AHD approach. The intersection operation is of fundamental importance as other Boolean operations union, difference and symmetric difference can be reduced to the computation based on intersection and complement. The complement of a polygon is computed in constant time by adding or removing a universal node as the root of the CHT representing the polygon. The union, difference and symmetric difference are then computed using the principle of duality in terms of intersection and complement operations. The algorithms for the computation of these Boolean operation, point in polygon test and line-region intersection are provided. The algorithms are efficient because the LoD structure of AHD offers pruning and children nodes are processed only if they qualify some test. LoD together with lazy evaluation (provided by some programming languages e.g. Haskell) make the geometric algorithms by reducing the number of computations.

109

110 Chapter 6 AHD AND OPERATIONS: IMPLEMENTATION IN HASKELL In previous chapters, I provided details of AHD and associated operations. In this chapter I will provide implementation of AHD and related issues. All the algorithms mentioned in previous chapter have been implemented using Haskell [Jones and Jones, 2003]. The selection of Haskell for implementation provides ease of implementation giving simple and compact code. Haskell is selected because it supports (see appendix... for Haskell overview); ˆ Lazy evaluation: Lazy evaluation means an expression, a function or an argument passed to a function, or a data structure is evaluated only when its value is actually used. Lazy evaluation increases performance by avoiding unnecessary calculations. In case of AHD, lazy evaluation is useful because the CHT is not built or evaluated unnecessarily until its result is actually used. The CHT is built or evaluated only to the LoD needed as opposed to eagerly building or evaluating the CHT entirely. LoD data structures and lazy evaluation work well together: levels of detail not necessary to determine the result are not explored [Samet, 2006]. This effect is automatic in languages with a lazy execution strategy, e.g., Haskell [Hudak et al., 1992]; it is then possible to chain multiple operations on LoD structures together and the whole expression is evaluated only to the degree necessary. In ordinary languages, the expressions must be folded into the 87

111 Chapter 6 - AHD AND OPERATIONS: IMPLEMENTATION IN HASKELL 88 ultimate evaluation code (gradual for each level) to achieve the same effect, namely avoiding building intermediate results to a degree not necessary. ˆ High order functions - Functors: Functors are higher order functions that take another function (s) as an argument. Functors are a principled way to extend a given algebra in one domain to another domain e.g. Karimipour et al. [2008] has shown lifting functors to lift a domain (e.g., static 2D) to another domain (e.g., moving 2D). In case of AHD, lifting functors are needed to achieve dimension independence by extending the AHD algebra for 2D to n-dimensions. ˆ Big Integers: Haskell supports arbitrary precision arithmetic. The built in Integer (big integer) data type implements arbitrary precision arithmetic. In case of AHD, the point coordinates are represented as homogeneous big integers to ensure robustness in geometric computations. ˆ Compact code: Haskell code is concise and compact. Schrage et al. [2005] have shown that a system developed in Java when reproduced with Haskell resulted in reduction of lines of code from 220, 000 to 10,000, a reduction ratio of 22 : 1. Less code leads to less errors, ease of management and maintenance. 6.1 Input Representation In this section the representation of input domain region is discussed. This is important because the AHD algorithm design depends on the representation of the region. A region is a collection of polygons which in turn are defined by set of rings. The outer ring (having counter clockwise orientation) makes the boundary of the polygon while inner rings make the holes of the polygon and have opposite orientation than outer boundary. A ring is defined by set of points. Figure shows the hierarchy of geometric data types needed for the representation of an input region. Figure 6.2 shows a region represented with two polygons, polygon1 and polygon2. Polygon1 (Figure 6.2a) has two rings, the outer ring with 12 points and counter clockwise orientation represents the boundary of the polygon while an

112 Chapter 6 - AHD AND OPERATIONS: IMPLEMENTATION IN HASKELL 89 Figure 6.1: Hierarchy of geometric data types for region representation (a) Polygon1 (b) Polygon2 Figure 6.2: A Region R represented by two polygons inner ring with 6 points and clockwise orientation represents a hole. Polygon2 (Figure 6.2b) has only one ring with 8 points and counter clockwise orientation. The input data types in Haskell are shown below. type Point = ( Int, Int ) data Ring = Ring { _lpoints :: [ Point ]} deriving ( Show, Eq, Ord ) unring ( Ring ring ) = ring data Poly = Poly { _lrings :: [ Ring ]} deriving ( Show, Eq, Ord ) unpoly ( Poly poly ) = poly data Reg = Reg { _reg :: [ Poly ]} deriving ( Show, Eq, Ord ) unreg ( Reg reg ) = reg

113 Chapter 6 - AHD AND OPERATIONS: IMPLEMENTATION IN HASKELL Implementation of AHD AHD is based on the convex decomposition of nonconvex polytopes into their convex components, convex polytopes. The implementation details of the AHD algorithms for 2D case are provided and shown how AHD is implemented dimension independently using simplicial decompositions D implementation of AHD The implementation of AHD needs the definition of geometric data types that AHD must support. I defined the geometric data types for AHD based representation model using the algebraic data types provided by Haskell Geometric data types For robustness in geometric computations using AHD the point coordinates are defined by homogeneous big integer (Haskell Integer type) coordinates. It is named as BPoint to differentiate it from Haskell built in Point type). AHD uses convex hull as the geometric building block and is defined as the list of BPoint. The definition of aforementioned data types using Haskell s algebraic data types is shown below; data BPoint = Bpt {_w, _x, _y :: Integer } deriving ( Show, Eq, Ord ) unpoint ( Bpt w x y) = (w, x, y) data CHull = CHull { _chull :: [ BPoint ]} deriving ( Show, Eq, Ord ) unchull ( CHull ch) = ch Geometric data structure AHD is based on the convex decomposition of a given nonconvex region into its convex components. The component convex hulls are stored in a tree data structure, which is called convex hull tree. The code below shows the definition of convex hull tree data structure in Haskell. data Tree p = Node { _this :: p, _childtrees :: [ Tree p], _level :: Level } LeafNode { _this :: p, _level :: Level }

114 Chapter 6 - AHD AND OPERATIONS: IMPLEMENTATION IN HASKELL 91 UniNode { _this :: p, _childtrees :: [ Tree p], _level :: Level } NullTree {} deriving ( Eq, Show, Read ) where p is the geometric primitive stored by nodes of the Tree which is a convex hull in case of AHD Node is the constructor that creates a node and every node has three type variables this of a node is the variable of type p and keeps the primitive that node holds childtrees of a node is the variable of type list of Tree p and keeps the children trees of that node level of a node is the variable of type Level The Level type is useful for level of detail and is defined as newtype Level = Level Int deriving (Eq, Ord, Show, Read, Num ) unlevel ( Level i) = i Some of the useful operations on Level are shown below. The function iseven is useful for PIP test, where a point contained by a node of CHT at even level means the point in the region represented by the CHT otherwise it is not included. The inc and dec functions are used for updating the levels of a CHT and are needed for grafting and complement operations. iseven ( Level l) = even l inc l = l+1 dec l = l -1 Figure 6.3 shows relationship hierarchy between input representation and AHD AHD Algebra Haskell s type classes are used to define AHD algebra which will provide the prototypes of operations or functions of AHD. The two functions of AHD are build and eval. The build function builds the tree structure by decomposing the given nonconvex polygon into its convex components and populates the data structure.

115 Chapter 6 - AHD AND OPERATIONS: IMPLEMENTATION IN HASKELL 92 Figure 6.3: Relationship between input representation and AHD On the other hand, the eval function retrieves the polygon by evaluating the given tree structure. class AHD inp rep prim where build :: Level -> Level -> inp -> [ rep prim ] eval :: Level -> Level -> [ rep prim ]-> inp The AHD type class defines two functions build and eval for three type variables inp, rep and prim. The type variable inp represents the type of input which may be a ring, a polygon or a region. The rep prim type variables define the type of data structure and type of values in that data structure respectively. In AHD, type variable rep represents the Tree data structure and prim type variable represents the type of the value in the node of the tree which is the convex hull, CHull. The two Level arguments in the build and eval functions are needed for implementing level of detail. The first argument of type Level specifies the level up to which the tree is to be built or evaluated and the second argument of type Level is useful for performing recursion and also specifies the starting level number (which is 0 by default meaning root of any tree has level 0) for build and eval functions. The implementation of AHD class relies on functions of the Input and InpPrim classes which are shown below.

116 Chapter 6 - AHD AND OPERATIONS: IMPLEMENTATION IN HASKELL 93 Table 6.1: Functions of Input and Prim classes Function Description Example merge Given two overlapping polygons (e.g. p1 and p2), the function merges the two and returns the resulting new polygon (e.g. p) split makeprim mergprim Given a polygon (e.g. p), the function splits the polygon and returns its extracted deltas or nonconvexties (e.g. d1 and d2 ). Given a polygon (e.g. p), the function makes the its primitive which is the convex hull of the object (e.g. ch) Given two convex hulls (one parent and one child e.g. ch0 and ch1 respectively), the function merges the two hulls and returns the resulting polygon ring r as shown in the example figure on right. class Input inp where merge :: inp -> inp -> inp split :: inp -> [ inp ] class InpPrim inp prim where makeprim :: inp -> prim mergeprim :: prim -> prim -> inp Table 6.1 shows a brief description of the functions in both classes for the case of an input polygon (inp) and convex hull (prim) with some examples Instances for AHD algebra The algebra defined above provides a framework for generic implementation of build and eval functions of AHD. This is achieved by instantiating the defined classes for different input geometric types. For example, the code snippet below shows the instantiation of the build and eval functions for a Ring, Poly and Reg data types. instance AHD Ring Tree CHull where

117 Chapter 6 - AHD AND OPERATIONS: IMPLEMENTATION IN HASKELL 94 build mlev clev ring = if ( drings == []) ( mlev == clev ) then [( LeafNode p clev )] else [ Node p ( concat ( map ( build mlev nl) drings )) clev ] where p = makeprim ring drings = split ring nl = inc clev eval mlev [( LeafNode ( CHull p) l)] = Ring p eval mlev [( Node ( CHull p) lts l)] = if ( mlev == l) then Ring p else ( foldl mergefunc ( Ring p) llr ) where llr = ( map ( eval mlev ) ( toll lts )) instance AHD Poly Tree CHull where build mlev clev ( Poly []) = [] build mlev clev ( Poly lr) = [ foldl mergtrees ( head ltrees ) ( tail ltrees )] where ltrees = concat ( map ( build mlev clev ) lr) eval mlev [( LeafNode ( CHull p) l)] = Poly [ Ring p] eval mlev [( Node ( CHull p) lts l)] = if ( mlev == l) then Poly [ Ring p] else ( foldl mergefunc ( Poly [ Ring p]) lp) where lp = ( map ( eval mlev ) ( toll lts )) instance AHD Reg Tree CHull where build mlev clev ( Reg []) = [] build mlev clev ( Reg reg ) = ltrees where ltrees = concat ( map ( build mlev clev ) reg )

118 Chapter 6 - AHD AND OPERATIONS: IMPLEMENTATION IN HASKELL 95 eval mlev lts = Reg lp where lp = ( map ( eval mlev ) ( toll lts )) The implementations of the functions in the the two classes, Input and InpPrim, are shown in the code snippet below. instance Input Ring where merge ( Ring r0) ( Ring r1) = Ring ( edge2vertex nmre ) where er0 = mkedges r0 er1 = mkedges r1 oes = [( ce0, ce1 ) ce0 <- er0, ce1 <- er1, isedgeon ce1 ce0 ] re0 = er0 \\ ( map fst oes ) de1 = er1 \\ ( map snd oes ) re1 = map revorient de1 nmes = concat ( map mergedges oes ) nmre = re1 ++ re0 ++ nmes split ring = map listedges2ring dre where dre = sepreg fde ( CHull ( nub ( ( unchull ch) ++ dph ))) dph = nub. flatten $ ( de \\ fde ) fde = filter (\ y - > fst ( isedgeonreg y he)== False ) de de = ( mkedges. unring $ ring ) \\ he he = mkedges. unchull $ ch ch = quickhull ring instance Input Poly where merge ( Poly p0) ( Poly p1) = Poly ( mergeringlists p0 p1) instance InpPrim Ring CHull where makeprim ring = quickhull ring mergeprim ( CHull r0) ( CHull r1) = [ Ring ( edge2vertex nmre )] where er0 = mkedges r0

119 Chapter 6 - AHD AND OPERATIONS: IMPLEMENTATION IN HASKELL 96 er1 = mkedges r1 oes = [( ce0, ce1 ) ce0 <- er0, ce1 <- er1, isedgeon ce1 ce0 ] re0 = er0 \\ ( map fst oes ) de1 = er1 \\ ( map snd oes ) re1 = map revorient de1 nmes = concat ( map mergedges oes ) nmre = re1 ++ re0 ++ nmes instance InpPrim Poly CHull where makeprim poly = quickhull ( head. unpoly $ poly ) Dimension independent implementation of AHD AHD can be implemented dimension independently by lifting operations [Karimipour et al., 2008]. Table 6.2 lists some of the operations on the simplexes, which are used for developing the decomposition algorithm. For dimension independent implementation of AHD, the functions of Input and InputPrim need dimension independent implementation. The code below shows the definition of geometric data types and the instances for the classes of AHD algebra. -- An n dimnesional point defined as a list of homogenous big integer points type ND_ BPoint = [ BPoint ] -- An n- simplex is defined as a list of n dimensional vertexes type Simplex = [ ND_ Vertex ] -- Canonical representation of a n- simplex type CnSimplex = ( Simplex, Bool ) instance AHD [ CnSimplex ] Tree [ CnSimplex ] where build mlev clev reg = if ( dreg == []) ( mlev == clev ) then [ LeafNode chreg clev ] else [ Node chreg ( concat ( map ( build mlev ( inc clev )) dreg )) clev ] where chreg = makeprim reg

120 Chapter 6 - AHD AND OPERATIONS: IMPLEMENTATION IN HASKELL 97 Table 6.2: Operations on simplexes Operation Description Example addvertex(v, S) Adding a vertex v to an n-simplex S, which produces an (n+1)-simplex cw(p, S) ptinsimplex(p,{s i }) Testing the position of a point p w.r.t. a simplex S (clockwise or counterclockwise) Testing if a point p is inside the region delimited by a set of simplexes {S i } S 1 =< v 0,v 1 > addvertex(v,s 1 ) =< v 0,v 1 > cw(p,s1) = f alse ccw(p,s1) = true S 1 =< v 0,v 1 > ptinsimplex(p 1,R) = true ptinsimplex(p 2,R) = f alse Border({S i }) Extracting the border of a set of connected simplexes {S i } R = {S 1 1,S5 1 } Border(R) = {S j } ({S j } =bold edges) Split({S i }) Splitting a set of simplexes{s i } to the connected subsets {R 1,...,R k } R = {S i } ({S i } =all edges) Split({S 1 1,...,S9 1 }) = ({S 1 1,...,S5 1 },{S6 1,...,S8 1 },{S9 1 })

121 Chapter 6 - AHD AND OPERATIONS: IMPLEMENTATION IN HASKELL 98 dreg = split $ symdiff reg chreg eval mlev [( LeafNode s l)] = s eval mlev [( Node s lts l)] = if ( mlev == l) then s else symdiff s rs where rs = concat ( map ( eval mlev ) [ lts ]) instance InputPrim [ CnSimplex ] [ CnSimplex ] where makeprim ls = convexhull ( nub. concat. map cnsimp2simp $ ls) instance Input [ CnSimplex ] where split = splitjoints. splitordregs 6.3 Implementation of AHD based Geometric Operations AHD operations algebra The algebra of AHD operations is shown below. The class Prim defines the ccint (convex-convex intersection) between two convex geometric primitives and the result is also convex. The class will be instantiated for the AHD primitive convex hull as the value of type variable prim, the intersection of two convex hulls is always convex. The class AHDOperations defines the functions to be implemented for AHD. class Prim prim where ccint :: prim - > prim - > prim class AHDOperations rep prim where cnint :: prim - > rep prim - > [ rep prim ] gint :: rep prim - > rep prim - > [ rep prim ] comp :: [ rep prim ]-> [ rep prim ] uni :: rep prim -> rep prim -> [ rep prim ] diff :: rep prim -> rep prim -> rep prim symdiff :: rep prim - > rep prim -> rep prim

122 Chapter 6 - AHD AND OPERATIONS: IMPLEMENTATION IN HASKELL 99 pir :: BPoint -> rep prim -> Bool Implementation of intersection operation As discussed earlier, intersection computation is the most important operation as other operations like union difference and symmetric difference are computed using the intersection operation. The code for an instance of the Prim class that implements the ccint function for a convex hull primitive is shown below. instance Prim CHull where ccint ( CHull p1) ( CHull p2) = if ( p1 \\ pinp2 == []) then CHull p1 else if ( p2 \\ pinp1 == []) then CHull p2 else if (( length. unchull $ ip) <=2) then CHull [] else ip where ( CHull chp ) = quickhull ( Ring ( union p1 p2)) che = mkedges chp ine1 = ( mkedges p1) \\ che ine2 = ( mkedges p2) \\ che vip = fip $ pie ine1 ine2 pinp2 = pointsinoron ( CHull p1) ( CHull p2) pinp1 = pointsinoron ( CHull p2) ( CHull p1) ip = quickhull ( Ring ( pinp1 ++ vip ++ pinp2 )) The intersection of a convex and a nonconvex object can be convex or nonconvex. Using the ccint function, the intersection of a convex hull and a nonconvex object is computed by recursively applying ccint over the tree of nonconvex object. The generic intersection computation function gint is then implemented using cnint that computes intersection between two trees which may represent a convex or nonconvex object as shown in the code below. instance AHDOperations Tree CHull where cnint ch ( LeafNode x l) = [ LeafNode ( ccint ch x) l] cnint ch ( Node x xts l) = if ( ohi == CHull [] ) then []

123 Chapter 6 - AHD AND OPERATIONS: IMPLEMENTATION IN HASKELL100 else [( Node ohi ( concat ( map ( cnint ohi ) xts ) ) l)] where ohi = ( ccint ch x) gint t ( LeafNode y ly) = cnint y t gint ( LeafNode x lx) t = cnint x t gint ( Node x lct lx) t = if ( oi == []) then [] else [ foldl mergtrees ( head oi) lt] where oi = cnint x t lt = concat ( map ( gint ( head oi)) lct ) intreg r1 r2 = concat [( gint p x) p<- r1, x<- r2] Implementation of complement operation Using the principle of duality, the union and symmetric difference operations are computed in terms of intersection and complement operations (De Morgans Law). The implementation of complement operation is shown below. instance AHDOperations Tree CHull where... compreg lpt = if ( length lpt ==1) && ( is_ Uni. head $ lpt ) then dts else [ UniNode ( unihull ) its 0] where its = map ( inctlevel 0) lpt dts = map ( dectlevel 0) ( tail lpt )... The function compreg complements the given region by adding all the polygon trees of the region as the children of the universal node, UniNode. The universal node contains the universal hull. For simplification the drawing space could be assumed as the finite universal space, in which case, the convex hull of the drawing space becomes the universal hull. According to the principle of duality, the dual of a dual function is identity. The compreg implements this property,

124 Chapter 6 - AHD AND OPERATIONS: IMPLEMENTATION IN HASKELL101 and the complement of a complemented region returns the original region Implementation of union operation The union operation is implemented as a dual function using intersection and complement functions (r1 r2 = r1 r2 ), the implementations of which have already been given. The function unireg computes the union of two regions. The complement of the intersection of complemented regions gives the union region. instance AHDOperations Tree CHull where... unireg r1 r2 = compreg ( intreg cr1 cr2 )... where cr1 = compreg r1 cr2 = compreg r Implementation of difference and symmetric difference operations The implementation of symmetric difference needs the implementation of difference operation. The difference of two regions is implemented using the complement and intersection operations. r1 \ r2 = r1 r2 r2 \ r1 = r2 r1 The symmetric difference of two regions is then computed by taking the union of two difference regions r1 \ r2 and r2 \ r1. r1 r2 = (r1 \ r2) (r2 \ r1) instance AHDOperations Tree CHull where... difreg r1 r2 = intreg r1 ( compreg r2) symdreg r1 r2 = unireg r1minr2 r2minr1 where r1minr2 = difreg r1 r2 r2minr1 = difreg r2 r1...

125 Chapter 6 - AHD AND OPERATIONS: IMPLEMENTATION IN HASKELL Implementation of point in polygon The point in polygon uses the geometric function ispointinhull which determines whether a given point is in the hull or not. The children of a tree are evaluated only if the given ispointinhull returns true for the given point and the convex hull at the root. This is lazily done because the Haskell s built in lazy evaluation, thus pruning children trees whose root hulls do not include the point. instance AHDOperations Tree CHull where... pip p ( LeafNode ch l) = ( ispointinhull p ch) && ( iseven l) pip p t = ( ispointinhull p ch) && ( all (== False ) lb) && ( iseven l) where ch = this t l = level t cts = childtrees t lb = map ( pip p) cts pir p r = ( any (== True ) lpip ) where lpip = map ( pip p) r 6.4 Implementation of Generalized LoD Data Structure In the previous sections I showed that Tree data structure of AHD supports LoD and design of progressive algorithms for performing Boolean operations. In this section I will show that the AHD s LoD based tree data structure works for other LoD based data structures and operations. This is shown with two examples, first in which the data is divided over LoD by delta is the segment tree, and the other in which the data is divided over the LoD by replacement is the strip tree [Ballard, 1981]. 1. Segment tree - Intersection computation between a region represented in the CHT of AHD and a line segment is done progressively by intersecting the line segment with convex hulls stored in the CHT. The intersection between a line and a convex hull (assuming that both intersect) is always

126 Chapter 6 - AHD AND OPERATIONS: IMPLEMENTATION IN HASKELL103 Figure 6.4: The function f(x) with three approximations Figure 6.5: One piece of a linear function approximating the given function a line segment, which is stored in a tree every node of which contains a list of line segments, the tree called as segment tree. 2. Strip tree - Strip trees approximate lines with straight line segments describing for each level the error bounds on the approximation. The approximated line segments are called a strip organized in a tree called a strip tree. This can be seen as an approximation of a continuous function in one variable y = f (x) by a hierarchy of piecewise linear functions (Fig. 6.4). The linear function in an interval (Fig. 6.4) is gradually approximated with linear functions, for smaller and smaller intervals Fig. 6.5) Implementation of segment-region intersection The implementation of algorithm for computing the intersection between a line segment and a region is shown below. The function intlinreg computes the intersection between a given line segment (which is stored in data type LinSeg) and a region which is achieved by mapping the function intlinpoly over the list of trees of the polygons of the region.

127 Chapter 6 - AHD AND OPERATIONS: IMPLEMENTATION IN HASKELL104 data LinSeg = LinSeg { _sp, _ep :: BPoint } deriving ( Show, Eq, Ord ) linseg ( LinSeg p1 p2) = ( p1, p2) intlinreg :: Level - > Level - > LinSeg -> [ Tree CHull ] -> [ Tree [ LinSeg ]] intlinreg ml cl s rts = concat ( map ( intlinpoly ml cl s) rts ) intlinpoly :: Level - > Level - > LinSeg -> Tree CHull - > [ Tree [ LinSeg ]] intlinpoly ml cl s ( LeafNode ch l) = [ LeafNode ( intlinhull s ch) l] intlinpoly ml cl s ( Node ch cts l) = if ( int == []) then [] else if ( ml == cl) then [ LeafNode ( intlinhull s ch) cl] else [ Node int cs cl] where int = intlinhull s ch cs = concat ( map ( intlinpoly ml (cl +1) s) cts ) The result is a list segment trees, each node of which stores a line segment. Each segment is then evaluated, resulting in a segment or list of segments which is achieved by line segment (primitive) merging. The instance of merge for LinSeg is is shown below which is used by the eval function of the AHD. instance Input [ LinSeg ] where merge ls1 ls2 = ns where os = [( cs1, cs2 ) cs1 <- ls1, cs2 <- ls2, isedgeon ( s2e cs1 ) ( s2e cs2 ) ] rs1 = ls1 \\ ( map fst os) rs2 = ls2 \\ ( map snd os) os2e = [( s2e s1, s2e s2) (s1,s2) <- os] ms = concat ( map mergedges os2e ) oe2s = [ e2s e e <- ms] ns = rs1 ++ rs2 ++ oe2s

128 Chapter 6 - AHD AND OPERATIONS: IMPLEMENTATION IN HASKELL Implementation of strip tree Two data types are defined for the implementation of strip tree algorithm. The input is a curve defined by a list of point, so the type Curve is a synonym to the list of points type. The primitive is a strip which is defined as the data type Strip having six elements where spx and spy denote the beginning of the strip, epx and epy denote the end of the strip and wl and wr are the left and right distances of the strip borders. type Curve = [ BPoint ] data Strip = Strip { spx :: Double, spy :: Double, epx :: Double, epy :: Double, wl :: Double, wr :: Double } deriving ( Show, Read ) The instantiation of the AHD algebra for strip tree implementation is shown below. instance AHD Curve Tree Strip where build mlev clev c = if ( mlev == clev ) ( is_ Splittable c == False ) then [( LeafNode p clev ) ] else [ Node p ( concat ( map ( build mlev nl) parts )) clev ] where p = makeprim c parts = split c nl = clev +1 eval mlev [( LeafNode s l)] = getcurve s eval mlev [( Node s lts l)] = if ( mlev == l) then ( getcurve s) else ( merge ( getcurve s) ( concat llr )) where llr = ( map ( eval mlev ) ( toll lts )) instance Input Curve where is_ Splittable curve = length curve > 2

129 Chapter 6 - AHD AND OPERATIONS: IMPLEMENTATION IN HASKELL106 split c = parts where iline = getline. makeprim $ c eps = getxtrmpoints iline c breakpoint = fst ( maximumby ( compare on snd ) eps ) parts = splitlist breakpoint c merge _ lc = nub $ lc instance InputPrim Curve Strip where makeprim ( p1: p2: []) = Strip { spx = p1x, spy = p1y, epx = p2x, epy = p2y, wl = 0.0, wr = 0.0} where (1.0, p1x, p1y ) = h2c ( unpoint p1) (1.0, p2x, p2y ) = h2c ( unpoint p2) makeprim lp = Strip { spx = p1x, spy = p1y, epx = p2x, epy = p2y, wl = wll, wr = wrr } where (1.0, p1x, p1y ) = h2c ( unpoint p1) (1.0, p2x, p2y ) = h2c ( unpoint p2) ( p1, p2) = getinitline lp wrr = snd. head $ lxt wll = snd. last $ lxt lxt = getxtrmpoints ( p1, p2) lp The build function works for an input of type Curve and results in an output of type [Tree Strip] i.e. a list of strip trees that contains only one strip tree of the input curve. Similarly the eval function works when the argument is of type [Tree Strip] and returns the output of the type Curve i.e. the strip tree is evaluated up to the level specified and returns the corresponding curve. This is shown with an example curve, expcurve, which is a list of points in the code in the code below. -- example curve of type Curve expcurve = [( Bpt 1 3 7), ( Bpt ), ( Bpt ), ( Bpt ),( Bpt )] :: Curve -- build strip tree of expcurve up to 3 levels, the root of strip tree should have level 0 bst = build 3 0 expcurve :: [ Tree Strip ]

130 Chapter 6 - AHD AND OPERATIONS: IMPLEMENTATION IN HASKELL evaluate bst, the strip tree of expcurve up to the level 2 est = eval 2 bst :: Curve

131

132 Chapter 7 CONCLUSION AND FUTURE WORK 7.1 Conclusion The research showed that a systematic exploration is possible for the representation of arbitrary objects (convex or nonconvex, with or without holes) by decoupling metric (numeric) and geometry considerations. The proposed solution separates the metric and geometric representation and uses the combination of big integers homogeneous coordinates for metric and convex polytopes for topological processing. The literature revealed that combination of big integers and convex polytopes was unexplored and the research showed that the combination is useful because it provides opportunity to investigate independently the metric operations and coordinate representations from representation of topology of the geometric objects. The advantage of metric calculations of big integers with homogeneous coordinates is that they are accurate for straight line structures, not approximates and all topological relations derived are consistent. Intersection points calculated are exactly on the line, not only very near, etc. The solution provides the geometric model AHD that has the following properties: ˆ ease of implementation ˆ support for operations ˆ level of detail support ˆ extendable to n-dimensions 109

133 Chapter 7 - CONCLUSION AND FUTURE WORK 110 The following questions were answered; Is the use of big integers practical? How slow are big integers? The question was investigated thoroughly in section 4.1. The experiment results showed that metric computations using homogeneous coordinates with big integers were conceptually simpler and easy to program. Also, the performance was acceptable for GIS geometry. The experiment results showed that; ˆ Solutions using big numbers are realistic for GIS. For applications including cascaded construction of geometric objects, the growth in the size of the big numbers representing the coordinates may be problematic. The average size doubles with each cascaded computation. Typical GIS operations do not construct long chains of intersections of lines defined as intersections of other lines. ˆ Contrary to the widespread belief, programming with big numbers was straightforward and easier than writing code using conventional Integer or Float data types. I showed that the performance penalty is relatively small and affects only the part of GIS operations computing metric relations for cascaded construction of points geometrically. As a summary, metric computations with big numbers lead to straightforward programs that are guaranteed to be consistent. The performance penalty seems bearable and the memory utilization can be controlled Is the combination of convex polytope and big integers attractive? I showed that the novel combination of big integers with convex polytopes is practical for the representation of GIS geometry that is guaranteed to be consistent. The solution advocated in 1986, namely, floating point arithmetic with simplicial complex [Frank and Kuhn, 1986] can be characterized as eager, leading to too many computations that are not necessarily meaningful. A similar approach [Thompson, 2007]uses regular polytopes (defined as union of convex polytopes), but half spaces are defined by finite precision representations. The proposed approach used convex polytopes in the dual space in which the coordinates of the point are homogeneous big integers.

134 Chapter 7 - CONCLUSION AND FUTURE WORK Does the model support Boolean operations? The model offers support for Boolean operations like intersection, union and symmetric difference etc. The convex decomposition and the hierarchical tree data structure facilitate the computations necessary for performing operations. Intersection is the only closed operation (as the intersection of two convex polytopes is always convex) and most important operation (other operations depend on it). The solution provided an algorithm for the computation of the intersection of two general polygons polygons (convex or nonconvex and with or without holes). The union of two convex polytopes is may be nonconvex. The principle of duality was to tackle the issue, taking the inverse of given polygons and intersecting them and then taking the inverse of result provided the union of the two polygons (i.e. A B = (A B)). The other operations, symmetric difference, point in a polygon and line intersections with a given point were then computed using the intersection and complement operations. Once the questions regarding the basic requirements were answered, I explored additional requirements the model fulfills; Support for level of detail Level of detail is an important concept in geometric and graphical description of objects. The hierarchical tree data structure of the proposed solution, AHD, provides support for geometric level of detail. I have argued that the use of convex polytopes as geometric primitives and the hierarchical data structure lead to algorithms which can be implemented as progressive algorithms. The LoD in AHD facilitates reduced number of computations. I concluded that LoD data structures and progressive evaluation are necessary for GIS and other information systems, where data are stored and requested from applications with very differing quality requirements. Progressive LoD evaluation can be achieved generally in programming languages with a lazy evaluation strategy, with the programmer only avoiding depth first recursive calls; this shows that the progressive concept can be separated from and dealt with independently of details of LoD. The analysis showed a further step of generalization, as it separates generic LoD data structure and operations from operations on primitives used to construct the approximations.

135 Chapter 7 - CONCLUSION AND FUTURE WORK 112 Dataset No Table 7.1: Description of the three test data sets Data Type No. of polygons No. of rings Total no of points 1 building footprints 2 cadastre cadastre (data source [Kui Liu et al., 2007]) Dimension independence Most of the current decomposition algorithms are dimension specific needing dimension specific implementations. The proposed approach AHD is dimension independent that is achieveable by lifting the AHD algebra for 2D to nd. For dimension independent AHD, the geometric primitive convex polytope is implemented as a n- convex polytope (convex polytope of any dimension) and the operations on the primitive are generalized. The most important geometric operation is the convex hull computation, for which any existing dimension independent convex hull algorithm can be used. In order to show the dimension independence, AHD is implemented by decomposing a polytope into a simplicial complex. The approach uses the dimension independent convex hull, called IncConvexHull algorithm and a lifted split function that extracts the deltas or notches Performance analysis Finally, to verify the proposed solution, I tested AHD with three real datasets having large number of vertexes. This proved useful for getting an objective insight into the strengths and weaknesses of the model. The description of the three datasets used is given in Table 7.1. In order to measure the intersection computation performance for AHD, the test dataset regions r1, r2 and and r3 are intersected against randomly drawn (clip) regions c1, c2 and c3 respectively as shown in Figure 7.1. The three intersection regions i1 (r1 c1), i2 (r2 c2) and i3 (r3 c3) are shown in Figure.

136 Chapter 7 - CONCLUSION AND FUTURE WORK 113 (a) Dataset1 region r1 and clip region c1 (b) Dataset2 region r2 and clip region c2 (c) Dataset3 region r3 and clip region c3 Figure 7.1: Test datasets and clip regions

137 Chapter 7 - CONCLUSION AND FUTURE WORK 114 (a) Intersection region i1 (r1 c1) (b) Intersection region i2 (r2 c2) (c) Intersection region i3 (r3 c3) Figure 7.2: Intersection regions

138 Chapter 7 - CONCLUSION AND FUTURE WORK 115 Table 7.2: Region statistics where r1, r2, and r3 are input regions: c1, c2 and c3 are the clip regions intersected with regions r1, r2, and r3 respectively: i1=(r1 c1), i2=(r2 c2) and i3 =(r3 c3) Dataset Region No. of Points No. of trees Max. no. of nodes Max. no. of levels r r r c c c i i i Table 7.3: Time for AHD and intersection computation Build time (bt) bt/point Eval time (et) et/point Int. time (it) it/point s 52.67µs 1.83s 37.26µs 8.37s µs s µs 1.11s 71.71µs 0.48s µs s 94.48µs 0.68s 69.33µs 4.22s µs Table 7.2 summarizes the region statistics for the test dataset, the clip and the intersection regions. Table shows the time elapsed in seconds for build and eval functions of AHD and the computation of intersection regions using a system having a dual core processor of 2 x 1 GHz and 2GiB RAM. From the results it is deduced that the performance for build, eval and intersection depends on the number of nodes and levels in the region trees or in other words on the shape of the region polygons. This is shown in Figure 7.3 where the build and eval times per point for the regions r1, r2 and r3 are plotted together with the maximum number of nodes in a tree. The same relationship is shown for time per point for intersection and the maximum number of nodes in a tree as shown in Figure All values are rounded to two decimal places for better presentation

139 Chapter 7 - CONCLUSION AND FUTURE WORK 116 Figure 7.3: Relationship between time per point (in µs) and max. no. of nodes for AHD operations build and eval Figure 7.4: Relationship between time per point (in µs) on logarithmic scale and max. no. of nodes for AHD intersection operation

140 Chapter 7 - CONCLUSION AND FUTURE WORK Future Work Support for non simple polygons AHD assumes the polygons are simple (without self intersecting edges) which could be problematic for some real datasets. The possible solution to the problem is introducing a preprocessing step in which a non simple polygon is splitd into two or more polygons depending on the shape. This is done by computation the intersection points of intersecting edges, updating the intersecting edges and then ultimately segregating the closed regions formed, so as to represent it with multiple simple polygons. The idea is to convert or decompose a non simple polygon with multiple simple polygons or use any established method to deal non simplicity first and then continue with proposed solution. Since AHD supports multiple polygons, the preprocessing will overcome the problem and would increase the usability and applicability of AHD for practical GIS Implemention of AHD in a database In some large scale applications it may be more efficient to have a separate geometric database to store large number of geometric objects [Günther, 1988a]. In future, the AHD will be implemented in three different database environments relational (e.g. mysql), object oriented (e.g. Oracle) and document-oriented (couchdb 2 ). This will need support of indices that are used to optimize spatial queries. Popular spatial indices are quadtree [Samet, 1984], R-tree [Guttman, 1984], R+tree [Sellis et al., 1987], cell tree[günther, 1988a] and B-tree [Bayer and McCreight, 1970] etc. The index should be implemented as a secondary storage data structure that facilitates efficient search queries AHD based geometric modeling of buildings A 3D city model may consist of many different objects needed to be modeled depending on the application domain. Some of the most important city objects are buildings, roads, streets, trees, etc. However, buildings are the most important part of a city model for many applications (Lancelle and Fellner, 2004). The approach for using AHD for the geometric modeling of buildings involves; the computation of the convex hull of the building 3D points which makes the root of the CHT. The concavities are extracted and the process is repeated for 2

141 Chapter 7 - CONCLUSION AND FUTURE WORK 118 Figure 7.5: AHD based geometric modeling of buildings each of the extracted nonconvex part, which are ultimately used to approximate extruding structures like chimneys, or surface structures like doors windows etc or sometimes just noise space. By noise space, I mean the space which is not part of the actual object space, but is part of the approximation space. Figure 7.5 shows an example for geometric modeling of buildings (in 2D) using AHD. For dem newtype Level = Level Int deriving (Eq, Ord, Show, Read, Num ) unlevel ( Level i) = i onstration purposes the input is a 2D point set representing a building in 2D (Figure 7.5a). The decomposed convex components and the corresponding CHT are shown in Figures 7.5b and 7.5c respectively. The convex hulls 1 and 2 represent noise space of the overall approximation space represented by the CHT. The application of AHD for geometric modeling of city objects seems attractive as an additional geometric model, however it needs further investigation. Some of the issues for future investigation are; ˆ Integration of ontological information into AHD ˆ Relating geometric and semantic levels of detail

142 Bibliography T. Ai, Z. Li, and Y. Liu. Progressive transmission of vector data based on changes accumulation model. Developments in Spatial Data Handling, pages 85 96, P. Alexandroff and PS Aleksandrov. Elementary concepts of topology. Dover Publications, O. El Badawy and M.S. Kamel. Hierarchical representation of 2-d shapes using convex polygons: a contour-based approach. Pattern Recognition Letters, 26 (7): , ISSN C.L. Bajaj and T.K. Dey. Convex decomposition of polyhedra and robustness. SIAM J. Comput., 21(2): , Dana H. Ballard. Strip trees: A hierarchical representation for curves. ACM Comm., 24(5 (May)): , C. Bradford Barber, David P. Dobkin, and Hannu Huhdanpaa. The quickhull algorithm for convex hulls. ACM Trans. Math. Softw., 22(4): , ISSN R. Bayer and E. McCreight. Organization and maintenance of large ordered indices. In Proceedings of the 1970 ACM SIGFIDET (now SIGMOD) Workshop on Data Description, Access and Control, SIGFIDET 70, pages , New York, NY, USA, ACM. J.L. Bentley and T.A. Ottmann. Algorithms for reporting and counting geometric intersections. IEEE Transactions on Computers, 28(9), Jules Bloomenthal and Jon Rokne. Homogeneous coordinates. The Visual Computer, 11:15 26, ISSN

143 Bibliography 120 M. Breunig. On the way to component-based 3D/4D geoinformation systems. Springer Verlag, C. Burnikel, R. Fleischer, K. Mehlhorn, and S. Schirra. Efficient exact geometric computation made easy. In Proceedings of the fifteenth annual symposium on Computational geometry, page 350. ACM, B. Chazelle. An optimal algorithm for intersecting three-dimensional convex polyhedra. Foundations of Computer Science, Annual IEEE Symposium on, 0: , B. Chazelle and DP Dobkin. Intersection of convex objects in two and three dimensions. Journal of the ACM (JACM), 34(1):1 27, B. Chazelle and H. Edelsbrunner. An optimal algorithm for intersecting line segments in the plane. Journal of the ACM (JACM), 39(1):1 54, B. Chazelle and L. Palios. Triangulating a nonconvex polytope. Discrete and computational geometry, 5(1): , N.R. Chrisman, J.A. Dougenik, and D. White. Lessons for the design of polygon overlay processing from the Odyssey Whirlpool algorithm. In Proc. 5th Int. Symp. on Spatial Data Handling, volume 2, pages , M. De Berg, O. Cheong, M. Van Kreveld, and M. Overmars. Computational geometry: algorithms and applications. Springer-Verlag New York Inc, L. De Floriani, P. Magillo, and E. Puppo. Applications of computational geometry to geographic information systems. Handbook of computational geometry, pages , M.J. De Smith, M.F. Goodchild, and P. Longley. Geospatial analysis: a comprehensive guide to principles, techniques and software tools. Troubador Publishing, second edition, Herbert Edelsbrunner and Ernst Peter Mücke. Simulation of simplicity: a technique to cope with degenerate cases in geometric algorithms. ACM Trans. Graph., 9(1):66 104, ISSN M. Egenhofer, A. Frank, and J. Jackson. A topological data model for spatial databases. Design and Implementation of Large Spatial Databases, pages , 1990.

144 Bibliography 121 F. R. Feito and M. Rivero. Geometric modelling based on simplicial chains. Computers & Graphics, 22(5): , ISSN J. Fernandez, L. Canovas, and B. Pelegrin. Algorithms for the decomposition of a polygon into convex polygons. European Journal of Operational Research, 121(2): , ISSN E. Fogel, R. Wein, B. Zukerman, and D. Halperin. 2D Regularized Boolean Set- Operations. CGAL Editorial Board, CGAL-3.2 user and reference manual edition, S. Fortune. Stable maintenance of point set triangulations in two dimensions. In Proceedings of the 30th Annual Symposium on Foundations of Computer Science, pages IEEE Computer Society, S. Fortune. Polyhedral modelling with exact arithmetic. In Proceedings of the third ACM symposium on Solid modeling and applications, pages ACM, Steven Fortune and Christopher J. Van Wyk. Static analysis yields efficient exact integer arithmetic for computational geometry. ACM Trans. Graph., 15 (3): , ISSN A. U. Frank and W. Kuhn. Cell graphs: A provable correct method for the storage of geometry. In D. Marble, editor, Second International Symposium on Spatial Data Handling, pages , Seattle, Wash., Andrew U. Frank. Spatial concepts, geometric data models, and geometric data structures. Computers & Geosciences, 18(4): , ISSN W.R. Franklin. Cartographic errors symptomatic of underlying algebra problems. In Proc. First Intl. Symposium on Spatial Data Handling, Z urich, volume 1, pages , August Christine Goldenhuber. Aufdeckung von Numerischen Problemen in geodätischer Software, volume 11 of Geoinfo Series. Institute for Geoinformation, Daniel H. Greene and F. Frances Yao. Finite-resolution computational geometry. In Foundations of Computer Science, 1986., 27th Annual Symposium on, pages , 1986.

145 Bibliography 122 Gunther Greiner and Kai Hormann. Efficient clipping of arbitrary polygons. ACM Trans. Graph., 17(2):71 83, ISSN L. Guibas, L. Ramshaw, and J. Stolfi. A kinetic framework for computational geometry. In Foundations of Computer Science, 1983., 24th Annual Symposium on, pages , O. Günther. Efficient Structures for Geometric Data Management, volume 337 of Lecture Notes in Computer Science. Springer Verlag, 1988a. O. Günther. A dual approach to detect polyhedral intersections in arbitrary dimensions. In Oliver Günther, editor, Efficient Structures for Geometric Data Management, volume 337 of Lecture Notes in Computer Science, pages Springer Berlin / Heidelberg, 1988b. O. Günther and E. Wong. Convex polyhedral chains: A representation for geometric data. Computer-aided Design, Butterworth & Co., 21(3): , copy. Ralf Güting and Markus Schneider. Realms: A foundation for spatial data types in database systems. In David Abel and Beng Chin Ooi, editors, Advances in Spatial Databases, volume 692 of Lecture Notes in Computer Science, pages Springer Berlin / Heidelberg, R.H. Güting and M. Schneider. Realm-based spatial data types: the ROSE algebra. The VLDB Journal, 4(2): , Antonin Guttman. R-trees: A dynamic index structure for spatial searching. In Proceedings of the 1984 ACM SIGMOD international conference on Management of data, SIGMOD 84, pages 47 57, New York, NY, USA, ACM. ISBN I. Hanniel and R. Wein. An exact, complete and efficient computation of arrangements of Bézier curves. In Proceedings of the 2007 ACM symposium on Solid and physical modeling, page 263. ACM, John Herring. TIGRIS: A data model for an object-oriented geographic information system. Computers and Geosciences, 18: , Christoph M. Hoffmann. The problems of accuracy and robustness in geometric computation. Computer, 22(3):31 40, ISSN

146 Bibliography 123 Christoph M. Hoffmann. Robustness in geometric computations. Journal of Computing and Information Science in Engineering, 1(2): , C.M. Hoffmann, J.E. Hopcroft, and M.S. Karasick. Towards implementing robust geometric computations. In Proceedings of the fourth annual symposium on Computational geometry, page 117. ACM, C.M. Hoffmann, J.E. Hopcroft, and M.J. Karasick. Robust set operations on polyhedral solids. Computer Graphics and Applications, IEEE, 9(6):50 59, nov ISSN P. Hudak, S. L. Peyton Jones, P. L. Wadler, Arvind, B. Boutel, J. Fairbarn, J. Fasel, M. Guzman, K. Hammond, J. Hughes, T. Johnson, R. Kieburtz, R. S. Nikhil, W. Partain, and J. Peterson. Report on the functional programming language Haskell, version 1.2. ACM SIGPLAN Notices, 27(5):1 164, Annie Hui, Lucas Vaczlavik, and Leila De Floriani. A decomposition-based representation for 3D simplicial complexes. In SGP 06: Proceedings of the fourth Eurographics symposium on Geometry processing, pages , Aire-la-Ville, Switzerland, Switzerland, Eurographics Association. ISBN S.P. Jones and S.L.P. Jones. Haskell 98 language and libraries: the revised report. Cambridge Univ Pr, Michael Karasick, Derek Lieber, and Lee R. Nackman. Efficient delaunay triangulation using rational arithmetic. ACM Trans. Graph., 10(1):71 91, ISSN Farid Karimipour, Andrew U. Frank, and Mahmoud R. Delavar. An operationindependent approach to extend 2D spatial operations to 3D and moving objects. Proceedings of the 16th ACM SIGSPATIAL International Conference on Advances in Geographic Information Systems (ACM GIS 2008), pages The Association for Computing Machinery, Inc., R. Karinthi, K. Srinivas, and G. Almasi. A parallel algorithm for computing polygon set operations. pages IEEE, apr J.M. Keil. Polygon decomposition. Handbook of Computational Geometry, pages , 2000.

147 Bibliography 124 L. Kettner, K. Mehlhorn, S. Pion, S. Schirra, and C. Yap. Classroom examples of robustness problems in geometric computations. Computational Geometry, 40(1):61 78, D.E. Knuth. Axioms and hulls. Springer, H.P. Kriegel, H. Horn, and M. Schiwietz. The performance of object decomposition techniques for spatial query processing. In Advances in Spatial Databases, pages Springer, Y. Kui Liu, X. Qiang Wang, S. Zhe Bao, M. Gombosi, and B. Zalik. An algorithm for polygon clipping, and for determining polygon intersections and unions. Computers & geosciences, 33(5): , U. Lauther. An O (n log n) algorithm for Boolean mask operations. In Proceedings of the 18th Design Automation Conference, pages IEEE Press, C. Li, S. Pion, and C.K. Yap. Recent progress in exact geometric computation. Journal of Logic and Algebraic Programming, 64(1):85 111, ISSN Jyh-Ming Lien and Nancy M. Amato. Approximate convex decomposition. In SCG 04: Proceedings of the twentieth annual symposium on Computational geometry, pages , New York, NY, USA, ACM. ISBN Jyh-Ming Lien and Nancy M. Amato. Approximate convex decomposition of polygons. Computational Geometry, 35(1-2): , ISSN Rong Liu, Hao Zhang, and James Busby. Convex hull covering of polygonal scenes for accurate collision detection in games. In GI 08: Proceedings of graphics interface 2008, pages , Toronto, Ont., Canada, Canada, Canadian Information Processing Society. ISBN A. Margalit and G.D. Knott. An algorithm for computing the union, intersection or difference of two polygons. Computers & Graphics, 13(2): , F. Martínez, A.J. Rueda, and F.R. Feito. A new algorithm for computing Boolean operations on polygons. Computers & Geosciences, 35(6): , 2009.

148 Bibliography 125 Kurt Mehlhorn and Stefan Naher. LEDA: A platform for combinatorial and geometric computing. Cambridge University Press, Cambridge, V.J. Milenkovic. Practical methods for set operations on polygons using exact arithmetic. In Proc. 7th Canad. Conf. Comput. Geom, pages Citeseer, David M. Mount. Geometric intersection. In Handbook of Discrete and Computational Geometry, chapter 33, pages CRC Press LLC, Boca, J. Nievergelt and F. P. Preparata. Plane-sweep algorithms for intersecting geometric figures. Commun. ACM, 25(10): , ISSN Joseph O Rourke. Computational geometry in C (2nd ed.). Cambridge University Press, New York, NY, USA, ISBN Joseph O Rourke, Chi-Bin Chien, Thomas Olson, and David Naddor. A new linear algorithm for intersecting convex polygons. Computer Graphics and Image Processing, 19(4): , ISSN X. Leonidas Palios. Decomposition Problems in Computational Geometry. PhD thesis, Department of Computer Sceinces, Princeton University, April A. Paoluzzi, F. Bernardini, C. Cattani, and V. Ferrucci. Dimension-independent modeling with simplicial complexes. ACM Trans. Graph., 12(1):56 102, ISSN Yu Peng, Jun-Hai Yong, Wei-Ming Dong, Hui Zhang, and Jia-Guang Sun. A new algorithm for boolean operations on general polygons. Computers & Graphics, 29(1):57 70, ISSN Frisco Penninga. 3D Topography: Simplicial Complex-based Solution in a Spatial DBMS. PhD thesis, The research and development center for Geo-Information technology of Delft University of Technology, Ken Perlin and Luiz Velho. textures Live paint: Painting with procedural multiscale Eric Persoon and King-Sun Fu. Shape discrimination using fourier descriptors. Systems, Man and Cybernetics, IEEE Transactions on, 7(3): , ISSN

149 Bibliography 126 Ari Rappoport. The n-dimensional extended convex differences tree (ECDT) for representing polyhedra. In SMA 91: Proceedings of the first ACM symposium on Solid modeling foundations and CAD/CAM applications, pages , New York, NY, USA, ACM. ISBN P. Rigaux, M.O. Scholl, and A. Voisard. Introduction to spatial databases: with application to GIS. Morgan Kaufmann Inc., M. Rivero and F. R. Feito. Boolean operations on general planar polygons. Computers & Graphics, 24(6): , ISSN A. Sabau. Signedintersection-A new algorithm for finding the intersection of two simple polygons. INFORMATICA, page 83, D. Salesin, J Stolfi, and L. Guibas. Epsilon geometry: building robust algorithms from imprecise computations. In SCG 89: Proceedings of the fifth annual symposium on Computational geometry, pages , New York, NY, USA, ACM. ISBN H. Samet. The quadtree and related hierarchical data structures. ACM Computing Surveys, 16(2): , Hanan Samet. Foundations of Multidimensional and Metric Data Structures. Morgan Kaufmann, B. Schachter. Decomposition of polygons into convex sets. IEEE Transactions on Computers, 100(27): , S. Schirra. Robustness and precision issues in geometric computation. Max Planck Institut Fur InformatiK-Report-MPI I, Markus Schneider. Spatial data types - A survey. In Markus Schneider, editor, Spatial Data Types for Database Systems, volume 1288 of Lecture Notes in Computer Science, pages Springer Berlin / Heidelberg, 1997a. Markus Schneider. Introduction. In Markus Schneider, editor, Spatial Data Types for Database Systems, volume 1288 of Lecture Notes in Computer Science, pages 1 9. Springer Berlin / Heidelberg, 1997b. Markus Schneider. Spatial data types: Conceptual foundation for the design and implementation of spatial database systems and gis. Online Tutorial, 2002.

150 Bibliography 127 Martijn M. Schrage, Arjan van IJzendoorn, and Linda C. van der Gaag. Haskell ready to dazzle the real world. In Proceedings of the 2005 ACM SIGPLAN workshop on Haskell, Haskell 05, pages 17 26, New York, NY, USA, ACM. ISBN X. Rafael J. Segura and Francisco R. Feito. An algorithm for determining intersection segment-polygon in 3d. Computers & Graphics, 22(5): , ISSN Timos K. Sellis, Nick Roussopoulos, and Christos Faloutsos. The R+-Tree: A dynamic index for multi-dimensional objects. In Proceedings of the 13th International Conference on Very Large Data Bases, VLDB 87, pages , San Francisco, CA, USA, Morgan Kaufmann Publishers Inc. ISBN X. Michael Ian Shamos and Dan Hoey. Geometric intersection problems. In SFCS 76: Proceedings of the 17th Annual Symposium on Foundations of Computer Science, pages , Washington, DC, USA, IEEE Computer Society. J. R. Shewchuk. Lecture notes on geometric robustness, November J.M. Smith and N.A. Dodgson. A topologically robust algorithm for boolean operations on polyhedral shapes using approximate arithmetic. Computer- Aided Design, 39(2): , ISSN Julian M. Smith. Towards robust inexact geometric computation. PhD thesis, Computar Laboratory, University of Cambridge, St. Edmunds College, December W.C. Thibault and B.F. Naylor. Set operations on polyhedra using binary space partitioning trees. In Proceedings of the 14th annual conference on Computer graphics and interactive techniques, pages ACM, Rodney James Thompson. Towards a Rigorous Logic for Spatial Data Representation. PhD thesis, The research and development center for Geo-Information technology of Delft University of Technology, Godfried Toussaint. A simple linear algorithm for intersecting convex polygons. The Visual Computer, 1: , ISSN

151 Bibliography 128 Peter van Oosterom and Jantien Stoter. 5D data modelling: Full integration of 2D/3D space, time and scale dimensions. In Sara Fabrikant, Tumasch Reichenbacher, Marc van Kreveld, and Christoph Schlieder, editors, Geographic Information Science, volume 6292 of Lecture Notes in Computer Science, pages Springer Berlin / Heidelberg, Bala R. Vatti. A generic solution to polygon clipping. Commun. ACM, 35(7): 56 63, ISSN K. Weiler and P. Atherton. Hidden surface removal using polygon area sorting. In Proceedings of the 4th annual conference on Computer graphics and interactive techniques, pages ACM, Jianning Xu. Morphological decomposition of 2-D binary shapes into modestly overlapped octagonal and disk components. IEEE Transactions on Image Processing, 16(2): , Chee K. Yap. Robust geometric computation. pages , Charles T. Zahn and Ralph Z. Roskies. Fourier descriptors for plane closed curves. Computers, IEEE Transactions on, C-21(3): , ISSN

152 Appendix A A Brief Introduction to Haskell Haskell is a general purpose, purely functional programming language. A functional program is a single expression, which is executed by evaluating the expression. Functional programs consist entirely of functions. Each function takes a number of input types and returns a single output type. Constants are functions, which always return the same value. Even the program itself is a function. Because a function call can have no other effect than producing a result, functional programs are said to have no side effects. Haskell provides higher-order functions, non-strict semantics, static polymorphic typing, user-defined algebraic datatypes, pattern-matching, list comprehensions, a module system, a monadic I/O system, and a rich set of primitive datatypes, including lists, arrays, arbitrary and fixed precision integers, and floating-point numbers. Haskell has an innovative type system which supports a systematic form of overloading and a module system. Modules provide a way to control namespaces and to re-use software in large programs. An expression evaluates to a value and has a static type. Values and types are not mixed in Haskell. However, the type system allows user-defined datatypes of various sorts, and permits not only parametric polymorphism (using a traditional Hindley-Milner type structure) but also adhoc polymorphism, or overloading (using type classes). More information about Haskell can be found in [Jones and Jones, 2003]. 129

153 Appendix A - A Brief Introduction to Haskell 130 A.1 High Order Functions-Functors A functional or high order function is a function whose arguments are functions or whose result is a function. The map function illustrates how a high order function works. For example, map which is a higher order function (Functor) defined as [Jones and Jones, 2003]; class Functor f where fmap :: (a -> b) -> f a -> f b instance Functor [] where fmap = map map is an instance of Functor typeclass which represents types which can be mapped over. It defines only one function fmap whose arguments are a function from one type to another type and a functor applied to one type and returns a functor applied with another type. This becomes clear if we look at the type signature of map map : : ( a > b ) > [ a ] > [ b ] which is an instance of Functor class with f being [] (a list type constructor), so map is a Functor over lists. It takes a function from one type to another type and a list of one type and returns a list of another type. The example below shows the working of map; Prelude> map (+2) [ 1, 7, 18, 29] [3,9,20, 27] High order functions distinguish functional programming from other programming languages. The partial application of functions and the possibility to define functions of functions permit abstract specifications. As a result generic code can be written that is modular and highly reusable. A.2 Haskell Types Haskell s static type system defines the formal relationship between types and values. The static type system ensures that Haskell programs are type safe, All type errors are detected at compile-time. The type system also ensures that user-supplied type signatures are correct.

154 Appendix A - A Brief Introduction to Haskell 131 A.2.1 Generic data types Haskell provides a way to define type synonyms; i.e. names for commonly used types. Type synonyms are created using a type declaration. Some examples are shown below. type Point = ( Int, Int ) type String = [ Char ] type Person = ( Name, Address ) In Haskell, the newtype declaration creates a new type from an existing one. For example, natural numbers can be represented by the type Integer using the following declaration (refer gentle introduction). For example, AHD level is represented by the type Int as shown below, newtype Level = Level Int A.2.2 Algebraic data types Algebraic data type is a datatype each of whose values is data from other datatypes wrapped in one of the constructors of the datatype. Any wrapped datum is an argument to the constructor. In contrast to other datatypes, the constructor is not executed and the only way to operate on the data is to unwrap the constructor using pattern matching. For example, the tree data structure of AHD is defined as an algebraic data type; data Tree p = Node { _this :: p, _childtrees :: [ Tree p ], _level :: Level } LeafNode { _this :: p, _level :: Level } UniNode { _this :: p, _childtrees :: [ Tree p ], _level :: Level } NullTree {} Here, the Tree is a type type constructor, p is a type variable, Node, LeafNode, UniNode, and NullTree are data constructors. A.3 Classes in Haskell Classes are a specific feature of the Haskell programming language. A class in Haskell is a collection of types that support certain overloaded operations called

155 Appendix A - A Brief Introduction to Haskell 132 methods. shown in Figure A.1. Haskell provides a number classes that are built-in to the language Eq / \ / \ Ord \ Text / \ \ / / \ \ / / Enum Num / \ / \ Ix \ / \ \ Real Fractional \ / \ / \ \ / \ / \ Integral RealFrac Floating \ / \ / RealFloat Figure A.1: Hierarchy of Haskell classes On the top of the hierarchy there is the class Eq. It defines the collection of types with which the equality of two elements can be tested. The class declaration of Eq is given below. It consists of a class Name followed by a signature. The signature is a list of names and their types. The equality operation (==) takes two types and returns a Boolean value. class Eq a where (==) :: a -> a -> Bool In order to make an arbitrary type a member of the class Eq an implementation has to be provided. Members of a type class are called instances. Haskell defines instances for Int, Float, Bool and Char for Eq. Furthermore a default implementation for the class Eq is given that can be overwritten with a new implementation. The equality between two different types may differ. The equality of two natural numbers may be implemented by simply comparing their values, while the equality of two strings may be based on comparing the length of the two strings. Different instances may be defined. The appropriate implementation will be overloaded for the corresponding type. This way type classes implement

156 Appendix A - A Brief Introduction to Haskell 133 the ad-hoc polymorphism mentioned earlier. instance Eq Int where (==) a b = a == b instance Eq String where (==) a b = length a == length b For example here is the declaration for the type class Points; data Po i nt = P o int Float Float class Points p where getx : : p > Float gety : : p > Float instance Points Point where getx ( Point x y ) = x gety ( Point x y ) = y The first line declares the name of the class, and constraints on what types can be instances of this class. Then is the list of type declarations of the class functions that must be implemented in order to be an instance of the class. Haskell also offers a mechanism of inheritance, similar to object oriented programming languages. The class Ord can be derived from the class Eq. Ord defines the class of ordered types. The class Ord defines the operations to compare types like <, <=, >, >=. The definition of equality, defined by the == operator is inherited of the class Eq. class Eq a => Ord a where (<),(<=),(>),(>=) :: a -> a -> Bool... In the sample code above the => operator indicates that Ord is derived from Eq. The operator => refers to the context of a class. In the example that means for any type a that is declared and implemented belonging to Ord there has to be also a declaration and implementation belonging to Eq.

157

158 Appendix B Prototype Application The prototype application for AHD is developed in Haskell using leksah 1, an open source Haskell IDE, that uses Glasgow Haskell Compiler (ghc) and Gtk. The GUI is developed in Glade 2 (RAD tool for quick and easy development of user interfaces) using the gtk2hs 3 binding for Haskell. A screen-shot of the AHD prototype GUI is shown in Figure B.1 and Table B.1 describes different parts of the application GUI. Table B.1: Description of AHD prototype GUI 1 Select the region to draw 2 Drawing area where the region polygons are drawn 3 Here the text view of the application status and region statistics are provided 4 Set width of the region edges 5 Set color for the region 6 Checkbox for directed or undirected edges 7 File selection or browser button to load data from files 8 Saving regions for further processing 9 Button provides the AHD build function 10 Specify level of detail for build 11 Button provides the AHD eval function 12 Specify level of detail for eval 13 Buttons to perform operations on the two regions represented by AHD 14 Buttons for zooming operations

159 Figure B.1: Screen-shot of AHD prototype

AHD: The Alternate Hierarchical Decomposition of Nonconvex Polytopes (Generalization of a Convex Polytope Based Spatial Data Model)

AHD: The Alternate Hierarchical Decomposition of Nonconvex Polytopes (Generalization of a Convex Polytope Based Spatial Data Model) AHD: The Alternate Hierarchical Decomposition of Nonconvex Polytopes (Generalization of a Convex Polytope Based Spatial Data Model) Rizwan Bulbul Institute of Geoinformation and Cartography Technical University

More information

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

A Simplex based Dimension Independent Approach for Convex Decomposition of Nonconvex polytopes A Simplex based Dimension Independent Approach for Convex Decomposition of Nonconvex polytopes Rizwan Bulbul, Farid Karimipour and Andrew U. Frank Institute of Geoinformation and Cartography Technical

More information

Implementing Geometric Algorithms. Wouter van Toll June 20, 2017

Implementing Geometric Algorithms. Wouter van Toll June 20, 2017 Implementing Geometric Algorithms Wouter van Toll June 20, 2017 Introduction 6/20/2017 Lecture: Implementing Geometric Algorithms 2 Focus of this course Create algorithms to solve geometric problems Prove

More information

CSG obj. oper3. obj1 obj2 obj3. obj5. obj4

CSG obj. oper3. obj1 obj2 obj3. obj5. obj4 Solid Modeling Solid: Boundary + Interior Volume occupied by geometry Solid representation schemes Constructive Solid Geometry (CSG) Boundary representations (B-reps) Space-partition representations Operations

More information

Finite-Resolution Simplicial Complexes

Finite-Resolution Simplicial Complexes 1 Finite-Resolution Simplicial Complexes Werner Hölbling, Werner Kuhn, Andrew U. Frank Department of Geoinformation Technical University Vienna Gusshausstrasse 27-29, A-1040 Vienna (Austria) frank@geoinfo.tuwien.ac.at

More information

Geometric and Solid Modeling. Problems

Geometric and Solid Modeling. Problems Geometric and Solid Modeling Problems Define a Solid Define Representation Schemes Devise Data Structures Construct Solids Page 1 Mathematical Models Points Curves Surfaces Solids A shape is a set of Points

More information

Outline. CGAL par l exemplel. Current Partners. The CGAL Project.

Outline. CGAL par l exemplel. Current Partners. The CGAL Project. CGAL par l exemplel Computational Geometry Algorithms Library Raphaëlle Chaine Journées Informatique et GéomG ométrie 1 er Juin 2006 - LIRIS Lyon Outline Overview Strengths Design Structure Kernel Convex

More information

L1 - Introduction. Contents. Introduction of CAD/CAM system Components of CAD/CAM systems Basic concepts of graphics programming

L1 - Introduction. Contents. Introduction of CAD/CAM system Components of CAD/CAM systems Basic concepts of graphics programming L1 - Introduction Contents Introduction of CAD/CAM system Components of CAD/CAM systems Basic concepts of graphics programming 1 Definitions Computer-Aided Design (CAD) The technology concerned with the

More information

Solid Modelling. Graphics Systems / Computer Graphics and Interfaces COLLEGE OF ENGINEERING UNIVERSITY OF PORTO

Solid Modelling. Graphics Systems / Computer Graphics and Interfaces COLLEGE OF ENGINEERING UNIVERSITY OF PORTO Solid Modelling Graphics Systems / Computer Graphics and Interfaces 1 Solid Modelling In 2D, one set 2D line segments or curves does not necessarily form a closed area. In 3D, a collection of surfaces

More information

GEOMETRIC TOOLS FOR COMPUTER GRAPHICS

GEOMETRIC TOOLS FOR COMPUTER GRAPHICS GEOMETRIC TOOLS FOR COMPUTER GRAPHICS PHILIP J. SCHNEIDER DAVID H. EBERLY MORGAN KAUFMANN PUBLISHERS A N I M P R I N T O F E L S E V I E R S C I E N C E A M S T E R D A M B O S T O N L O N D O N N E W

More information

Lecture 17: Solid Modeling.... a cubit on the one side, and a cubit on the other side Exodus 26:13

Lecture 17: Solid Modeling.... a cubit on the one side, and a cubit on the other side Exodus 26:13 Lecture 17: Solid Modeling... a cubit on the one side, and a cubit on the other side Exodus 26:13 Who is on the LORD's side? Exodus 32:26 1. Solid Representations A solid is a 3-dimensional shape with

More information

Spatial Data Structures

Spatial Data Structures 15-462 Computer Graphics I Lecture 17 Spatial Data Structures Hierarchical Bounding Volumes Regular Grids Octrees BSP Trees Constructive Solid Geometry (CSG) March 28, 2002 [Angel 8.9] Frank Pfenning Carnegie

More information

9. Three Dimensional Object Representations

9. Three Dimensional Object Representations 9. Three Dimensional Object Representations Methods: Polygon and Quadric surfaces: For simple Euclidean objects Spline surfaces and construction: For curved surfaces Procedural methods: Eg. Fractals, Particle

More information

Geometric Modeling Mortenson Chapter 11. Complex Model Construction

Geometric Modeling Mortenson Chapter 11. Complex Model Construction Geometric Modeling 91.580.201 Mortenson Chapter 11 Complex Model Construction Topics Topology of Models Connectivity and other intrinsic properties Graph-Based Models Emphasize topological structure Boolean

More information

Tools, Generic Programming, CGAL, and 2D Arrangement of CGAL

Tools, Generic Programming, CGAL, and 2D Arrangement of CGAL Tools, Generic Programming, CGAL, and 2D Arrangement of CGAL Efi Fogel efif@post.tau.ac.il School of computer science, Tel Aviv University Spring 2004 Motion Planning workshop 1/23 Tools, Toolkits, and

More information

Spatial Data Structures

Spatial Data Structures Spatial Data Structures Hierarchical Bounding Volumes Regular Grids Octrees BSP Trees Constructive Solid Geometry (CSG) [Angel 9.10] Outline Ray tracing review what rays matter? Ray tracing speedup faster

More information

Spatial Data Structures

Spatial Data Structures 15-462 Computer Graphics I Lecture 17 Spatial Data Structures Hierarchical Bounding Volumes Regular Grids Octrees BSP Trees Constructive Solid Geometry (CSG) April 1, 2003 [Angel 9.10] Frank Pfenning Carnegie

More information

Chapter 12 Solid Modeling. Disadvantages of wireframe representations

Chapter 12 Solid Modeling. Disadvantages of wireframe representations Chapter 12 Solid Modeling Wireframe, surface, solid modeling Solid modeling gives a complete and unambiguous definition of an object, describing not only the shape of the boundaries but also the object

More information

Geometric Modeling. Introduction

Geometric Modeling. Introduction Geometric Modeling Introduction Geometric modeling is as important to CAD as governing equilibrium equations to classical engineering fields as mechanics and thermal fluids. intelligent decision on the

More information

Computational Geometry

Computational Geometry Lecture 1: Introduction and convex hulls Geometry: points, lines,... Geometric objects Geometric relations Combinatorial complexity Computational geometry Plane (two-dimensional), R 2 Space (three-dimensional),

More information

Lecture notes: Object modeling

Lecture notes: Object modeling Lecture notes: Object modeling One of the classic problems in computer vision is to construct a model of an object from an image of the object. An object model has the following general principles: Compact

More information

A Point in Non-Convex Polygon Location Problem Using the Polar Space Subdivision in E 2

A Point in Non-Convex Polygon Location Problem Using the Polar Space Subdivision in E 2 A Point in Non-Convex Polygon Location Problem Using the Polar Space Subdivision in E 2 Vaclav Skala 1, Michal Smolik 1 1 Faculty of Applied Sciences, University of West Bohemia, Univerzitni 8, CZ 30614

More information

Big Mathematical Ideas and Understandings

Big Mathematical Ideas and Understandings Big Mathematical Ideas and Understandings A Big Idea is a statement of an idea that is central to the learning of mathematics, one that links numerous mathematical understandings into a coherent whole.

More information

APPLIED aspects of COMPUTATIONAL GEOMETRY. Dan Halperin School of Computer Science Tel Aviv University

APPLIED aspects of COMPUTATIONAL GEOMETRY. Dan Halperin School of Computer Science Tel Aviv University APPLIED aspects of COMPUTATIONAL GEOMETRY Introduction Dan Halperin School of Computer Science Tel Aviv University Lesson overview Background The main topics Course mechanics Additional topics 2 Background

More information

THE ASP: A CONTINUOUS, VIEWER-CENTERED OBJECT REPRESENTATION FOR COMPUTER VISION

THE ASP: A CONTINUOUS, VIEWER-CENTERED OBJECT REPRESENTATION FOR COMPUTER VISION THE ASP: A CONTINUOUS, VIEWER-CENTERED OBJECT REPRESENTATION FOR COMPUTER VISION William Harry Plantinga Under the supervision of Associate Professor Charles R. Dyer In this thesis a new continuous, viewer-centered

More information

Lecture 1: September 6, 2001

Lecture 1: September 6, 2001 Lecture 1: September 6, 2001 Welcome to 6.838J, Geometric Computation! Introductions Overview and Goals General Information Syllabus 2D Convex Hull Signup sheets (return by end of class) MIT 6.838J/4.214J

More information

Constructive Solid Geometry and Procedural Modeling. Stelian Coros

Constructive Solid Geometry and Procedural Modeling. Stelian Coros Constructive Solid Geometry and Procedural Modeling Stelian Coros Somewhat unrelated Schedule for presentations February 3 5 10 12 17 19 24 26 March 3 5 10 12 17 19 24 26 30 April 2 7 9 14 16 21 23 28

More information

Flavor of Computational Geometry. Convex Hull in 2D. Shireen Y. Elhabian Aly A. Farag University of Louisville

Flavor of Computational Geometry. Convex Hull in 2D. Shireen Y. Elhabian Aly A. Farag University of Louisville Flavor of Computational Geometry Convex Hull in 2D Shireen Y. Elhabian Aly A. Farag University of Louisville February 2010 Agenda Introduction Definitions of Convexity and Convex Hulls Naïve Algorithms

More information

Computer Graphics Prof. Sukhendu Das Dept. of Computer Science and Engineering Indian Institute of Technology, Madras Lecture - 24 Solid Modelling

Computer Graphics Prof. Sukhendu Das Dept. of Computer Science and Engineering Indian Institute of Technology, Madras Lecture - 24 Solid Modelling Computer Graphics Prof. Sukhendu Das Dept. of Computer Science and Engineering Indian Institute of Technology, Madras Lecture - 24 Solid Modelling Welcome to the lectures on computer graphics. We have

More information

Surface Mesh Generation

Surface Mesh Generation Surface Mesh Generation J.-F. Remacle Université catholique de Louvain September 22, 2011 0 3D Model For the description of the mesh generation process, let us consider the CAD model of a propeller presented

More information

Practical Linear Algebra: A Geometry Toolbox

Practical Linear Algebra: A Geometry Toolbox Practical Linear Algebra: A Geometry Toolbox Third edition Chapter 18: Putting Lines Together: Polylines and Polygons Gerald Farin & Dianne Hansford CRC Press, Taylor & Francis Group, An A K Peters Book

More information

Computer Aided Engineering Design Prof. Anupam Saxena Department of Mechanical Engineering Indian Institute of Technology, Kanpur.

Computer Aided Engineering Design Prof. Anupam Saxena Department of Mechanical Engineering Indian Institute of Technology, Kanpur. (Refer Slide Time: 00:28) Computer Aided Engineering Design Prof. Anupam Saxena Department of Mechanical Engineering Indian Institute of Technology, Kanpur Lecture - 6 Hello, this is lecture number 6 of

More information

Advanced 3D-Data Structures

Advanced 3D-Data Structures Advanced 3D-Data Structures Eduard Gröller, Martin Haidacher Institute of Computer Graphics and Algorithms Vienna University of Technology Motivation For different data sources and applications different

More information

Digital Image Processing Fundamentals

Digital Image Processing Fundamentals Ioannis Pitas Digital Image Processing Fundamentals Chapter 7 Shape Description Answers to the Chapter Questions Thessaloniki 1998 Chapter 7: Shape description 7.1 Introduction 1. Why is invariance to

More information

LASER ADDITIVE MANUFACTURING PROCESS PLANNING AND AUTOMATION

LASER ADDITIVE MANUFACTURING PROCESS PLANNING AND AUTOMATION LASER ADDITIVE MANUFACTURING PROCESS PLANNING AND AUTOMATION Jun Zhang, Jianzhong Ruan, Frank Liou Department of Mechanical and Aerospace Engineering and Engineering Mechanics Intelligent Systems Center

More information

Visibility: Finding the Staircase Kernel in Orthogonal Polygons

Visibility: Finding the Staircase Kernel in Orthogonal Polygons Visibility: Finding the Staircase Kernel in Orthogonal Polygons 8 Visibility: Finding the Staircase Kernel in Orthogonal Polygons Tzvetalin S. Vassilev, Nipissing University, Canada Stefan Pape, Nipissing

More information

A Flavor of Topology. Shireen Elhabian and Aly A. Farag University of Louisville January 2010

A Flavor of Topology. Shireen Elhabian and Aly A. Farag University of Louisville January 2010 A Flavor of Topology Shireen Elhabian and Aly A. Farag University of Louisville January 2010 In 1670 s I believe that we need another analysis properly geometric or linear, which treats place directly

More information

66 III Complexes. R p (r) }.

66 III Complexes. R p (r) }. 66 III Complexes III.4 Alpha Complexes In this section, we use a radius constraint to introduce a family of subcomplexes of the Delaunay complex. These complexes are similar to the Čech complexes but differ

More information

Figure 2.1: An example of a convex set and a nonconvex one.

Figure 2.1: An example of a convex set and a nonconvex one. Convex Hulls 2.1 Definitions 2 Convexity is the key to understanding and simplifying geometry, and the convex hull plays a role in geometry akin to the sorted order for a collection of numbers. So what

More information

The goal is the definition of points with numbers and primitives with equations or functions. The definition of points with numbers requires a

The goal is the definition of points with numbers and primitives with equations or functions. The definition of points with numbers requires a The goal is the definition of points with numbers and primitives with equations or functions. The definition of points with numbers requires a coordinate system and then the measuring of the point with

More information

SOME 024: Computer Aided Design. E. Rozos

SOME 024: Computer Aided Design. E. Rozos SOME 024: Computer Aided Design E. Rozos Introduction to CAD theory part 2 Lesson structure Why Solid modelling Solid modelling methods Representation based Manufacturing based Solid modelling storage

More information

Multidimensional Data and Modelling

Multidimensional Data and Modelling Multidimensional Data and Modelling 1 Problems of multidimensional data structures l multidimensional (md-data or spatial) data and their implementation of operations between objects (spatial data practically

More information

VALLIAMMAI ENGINEERING COLLEGE

VALLIAMMAI ENGINEERING COLLEGE VALLIAMMAI ENGINEERING COLLEGE SRM Nagar, Kattankulathur 603 203 DEPARTMENT OF MECHANICAL ENGINEERING QUESTION BANK M.E: CAD/CAM I SEMESTER ED5151 COMPUTER APPLICATIONS IN DESIGN Regulation 2017 Academic

More information

ECE276B: Planning & Learning in Robotics Lecture 5: Configuration Space

ECE276B: Planning & Learning in Robotics Lecture 5: Configuration Space ECE276B: Planning & Learning in Robotics Lecture 5: Configuration Space Lecturer: Nikolay Atanasov: natanasov@ucsd.edu Teaching Assistants: Tianyu Wang: tiw161@eng.ucsd.edu Yongxi Lu: yol070@eng.ucsd.edu

More information

Computational Geometry Algorithms Library. Geographic information Systems

Computational Geometry Algorithms Library. Geographic information Systems Computational Geometry Algorithms Library in Geographic information Systems Edward Verbree, Peter van Oosterom and Wilko Quak TU Delft, Department of Geodesy, Thijsseweg 11, 2629 JA Delft, the Netherlands

More information

CPSC / Sonny Chan - University of Calgary. Collision Detection II

CPSC / Sonny Chan - University of Calgary. Collision Detection II CPSC 599.86 / 601.86 Sonny Chan - University of Calgary Collision Detection II Outline Broad phase collision detection: - Problem definition and motivation - Bounding volume hierarchies - Spatial partitioning

More information

Foundations of Multidimensional and Metric Data Structures

Foundations of Multidimensional and Metric Data Structures Foundations of Multidimensional and Metric Data Structures Hanan Samet University of Maryland, College Park ELSEVIER AMSTERDAM BOSTON HEIDELBERG LONDON NEW YORK OXFORD PARIS SAN DIEGO SAN FRANCISCO SINGAPORE

More information

1. CONVEX POLYGONS. Definition. A shape D in the plane is convex if every line drawn between two points in D is entirely inside D.

1. CONVEX POLYGONS. Definition. A shape D in the plane is convex if every line drawn between two points in D is entirely inside D. 1. CONVEX POLYGONS Definition. A shape D in the plane is convex if every line drawn between two points in D is entirely inside D. Convex 6 gon Another convex 6 gon Not convex Question. Why is the third

More information

Solid Modeling Lecture Series. Prof. Gary Wang Department of Mechanical and Manufacturing Engineering The University of Manitoba

Solid Modeling Lecture Series. Prof. Gary Wang Department of Mechanical and Manufacturing Engineering The University of Manitoba Solid Modeling 25.353 Lecture Series Prof. Gary Wang Department of Mechanical and Manufacturing Engineering The University of Manitoba Information complete, unambiguous, accurate solid model Solid Modeling

More information

Question. Why is the third shape not convex?

Question. Why is the third shape not convex? 1. CONVEX POLYGONS Definition. A shape D in the plane is convex if every line drawn between two points in D is entirely inside D. Convex 6 gon Another convex 6 gon Not convex Question. Why is the third

More information

Chapter 4 Concepts from Geometry

Chapter 4 Concepts from Geometry Chapter 4 Concepts from Geometry An Introduction to Optimization Spring, 2014 Wei-Ta Chu 1 Line Segments The line segment between two points and in R n is the set of points on the straight line joining

More information

Interactive Math Glossary Terms and Definitions

Interactive Math Glossary Terms and Definitions Terms and Definitions Absolute Value the magnitude of a number, or the distance from 0 on a real number line Addend any number or quantity being added addend + addend = sum Additive Property of Area the

More information

CAR-TR-990 CS-TR-4526 UMIACS September 2003

CAR-TR-990 CS-TR-4526 UMIACS September 2003 CAR-TR-990 CS-TR-4526 UMIACS 2003-94 September 2003 Object-based and Image-based Object Representations Hanan Samet Computer Science Department Center for Automation Research Institute for Advanced Computer

More information

Engineering designs today are frequently

Engineering designs today are frequently Basic CAD Engineering designs today are frequently constructed as mathematical solid models instead of solely as 2D drawings. A solid model is one that represents a shape as a 3D object having mass properties.

More information

Outline of the presentation

Outline of the presentation Surface Reconstruction Petra Surynková Charles University in Prague Faculty of Mathematics and Physics petra.surynkova@mff.cuni.cz Outline of the presentation My work up to now Surfaces of Building Practice

More information

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

Planar Graphs. 1 Graphs and maps. 1.1 Planarity and duality Planar Graphs In the first half of this book, we consider mostly planar graphs and their geometric representations, mostly in the plane. We start with a survey of basic results on planar graphs. This chapter

More information

Solids as point set. Solid models. Solid representation schemes (cont d) Solid representation schemes. Solid representation schemes (cont d)

Solids as point set. Solid models. Solid representation schemes (cont d) Solid representation schemes. Solid representation schemes (cont d) Solid models Solid models developed to address limitations of wireframe modeling. Attempt was to create systems which create only complete representations. Modelers would support direct creation of 3D

More information

3D Modeling: Solid Models

3D Modeling: Solid Models CS 430/536 Computer Graphics I 3D Modeling: Solid Models Week 9, Lecture 18 David Breen, William Regli and Maxim Peysakhov Geometric and Intelligent Computing Laboratory Department of Computer Science

More information

Collision and Proximity Queries

Collision and Proximity Queries Collision and Proximity Queries Dinesh Manocha (based on slides from Ming Lin) COMP790-058 Fall 2013 Geometric Proximity Queries l Given two object, how would you check: If they intersect with each other

More information

Simplified Voronoi diagrams for motion planning of quadratically-solvable Gough-Stewart platforms

Simplified Voronoi diagrams for motion planning of quadratically-solvable Gough-Stewart platforms Simplified Voronoi diagrams for motion planning of quadratically-solvable Gough-Stewart platforms Rubén Vaca, Joan Aranda, and Federico Thomas Abstract The obstacles in Configuration Space of quadratically-solvable

More information

Braid groups and Curvature Talk 2: The Pieces

Braid groups and Curvature Talk 2: The Pieces Braid groups and Curvature Talk 2: The Pieces Jon McCammond UC Santa Barbara Regensburg, Germany Sept 2017 Rotations in Regensburg Subsets, Subdisks and Rotations Recall: for each A [n] of size k > 1 with

More information

Physically-Based Modeling and Animation. University of Missouri at Columbia

Physically-Based Modeling and Animation. University of Missouri at Columbia Overview of Geometric Modeling Overview 3D Shape Primitives: Points Vertices. Curves Lines, polylines, curves. Surfaces Triangle meshes, splines, subdivision surfaces, implicit surfaces, particles. Solids

More information

Geometric Algorithms in Three Dimensions Tutorial. FSP Seminar, Strobl,

Geometric Algorithms in Three Dimensions Tutorial. FSP Seminar, Strobl, Geometric Algorithms in Three Dimensions Tutorial FSP Seminar, Strobl, 22.06.2006 Why Algorithms in Three and Higher Dimensions Which algorithms (convex hulls, triangulations etc.) can be generalized to

More information

Computational Geometry Algorithmische Geometrie

Computational Geometry Algorithmische Geometrie Algorithmische Geometrie Panos Giannopoulos Wolfgang Mulzer Lena Schlipf AG TI SS 2013 !! Register in Campus Management!! Outline What you need to know (before taking this course) What is the course about?

More information

Robustness improvement of polyhedral mesh method for airbag deployment simulations. TU Delft

Robustness improvement of polyhedral mesh method for airbag deployment simulations. TU Delft Robustness improvement of polyhedral mesh method for airbag deployment simulations. TU Delft Santiago Alagon Carrillo, Numerical Analysis Daily Supervisor: Prof. dr. ir. C. Vuik, Company Supervisors: Dr.

More information

Topological Data Analysis - I. Afra Zomorodian Department of Computer Science Dartmouth College

Topological Data Analysis - I. Afra Zomorodian Department of Computer Science Dartmouth College Topological Data Analysis - I Afra Zomorodian Department of Computer Science Dartmouth College September 3, 2007 1 Acquisition Vision: Images (2D) GIS: Terrains (3D) Graphics: Surfaces (3D) Medicine: MRI

More information

layers in a raster model

layers in a raster model layers in a raster model Layer 1 Layer 2 layers in an vector-based model (1) Layer 2 Layer 1 layers in an vector-based model (2) raster versus vector data model Raster model Vector model Simple data structure

More information

Shape from Silhouettes I

Shape from Silhouettes I Shape from Silhouettes I Guido Gerig CS 6320, Spring 2015 Credits: Marc Pollefeys, UNC Chapel Hill, some of the figures and slides are also adapted from J.S. Franco, J. Matusik s presentations, and referenced

More information

Modeling 3D Objects: Part 2

Modeling 3D Objects: Part 2 Modeling 3D Objects: Part 2 Patches, NURBS, Solids Modeling, Spatial Subdivisioning, and Implicit Functions 3D Computer Graphics by Alan Watt Third Edition, Pearson Education Limited, 2000 General Modeling

More information

Optimal Compression of a Polyline with Segments and Arcs

Optimal Compression of a Polyline with Segments and Arcs Optimal Compression of a Polyline with Segments and Arcs Alexander Gribov Esri 380 New York Street Redlands, CA 92373 Email: agribov@esri.com arxiv:1604.07476v5 [cs.cg] 10 Apr 2017 Abstract This paper

More information

Introduction to 2D and 3D Computer Graphics. Realistic Rendering. -- Solids Modeling --

Introduction to 2D and 3D Computer Graphics. Realistic Rendering. -- Solids Modeling -- Introduction to 2D and 3D Computer Graphics Realistic Rendering -- Solids Modeling -- CS447/547 10-1 CS447/547 10-2 Solid objects can be defined......by sweeping an object along a trajectory through space...this

More information

Advanced Operations Research Techniques IE316. Quiz 1 Review. Dr. Ted Ralphs

Advanced Operations Research Techniques IE316. Quiz 1 Review. Dr. Ted Ralphs Advanced Operations Research Techniques IE316 Quiz 1 Review Dr. Ted Ralphs IE316 Quiz 1 Review 1 Reading for The Quiz Material covered in detail in lecture. 1.1, 1.4, 2.1-2.6, 3.1-3.3, 3.5 Background material

More information

The Algorithm Design Manual

The Algorithm Design Manual Steven S. Skiena The Algorithm Design Manual With 72 Figures Includes CD-ROM THE ELECTRONIC LIBRARY OF SCIENCE Contents Preface vii I TECHNIQUES 1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 1.10 2 2.1 2.2 2.3

More information

CS-235 Computational Geometry

CS-235 Computational Geometry CS-235 Computational Geometry Computer Science Department Fall Quarter 2002. Computational Geometry Study of algorithms for geometric problems. Deals with discrete shapes: points, lines, polyhedra, polygonal

More information

Collision Detection. These slides are mainly from Ming Lin s course notes at UNC Chapel Hill

Collision Detection. These slides are mainly from Ming Lin s course notes at UNC Chapel Hill Collision Detection These slides are mainly from Ming Lin s course notes at UNC Chapel Hill http://www.cs.unc.edu/~lin/comp259-s06/ Computer Animation ILE5030 Computer Animation and Special Effects 2 Haptic

More information

Computer-Aided Design. Contributing vertices-based Minkowski sum computation of convex polyhedra

Computer-Aided Design. Contributing vertices-based Minkowski sum computation of convex polyhedra Computer-Aided Design 41 (2009) 525 538 Contents lists available at ScienceDirect Computer-Aided Design journal homepage: www.elsevier.com/locate/cad Contributing vertices-based Minkowski sum computation

More information

Simplicial Complexes: Second Lecture

Simplicial Complexes: Second Lecture Simplicial Complexes: Second Lecture 4 Nov, 2010 1 Overview Today we have two main goals: Prove that every continuous map between triangulable spaces can be approximated by a simplicial map. To do this,

More information

DEVELOPING A THREE-DIMENSIONAL TOPOLOGICAL DATA MODEL

DEVELOPING A THREE-DIMENSIONAL TOPOLOGICAL DATA MODEL DEVELOPING A THREE-DIMENSIONAL TOPOLOGICAL DATA MODEL Saadi MESGARI International Institute for Aerospace Survey and Earth Sciences (ITC) The Netherlands Mesgari@itc.nl Working Group IC/16 KEY WORDS: Data

More information

Pacific Journal of Mathematics

Pacific Journal of Mathematics Pacific Journal of Mathematics SIMPLIFYING TRIANGULATIONS OF S 3 Aleksandar Mijatović Volume 208 No. 2 February 2003 PACIFIC JOURNAL OF MATHEMATICS Vol. 208, No. 2, 2003 SIMPLIFYING TRIANGULATIONS OF S

More information

Solid Modeling. Thomas Funkhouser Princeton University C0S 426, Fall Represent solid interiors of objects

Solid Modeling. Thomas Funkhouser Princeton University C0S 426, Fall Represent solid interiors of objects Solid Modeling Thomas Funkhouser Princeton University C0S 426, Fall 2000 Solid Modeling Represent solid interiors of objects Surface may not be described explicitly Visible Human (National Library of Medicine)

More information

Lecture 0: Reivew of some basic material

Lecture 0: Reivew of some basic material Lecture 0: Reivew of some basic material September 12, 2018 1 Background material on the homotopy category We begin with the topological category TOP, whose objects are topological spaces and whose morphisms

More information

Design Intent of Geometric Models

Design Intent of Geometric Models School of Computer Science Cardiff University Design Intent of Geometric Models Frank C. Langbein GR/M78267 GR/S69085/01 NUF-NAL 00638/G Auckland University 15th September 2004; Version 1.1 Design Intent

More information

CS368: Geometric Algorithms Handout # 2 Design and Analysis Stanford University Monday, 17 April 2006

CS368: Geometric Algorithms Handout # 2 Design and Analysis Stanford University Monday, 17 April 2006 CS368: Geometric Algorithms Handout # 2 Design and Analysis Stanford University Monday, 17 April 2006 Homework #1: Arrangements, zones, straight and topological sweeps [70 points] Due Date: Monday, 1 May

More information

CMSC 754 Computational Geometry 1

CMSC 754 Computational Geometry 1 CMSC 754 Computational Geometry 1 David M. Mount Department of Computer Science University of Maryland Fall 2005 1 Copyright, David M. Mount, 2005, Dept. of Computer Science, University of Maryland, College

More information

Geometric Representations. Stelian Coros

Geometric Representations. Stelian Coros Geometric Representations Stelian Coros Geometric Representations Languages for describing shape Boundary representations Polygonal meshes Subdivision surfaces Implicit surfaces Volumetric models Parametric

More information

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

Hierarchical Representation of 2-D Shapes using Convex Polygons: a Contour-Based Approach Hierarchical Representation of 2-D Shapes using Convex Polygons: a Contour-Based Approach O. El Badawy, M. S. Kamel Pattern Analysis and Machine Intelligence Laboratory, Department of Systems Design Engineering,

More information

Geometric Programming for Computer-Aided Design

Geometric Programming for Computer-Aided Design Geometric Programming for Computer-Aided Design Alberto Paoluzzi Dip. Informatica e Automazione, Università Roma Tre, Rome Italy with contributions from Valerio Pascucci Center for Applied Scientific Computing,

More information

Path Planning for Point Robots. NUS CS 5247 David Hsu

Path Planning for Point Robots. NUS CS 5247 David Hsu Path Planning for Point Robots NUS CS 5247 David Hsu Problem Input Robot represented as a point in the plane Obstacles represented as polygons Initial and goal positions Output A collision-free path between

More information

Polygon decomposition. Motivation: Art gallery problem

Polygon decomposition. Motivation: Art gallery problem CG Lecture 3 Polygon decomposition 1. Polygon triangulation Triangulation theory Monotone polygon triangulation 2. Polygon decomposition into monotone pieces 3. Trapezoidal decomposition 4. Convex decomposition

More information

INTRODUCTION TO THE HOMOLOGY GROUPS OF COMPLEXES

INTRODUCTION TO THE HOMOLOGY GROUPS OF COMPLEXES INTRODUCTION TO THE HOMOLOGY GROUPS OF COMPLEXES RACHEL CARANDANG Abstract. This paper provides an overview of the homology groups of a 2- dimensional complex. It then demonstrates a proof of the Invariance

More information

Problèmes de robustesse en géométrie algorithmique

Problèmes de robustesse en géométrie algorithmique Problèmes de robustesse en géométrie algorithmique Monique Teillaud ENS - 12 mars 2008 Computational geometry Solving geometric problems algorithms complexity analysis worst case, average, randomized implementation

More information

1. Introduction to Constructive Solid Geometry (CSG)

1. Introduction to Constructive Solid Geometry (CSG) opyright@010, YZU Optimal Design Laboratory. All rights reserved. Last updated: Yeh-Liang Hsu (010-1-10). Note: This is the course material for ME550 Geometric modeling and computer graphics, Yuan Ze University.

More information

Geometric Computation: Introduction

Geometric Computation: Introduction : Introduction Piotr Indyk Welcome to 6.838! Overview and goals Course Information Syllabus 2D Convex hull Signup sheet Geometric computation occurs everywhere: Geographic Information Systems (GIS): nearest

More information

13.472J/1.128J/2.158J/16.940J COMPUTATIONAL GEOMETRY

13.472J/1.128J/2.158J/16.940J COMPUTATIONAL GEOMETRY 13.472J/1.128J/2.158J/16.940J COMPUTATIONAL GEOMETRY Lecture 23 Dr. W. Cho Prof. N. M. Patrikalakis Copyright c 2003 Massachusetts Institute of Technology Contents 23 F.E. and B.E. Meshing Algorithms 2

More information

Solid Modeling. Ron Goldman Department of Computer Science Rice University

Solid Modeling. Ron Goldman Department of Computer Science Rice University Solid Modeling Ron Goldman Department of Computer Science Rice University Solids Definition 1. A model which has a well defined inside and outside. 2. For each point, we can in principle determine whether

More information

1/60. Geometric Algorithms. Lecture 1: Introduction. Convex Hulls

1/60. Geometric Algorithms. Lecture 1: Introduction. Convex Hulls 1/60 Geometric Algorithms Lecture 1: Introduction Convex Hulls Geometric algorithms scope 2/60 Geometry algorithms (practice): Study of geometric problems that arise in various applications and how algorithms

More information

Convex Hulls (3D) O Rourke, Chapter 4

Convex Hulls (3D) O Rourke, Chapter 4 Convex Hulls (3D) O Rourke, Chapter 4 Outline Polyhedra Polytopes Euler Characteristic (Oriented) Mesh Representation Polyhedra Definition: A polyhedron is a solid region in 3D space whose boundary is

More information

CS S Lecture February 13, 2017

CS S Lecture February 13, 2017 CS 6301.008.18S Lecture February 13, 2017 Main topics are #Voronoi-diagrams, #Fortune. Quick Note about Planar Point Location Last week, I started giving a difficult analysis of the planar point location

More information

COMPUTING CONSTRAINED DELAUNAY

COMPUTING CONSTRAINED DELAUNAY COMPUTING CONSTRAINED DELAUNAY TRIANGULATIONS IN THE PLANE By Samuel Peterson, University of Minnesota Undergraduate The Goal The Problem The Algorithms The Implementation Applications Acknowledgments

More information

Homework 1: Implicit Surfaces, Collision Detection, & Volumetric Data Structures. Loop Subdivision. Loop Subdivision. Questions/Comments?

Homework 1: Implicit Surfaces, Collision Detection, & Volumetric Data Structures. Loop Subdivision. Loop Subdivision. Questions/Comments? Homework 1: Questions/Comments? Implicit Surfaces,, & Volumetric Data Structures Loop Subdivision Shirley, Fundamentals of Computer Graphics Loop Subdivision SIGGRAPH 2000 course notes Subdivision for

More information