1. Trang chủ
  2. » Luận Văn - Báo Cáo

A Parallel Algorithm based on Convexityfor the Computing of DelaunayTessellation

77 206 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 77
Dung lượng 1,53 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

A Parallel Algorithm based on Convexityfor the Computing of DelaunayTessellation

Trang 1

VIETNAM NATIONAL UNIVERSITY, HANOI

UNIVERSITY OF SCIENCEFACULTY OF MATHEMATICS, MECHANICS AND INFORMATICS

———–OOO————

DONG VAN VIET

A Parallel Algorithm based on Convexity

for the Computing of Delaunay

Tessellation

Undergraduate ThesisAdvanced Undergraduate Program in Mathematics

HANOI - 2012

Trang 2

VIETNAM NATIONAL UNIVERSITY, HANOI

UNIVERSITY OF SCIENCEFACULTY OF MATHEMATICS, MECHANICS AND INFORMATICS

———–OOO————

DONG VAN VIET

A Parallel Algorithm based on Convexity

for the Computing of Delaunay

Tessellation

Undergraduate ThesisAdvanced Undergraduate Program in Mathematics

Instructor: Assoc Prof Dr Phan Thanh An

Institute of MathematicsVietnam Academy of Science and Technology

HANOI - 2012

Trang 3

This thesis is based on the following two papers: “A parallel algorithm based onconvexity for the computing of Delaunay tessellation” (by Phan Thanh An and Le HongTrang, published in Numerical Algorithms, Vol 59, No 3, pp 347-357, 2012) and

“Spines for constructing convex hulls in 2D and their applications” (by Phan Thanh

An, Dong Van Viet, and Dinh Thanh Giang, in preparation, 2012) In the process

of doing this thesis, I received much important encouraging factor and support fromuniversity, teachers, family and friends I would like to thank those people who havecontributed significantly to this thesis

The work on this thesis could not have been started if it were not for the generoussupport and the detail guide provided by my instructor, Associate Professor PhanThanh An I am indebted to his advice during time of writing this thesis He providedhelpful feedback, support and valuable advice in writing this thesis

This work was partially supported by the Center for High-Performance Computing

I want to thank Associate Professor Nguyen Huu Dien, Master of Science Le HoangSon, and Mr Pham Duy Linh, who kindly provided a chance me to execute an parallelprogram on parallel computer and supervised when the parallel program was executing

I want to show my gratitude to all teachers from Faculty of Mathematics, Mechanics,and Informatics, who had taught me a lot of knowledge through four years Students atK1 Advanced Mathematics class have been extremely helpful in providing suggestionsand constructive criticism during the preparation of the manuscript

Outside Hanoi University of Science, there are many people who have provided mewith their insightful comments and generously shared their document and knowledge

I would like to thank, in particular, Miss Dinh Thanh Giang for her advice

Finally, I want to thank to my family, mostly for their understanding of the timecommitment necessary to write such a thesis To all of them I wishes to express mysincere gratitude

Hanoi, October 28, 2012Dong Van Viet

Trang 4

D(P ) The Delaunay tessellation of a set of points P

Ed d-dimensional Euclidean space

Trang 5

1.1 Geometric Preliminaries 10

1.2 Convex Sets and Convex Hulls 11

1.3 Algorithms for Computing Convex Hulls 13

1.4 Graham’s Convex Hull Algorithm 14

1.4.1 Pseudocode, Version A 14

1.4.2 Pseudocode, Version B 17

1.4.3 Implementation of Graham’s Convex Hull Algorithm 18

1.5 Spines for Constructing Convex Hulls in 2D 22

1.5.1 Arithmetic Model 22

1.5.2 Calculating Angles 23

1.5.3 Generating Monotonic Sequences 25

1.5.4 Extracting a Spine 27

2 Delaunay Triangulations 35 2.1 Delaunay Triangulations 35

2.1.1 Definition of Delaunay Triangulations 35

2.1.2 Basic Properties of Delaunay Triangulations 37

2.2 Algorithms for Computing Delaunay Triangulations 41

2.3 Delaunay Triangulations and Connection to Convex Hulls 42

2.4 Delaunay Triangulations and Restricted Areas 46

3 A Parallel Algorithm for Computing Delaunay Triangulations 51 3.1 Parallel Algorithms 51

3.2 Correctness and Implementation of the Parallel Algorithm 54

Trang 6

3.3 Remarks 55

Conclusion 57 Appendix A 58 Introduction to MPI Library 58

Getting Started with MPI on the Cluster 58

Compilation 58

Running MPI 59

The Basis of Writing MPI Programs 59

Initialization, Communicators, Handles, and Clean-Up 59

MPI Indispensable Functions 60

Example 63

Timing Programs 65

Debugging Methods 66

Appendix B 67 C Codes for Graham’s Convex Hull Algorithm 67

C Code for Computing Delaunay Triangulations 70

A Parallel Code for Computing Delaunay Triangulations 72

Appendix C 75 Center for High Performance Computing CPHC-HUS 75

Trang 7

Computational geometry is a branch of computer science concerned with the designand analysis of algorithms to solve geometric problems (such as pattern recognition,computer graphics, operations research, computer-aided design, robotics, etc.) thatrequire real-time speeds Until recently, these problems were solved using conventionalsequential computer, computers whose design more or less follows the model proposed

by John von Neumann and his team in the late 1940s (see [14]) The model consists

of a single processor capable of executing exactly one instruction of a program duringeach time unit Computers built according to this paradigm have been able to perform

at tremendous speeds However, it seems today that this approach has been pushed

as far as it will go For example, the speed of light imposes a limit that cannot besurpassed by any electronic device

On the other hand, our appetite appears to grow continually for ever more powerfulcomputers capable of processing large amounts of data at great speeds One solution

to this predicament that has recently gained credibility and popularity is parallel cessing The main purpose of parallel processing is to perform computations fasterthan can be done with a single processor by using a number of processors concurrently

pro-A parallel computer is simply a collection of processors, typically of the same type,interconnected in a certain fashion to allow the coordination of their activities and theexchange of data (see [14])

In order to solve a problem efficiently on a parallel machine, it is usually necessary

to design an algorithm that specifies multiple operations on each step, i.e., a lel algorithm This algorithm can be executed a piece at a time on many differentprocessors, and then put back together at the end to get the correct result

paral-MPI (Message Passing Interface) is one of the most popular library for passing within a parallel program It is a standardized and portable message-passingsystem designed by a group of researchers from academia and industry to function on awide variety of parallel computers The standard defines the syntax and semantics of acore of library routines useful to a wide range of users writing portable message-passingprograms in Fortran or C/C++

message-In En, a Delaunay tessellation (i.e Delaunay triangulation in the plane) is an

Trang 8

important problem in many domains, including pattern recognition, terrain modeling,and mesh generation for the solution of partial differential equations In many ofthese domains the tessellation is a bottleneck in the overall computation, making itimportant to develop fast algorithms As a result, there are many sequential algorithmsavailable for Delaunay tessellation, along with efficient implementations (see [17, 20]).Among others, Aurenhammer et al.’s method based on a beautiful connection betweenDelaunay tessellation and convex hull in one higher dimension (see [7, 9, 12]) Sincethese sequential algorithms are time and memory intensive, parallel implementation areimportant both for improved performance and to allow the solution of problems thatare too large for sequential machines However, although several parallel algorithmsfor Delaunay triangulation have been presented, practical implementations have beenslower to appear (see [8]).

For the convex hull problem in 2D and 3D, we find the convex hull boundary inthe domain formed by a rectangular (or rectangular parallelepiped) Then the domain

is restricted to a smaller domain, namely, restricted area to a simple detection ratherthan a complete computation (see [2, 3])

Recently, some problem in the area of computational geometry has focused on thenumerical issues that arise when geometric algorithms are implemented using roundedfloating point arithmetic Unlike other types of numerical algorithms, most geometricalgorithms require that all arithmetic be performed over the field of reals or rationals,and they behave erratically when implemented with a non-associative number systemsuch as rounded arithmetic The term robust has arisen to describe algorithms whosecorrectness is not spoiled by round-off error The assumption is we do not “cheat”:each real varible in the algorithm is replaced by a floating point variable, and each realaddition, subtraction, multiplication and division is replaced by a single correspondingfloating point operation Clearly, robust algorithms are of great practical interest.Section 1.5 present the first rounded arithmetic convex hull algorithm which guarantees

a convex hull output and which has error independent of the number of input points([16]) Some our initial results about spines are also presented in this section

In this thesis, we present a parallel algorithm introduced by P.T An [5] based

on divide-and-conquer strategy (see [14]) At each process of parallel algorithm, theAurenhammer et al.’s method (the lift-up to the paraboloid of revolution) is used Theconvexity in the plane as a crucial factor of efficience of the new parallel algorithm overcorresponding sequential algorithm is shown In particular, a restricted area obtainedfrom a paraboloid given in [8] is used to discard non-Delaunay edges (Proposition 2.2).Some advantages of the parallel algorithm are shown Its implementation in plane isexecuted easily on both PC clusters and parallel computers (Section 3.2) Compare

Trang 9

with a previous work, the resulting implementation (done at the Center for Performance Computing, Hanoi University of Science [10]) significantly achieves betterspeedups over corresponding sequential code given in [18] (see Table 3.1).

High-This thesis has three chapters and three appendices:

Chapter 1: Convex Sets and Convex Hulls We deal with basis geometric liminaries, convex set and convex hull notions This chapter shows some algo-rithms for computing convex hull and goes in detail for only Graham’s convexhull algorithm Li and Milenkovic’s concept of spines for a point set is presented

pre-We present some initial results about the use of spines for constructing convexhulls in 2D

Chapter 2: Delaunay Triangulations Chapter 2 majors on the definition of launay triangulation and properties of Delaunay triangulation Then it deals withsome algorithms for computing Delaunay triangulation This chapter also shows abeautiful connection between Delaunay tessellation and convex hulls in one higherdimension The so-called restricted area is presented

De-Chapter 3: A Parallel Algorithm for Computing Delaunay Triangulations.This chapter comes into contact with parallel algorithms The algorithms are exe-cuted on parallel computer and the results shows that the parallel algorithms runmuch faster

Appendices: These appendices are designed to give a brief overview of some of thebasis and important routines of MPI Library Some C codes are represented here.These appendices also include some information about the IBM System Cluster

1350 of the Center for High-Performance Computing, Hanoi University of Science,which was used to execute the algorithms

Some new initial results about the use of spines for constructing convex hulls in 2Dwere presented at the seminar of the Department of Numerical Analysis and ScientificComputing, Institute of Mathematics, Hanoi on October 10, 2012

Trang 10

Chapter 1

Convex Sets and Convex Hulls

The most ubiquitous structure in computational geometry is the convex hull It isuseful in its own right and useful as a tool for constructing other structures in a widevariety of circumstances The construction of the convex hull, in two dimensions, isthe subject of this chapter For the reader’s convenience, this chapter presents somebasic geometrical notions that will be commonly used in this text

The objects considered in Computational Geometry are normally sets of points inEuclidean space A coordinate system of reference is assumed, so that each point isrepresented as a vector of cartesian coordinates of the appropriate dimension Thegeometric objects do not necessarily consist of finite sets of points, but must complywith the convention to be finitely specifiable So we shall consider, besides individualpoints, the straight line containing two given points, the straight line segment defined

by its two extreme points, the plane containing three given points, the polygon defined

by an (ordered) sequence of points, etc

This section has no pretence of providing formal definitions of the geometric conceptsused in this paper; it has just the objectives of refreshing notions that are certainlyknown to the reader and of introducing the adopted notation (see [20], pp.17-19)

A Cartesian coordinate system specifies each point uniquely in a plane by a pair

of numerical coordinates, which are the signed distances from the point to two fixedperpendicular directed lines, measured in the same unit of length Each reference line

is called a coordinate axis or just axis of the system, and the point where they meet istheir origin, usually at ordered pair (0, 0)

By Edwe denote the d − dimensional Euclidean space, i.e., the space of the d-tuples(x1, , xd) of real numbers xi, i = 1, , d with metric (Pd

i=1x2i)1/2 We shall nowreview the definition of the principal objects considered by Computational Geometry.Point: A d-tuple (x1, , xd) denotes a point p of Ed; this point may be also

Trang 11

interpreted as a d-component vector applied to the origin of Ed, whose free terminus

A polygon is simple if there is no pair of nonconsecutive edges sharing a point

Polyhedron: In E3 a polyhedron is defined by a finite set of plane polygons suchthat every edge of a polygon is shared be exactly one other polygon (adjacent polygons)and no subset of polygons has the same property The vertices and the edges of thepolygons are the vertices and the edges of the polyhedron; the polygons are the facets

of the polyhedron A polyhedron is simple if there is no pair of nonadjacent facetssharing a point

Faces: The boundary of a polyhedron in E3 consists of polygons, which are calledfaces Generally, we shall refer to a bounded d-dimensional polyhedral set as a convexd-polytope The boundary of a polytope in Edconsists of polyhedrons in Ed−1, whichare called (d − 1)-faces; the boundary of an (d − 1)-faces consists on polyhedrons in

Ed−2, which are called (d − 2)-faces; and so on Note that 0-faces are vertices, and1-faces are edges, and that (d − 1)-faces are sometimes called facets

Definition 1.1 (see [17], p.18) Given two distinct points q1 and q2 in Ed, the linearcombination

αq1+ (1 − α)q2 (α ∈ R, 06α 61)

is called the convex combination of q1 and q2

This convex combination describes the line segment joining the two points q1 and

q2 Normally this segment is denoted as q1q2 (unordered pair)

Definition 1.2 (see [17], p.18) A domain D in Ed is convex if, for any two points q1and q2 in D, the segment q1q2 is entirely contained in D

Observing Fig.1.1(a), we readily understand that the line segment between any twopoints in a convex domain is included in the domain It should be clear from Fig.1.1(b)that any region with a “dent” is not convex, since two points straddling the dents can

Trang 12

Figure 1.1 a) Convex set, b) nonconvex set.

be found such that the segment they determine contains points exterior to the region

A simple polygon P is convex if its interiour is a convex set A simple polyhedron isconvex if its interior is a convex set

Definition 1.3 (see [17], p.21) The convex hull of a set of points P in Ed is theboundary of the smallest convex domain in Ed containing P (see Fig.1.2)

Figure 1.2 Convex hull of finite set.

In the mathematics literature, the convex hull of a set of points P is denoted byCH(P ) Note that the convex hull of a set is a closed “solid” region, including all thepoints inside Often the term is used more loosely in computational geometry to meanthe boundary of this region, since it is the boundary we compute, and that implies theregion We will use the phrase “on the hull” to mean “on the boundary of the convexhull.”

Theorem 1.1 (see [17], p.97) The convex hull of a finite set of points in Ed is aconvex polytope; conversely, a convex polytope is the convex hull of a finite of points.Convex hull problem Given a set P of n points in Ed, construct its convex hull(that is, the complete description of the boundary CH(P ))

Referring to the nonconstructive nature of Definition 1.3, we must now find ematical results that will lead to efficient algorithms

Trang 13

math-Definition 1.4 (see [17], p.104) A point p of a convex set P is an extreme point if notwo points a, b ∈ S such that p lies on the open line segment ab.

The set E of extreme points of P is the smallest subset of P having the propertythat CH(E) = CH(P ), and E is precisely the set of vertices of CH(P ) It follows thattwo steps are required to find the convex hull of a finite set:

i Identify the extreme points

ii Order these points so that they form a convex polygon

The extreme points of a set P of points in the plane are the vertices of the convexhull at which the interior angle is strictly convex, less than π An edge is extreme ifevery point of P is on or to one side of the line determined by the edge It seems easiest

to detect this by treating the edge as directed, and specifing one of the two possibledirections as determining the “side” Let the left side of a directed edge be the inside.Phrased negatively, a directed edge is not extreme if there is some point that is notleft of it or on it

The remainder of this chapter will concentrate on algorithms for constructing theboundary of the convex hull of a finite set of points in two dimensions We justmention some rather inefficient algorithms and go on full detail for Graham’s convexhull algorithm

In computational geometry, numerous algorithms are proposed for computing theconvex hull for a finite set of points and for other geometric objects with variouscomputational complexities (see [18], pp.68-91) Known convex hull algorithms arelisted below, time complexity of each algorithm is stated in terms of inputs points nand the number of points on the hull h

Gift wrapping algorithm: One of the simplest planar algorithm Discoveredindependently by Chand and Kapur in 1970 and by Jarvis in 1973 The idea is to useone extreme edge as an anchor for finding the next This works because we know thatthe extreme edges are linked into a convex polygon It has O(nh) time complexity,where n is the number of points in the set, and h is the number of points in the hull

In worst case the complexity is O(n2)

Graham’s convex hull algorithm: A slightly more sophisticated, but much moreefficient algorithm, published by Graham in 1972 with a worst-case optimal O(n log n)algorithm If the points are already sorted by one of the coordinates or by the angle

to a fixed vector, then the algorithm takes O(n) time We’ll go in full detail for thisalgorithm in the next section

Trang 14

Quick hull: Discovered independently by several researchers in the late 1970s.

It was dubbed the “quick hull” algorithm by Preparata and Shamos because of itssimilarity to the QuickSort algorithm (see [23], pp 97-122) The basic intuition is assimple as it is sound: for “most” sets of points, it is easy to discard many point asdefinitely interior to the hull, and then concentrate on those closet to the hull boundary.Just like the QuickSort algorithm, it has the expected complexity of O(n log n), butmay degenerate to O(n2) in the worst case

Divide and conquer: “Divide and conquer” is a general paradigm for solvingproblems that has proved very effective in computer science The divide and conquertechnique was frist applied to the convex hull problem by Preparata and Hong (1977),whose goal was to create an efficient algorithm for three dimensions This techniquesachieves the same asymptotically optimal O(n log n) time complexity It is thereforewell worth studying, even though in two dimensions it is relatively complicated.Incremental Algorithm: Published in 1984 by Kallay Having arrived at anoptimal O(n log n) algorithm, it may seem there is no point in exploring additionalalgorithms But there is motivation: extension to three (and higher) dimensions Itsbasic plan is simple: add the points one at a time, at each step constructing the hull

of the first k points and using that hull to incorporate the next points It turns outthat “factoring” the problem this way simplifies it greatly, in that we only have to dealwith one very special case: adding a single point to an existing hull

Perhaps the honor of the first paper published in the field of computational geometryshould be accorded to Graham’s convex hull algorithm for finding the hull of points intwo dimensions in O(n log n) time In the late 1960s an application at Bell Laboratoriesrequired the hull of n ≈ 10, 000 points, and they found the O(n2) algorithm in use tooslow Graham developed his simple algorithm in response to this need

Trang 15

Before proceeding to a more careful presentation, we summarize the rough algorithm

in pseudocode in Algorithm 1 ( see [18], p.74) We use stack data structure to maintainthe points of the convex hull We assume stack primitives P ush(p, S) and P op(S),which push p onto the top of the stack S, and pop the top off, respectively (see [23],p.233) We use t to index the stack top and i for angularly sorted points Manyissues remain to be examined (start and termination in particular), but at this coarselevel, it should be apparent that the while loop iterates O(n) times: each stack poppermanently removes one point, so the number of backups cannot exceed n Togetherwith n forward steps, the loop iterates at most 2n times So the algorithm runs inlinear time after the sorting step, which takes O(n log n) time

Algorithm 1 (Graham scan, version A)

Given: P = {q0, q1, , qn}.

Find: The convex hull of P

1: Find interior point x; label it p 0

2: Sort all other points angularly about x; label p1, , pn−1.

3: Stack S = {p2, p1} = {p t , pt−1, , p1}; t indexes top.

Start and Stop of Loop

Even a simple loop can be difficult to start and stop properly: the algorithm so farpresented might have trouble at either end The termination difficulties would arise if

a, the stack bottom, were not on the hull Startup difficulties occur when b, the secondpoint pushed on stack, is not on the hull For suppose that (a, b, c) is a right turn.Then b would be popped from the stack, and the stack reduced to S = (a) But atleast two points are needed to determine if a third forms a left turn with the stack top.Clearly both startup and stopping problems are avoided if both a and b are on thehull How this can be arranged will be shown in the next subsection

Sorting Origin

A simplification is to sort with respect to a point of the set, and in particular, withrespect to a point on the hull We shall use the lowest point, which is clearly on thehull In case there are several with the same minimum y coordinate, we will use therightmost of the lowest as the sorting origin This is point 0 in Fig.1.3 Now thesorting appears as in Fig.1.3 Note all points in the figure have been relabeled with

Trang 16

numbers; this is how they will be indexed in the implementation We will call thepoints p0, p1, , pn−1, with p0 the sorting origin and pn−1 the most counterclockwisepoint.

Figure 1.3 Sorting points.

Now we are prepared to solve the startup and termination problems discussed above

If we sort points with respect to their counterclockwise angle from the horizontal rayemanating from our sorting origin p0, then p1 must be on the hull, as it forms anextreme angle with p0 However, it may not be an extreme points, an issue we shalladdress below If we initialize the stack to S = {p0, p1}, the stack will always contain

at least two points, avoiding startup difficulties, and will never be consumed when thechain wraps around to p0 again, avoiding termination difficulties

Collinearities

The final “boundary condition” we consider is the possibility that three or morepoints are collinear, until now a situation conveniently assumed not to occur Thisissue affects several aspects of the algorithm First we focus on defining precisely what

we seek as output

Hull Collinearities We insist here on the most useful output: the extreme verticesonly, ordered around the hull Thus if the input consists of the corners of a square,together with points sprinkled around its boundary, the output should consist of justthe four corners of the square Avoiding non-extreme hull points is easily achieved byrequiring a strict left turn (pt−1, pt, pi) to push pi onto the stack, where pt and pt−1are the top two points on the stack Then if pt is collinear with pt−1 and pi, it will bedeleted

Sorting Collinearities Collinearities raise another issue: how should we break ties

Trang 17

in the angular sorting if both points a and b form the same angle with p0? One’s firstinclination is to assume (or hope) it does not matter, but alas the situation is moredelicate There are at least two points First, use a consistent sorting rule, and thenensure start and stop and hull collinearities are managed appropriately A reasonablerule is that if angle(a) < angle(b), then a < b, if angle(a) = angle(b), then define

a < b if |a − p0| < |b − p0|, where angle(pi) is the counterclockwise angle between

p0pi and the positive x axis (since, p0 is lowest, all these angles are in range (0, π] ).Closer points are treated as earlier in the sorting sequence With this rule we obtainthe sorting indicated by the indices in the example shown in Fig.1.4

Figure 1.4 Sorting points with collinearities.

Note, however, that p1 is not extreme in the figure, which makes starting with

S = {p1, p0} problematic Although this can be circumvented by starting instead with

S = {pn−1, p0} (note that pn−1 = p18 is extreme), we choose here a second option It

is based on this simple observation: if angle(a) = angle(b) and a < b according to theabove sorting rule, then a is not an extreme point of the hull and may therefore bedeleted In Fig.1.4, points p1, p5, p9, p12, and p17 may be deleted for this reason.Coincident Points Often code that works on distinct points crashes for sets thatmay include multiple copies of the same point We will see that we can treat this issue

as a special case of a sorting collinearity, deleting all but one copy of each point.1.4.2 Pseudocode, Version B

Before proceeding with implementation details, we summarize the preceding sion with pseudocode in Algorithm 2 that incorporates the changes (see [18], p.77)

discus-We have not discussed yet the details of loop termination Is the condition i < ncorrect, even when there are collinearities? Or should it be i 6 n, or i < n − 1?

Trang 18

Algorithm 2 (Graham scan, version B)

Given: P = {q 0 , q 1 , , q n }.

Find: The convex hull of P

1: Find rightmost lowest point; label it p0.

2: Sort all other points angularly about p0.

In case of tie, delete the point closer to p0

(or all but one copy for multiple points).

3: Stack S = {p1, p0} = {pt, pt−1, , p0}; t indexes top.

of being finished Thus the loop stopping condition is indeed i < n

1.4.3 Implementation of Graham’s Convex Hull Algorithm

We now describe an implementation of Algorithm 2 We assume the input points aregiven with integer coordinate, and we insist upon avoiding all floating-point calculations

so that a correct output can be guaranteed We start with data structures, then tacklethe sorting step, and finally present the code

Data Representation

We have a choice between storing the points in an array or a list We choose in thisinstance to use an array, anticipating using a sorting routine that expects its data in acontiguous section of memory Each point will be represented by a structure parallelingthat used for vertices (see Appendix B, Code 1.1) The point are stored in a globalarray P , with P := {P [0], , P [n − 1]} corresponding to {p0, , pn−1} Each P [i] is

a structure with fields for its coordinates, a unique identifying number, and a flag tomark deletion (see Appendix B, Code 1.2)

The stack is most naturally represented by s singly linked list of cells, each of which

“contains” a point (i.e., contains a pointer to a point record) (see Appendix B, Code1.3) With these definitions, the stack top can be declared as tStack top, and theelement under the top is top → next

We need three stack manipulation routines: Pop, Push, and PrintStack (see pendix B, Code 1.4) The stack top is always the head (leftmost) element of the list.Pop frees the top cell and returns a pointer to the next cell Push(p,t) allocates newstorage, fills it up with p, and makes it the new stack top Note in PrintStack that t

Trang 19

Ap-→ p Ap-→ v reaches the coordinates of the point: t is type tStack, p is type tPoint, v istype tPointi.

Sorting

FindLowest We first dispense with the easiest aspect of the sorting step: findingthe rightmost lowest point in the set The function Findlowest accomplishes this andswaps the point into P [0] (see Appendix B, Code 1.5)

Avoiding Floats The sorting step seems straightforward, but there are hiddenpitfalls if we want to guarantee an accurate sort First we introduce a bit of notation.Let ri = pi− p0, the vector from p0 to pi Our goal is to give a precise calculation todetermine when pi< pj, where “ < ” represents the sorting relation The obvious choice

is to define pi< pj if angle(ri) < angle(rj), where angle(r) is the counterclockwise angle

of r from the positive x axis Since p0 is lowest, all these angles are in the range (0, π],which is convenient because sorting positive and negative angles can tricky C providesprecisely the desired function: angle(r) = atan2(r[x], r[y]) There are at least tworeasons not to use this First, although the conversion from ints to doubles (required

by atan2) should be accurate, there is no guarantee that the arctangent computation

is itself accurate Second, the arctangent is a complicated, function - left is simplerand serves the same purpose

Left The function to determine whether a point is left of a line determined by twoother points, is precisely what we need to compare ri and rj Left was itself a simpletest on the value of Area2, which computes the signed area of the triangle determined

by three points We will use this area function rather than Left, as it is then easier todistinguish ties We will first discuss the overall sorting method before showing howArea2 is employed for comparisons

Qsort The standard C library includes a sorting routine qsort that is at least asgood as most programmers could develop on their own, and it makes sense to use it.Because it is general, however, it takes a bit of effort to set it up properly The routinerequires information on the shape and location of the data and a comparison function

to compare keys It then uses the provided comparison function to sort the data inplace, from smallest to largest Its four arguments are:

1 A pointer to the base of the data, in our case &P[1], the address of the first point.( Remember that P [0] is fixed as our lexicographic minimum.)

2 The number of elements to be sorted: n − 1

3 The width of a element in bytes: sizeof(tsPoint)

4 The name of the two-argument comparison routine: Compare

Trang 20

Compare The routine qsort expects the comparison function to “return an integerless than, equal to, or greater than 0 according as the first argument is to be consideredless than, equal to, or greater than the second.” Moreover, it will be called “with twoarguments which are pointers to the elements being compared” This latter requirementpresents a slight technical problem, because we need three inputs: p0, pi, and pj Here

we choose a solution: make P global, so that p0 can be referenced inside the body ofcompare without passing it as a parameter

Finally we can specify the heart of compare: if pj is left of the directed line though

p0pi, then pi < pj In other word, pi < pj if Area2(p0, pi, pj) > 0, in which case qsortexpects a return of −1 to indicate “less than”

When the area is zero , we fall into a sorting collinearities, which requires action asdiscussed previously (Subsection 1.4.1) First we need to decide which point is closer

to p0 We can avoid computing the distance by noting that if pi is closer, then ri =

pi− p0 projects to a shorter length than does rj = pj − p0 The code computes theseprojections x and y and bases further decisions on them If pi is closer, mark it forlater deletion; if pj is closer, mark it instead If x = y = 0, then pi = pj and we markthe one with lower index for later deletion In all cases, one member of {−1, 0, +1} isreturned according to the angular sorting rule detail earlier

Main

Having worked out the sorting details, let us move to the top level and discuss main(see Appendix B, Code 1.6) The points are read in, the rightmost lowest is swappedwith P [0] in Findlowest, and P [1], , P [n − 1] are sorted by angle with qsort Therepeated call to Compare mark a number of points for deletion by setting the Booleandelete field The next task is to delete those points, which we accomplish with asimple routine Squash (see Appendix B, Code 1.7) This maintains two indices i and

j into the points array P , copying P [i] on top of P [j] for all undeleted points i Afterthis the most problematic cases are gone, and we can proceed with the Graham scan,with the call top = Graham()

Code for the Graham Scan

The code for the Graham scan is a nearly direct translation of the while loop in thepseudocode presented earlier (Algorithm 2); see Appendix B, Code 1.8 We have theall too common situation where the majority of the coding effort is on the periphery,with relatively little needed for the heart of the geometric algorithm For completed

C code for pseudocode Graham Scan Version B, see [19] The author of this C code isO’Rourke

Trang 21

We summarize in a theorem

Theorem 1.2 (see [18], p.86) The convex hull of n points in the plane can be found

by Graham’s convex hull algorithm in O(n log n) time: O(n log n) for sorting and nomore than 2n iterations for the scan

The complexity of the first step, finding the rightmost lowest point, is in O(n) Thesorting step use quicksort algorithm to sort points then the complexity of the sortingstep is in O(n log n) (see [23], p.84) Graham’s scan takes time proportional to thenumber of vertices Let’s see how

In each iteration of loop, if the turn is left we change the cost of the test to the vertexthat is added to the tentative list of extreme vertices; if the turn is right we chargethe cost to the vertex that gets deleted A vertex that is deleted right away (that is,without being added to the tentative list of vertices) initiates a backtrack Each step

in the backtrack, except the last, results in a deletion which we charge to the deletedvertex The cost of the last step is charged to the deleted vertex that initiated thebacktrack, which is thus charged twice Se every vertex is charged at most twice Thusthe complexity of Graham’s scan is in O(n); and that of the algorithm is in O(n log n).Example

Figure 1.5 Graham scan for Fig.1.4

The example in Fig.1.5 (a repeat of the points in Fig.1.4) was designed to be astringent test of the code for Graham’s convex hull algorithm in the previous section,

as it includes collinearities of all types The points after angular sorting, with marksfor those to be deleted, are shown in Table 1.1 (The vnums indices shown accord withthe labels in Fig.1.5) After deleting five points in Squash, n = 14 points remain

Trang 22

Index (x, y) delete Index (x, y) delete

Table 1.1 Points in Fig.1.5 after sorting.

The stack is initialized to {p18, p15} Point p6and p12are added to form {p12, p6, p18, p15}, but then p1causes p12to be deleted After p1is pushed onto the stack, p3 causes

p1 to be popped, because (p6, p1, p3) is not a strict left turn (the three points arecollinear) Then p3 is removed by p16 And so on For this example, the total number

of iterations is 19 < 2.n = 28 The final result is {p1, p9, p8, p7, p16, p6, p18, p15}, theextreme points in clockwise order

1.5.1 Arithmetic Model

There are three types of representation for the vertex coordinates of the input: fixedpoints, single precision floating point, and double precision floating point Fixed pointrepresentation is essentially integer representation with the implicit understanding thateach number is multipled by some fixed power of two Floating point representationcontain an explicit exponent field as well as mantissa The value represented by afloating point number with mantissa m and exponent e is 2em

The fixed or integer representation has BI bits; the single precision floating pointmantissa has BS bits; and the double has a BD of mantissa For a typical computers

BI is 16 or 32, BS is 23 and BD is 53

Mathematically, the consequence of single precision having BS bits is that everysingle precision operation has a relative error bound of 2−BS For example,

|(a +BS b) − (a + b)|62−BS|a + b|,where a +BSb refers to the sum of a and b computed using single precision arithmetic.The analogous bound holds for the other three operations This broad assumption

Trang 23

holds for all floating point representations Particular floating point representationsmay have more specific properties, but we do not expoint them here.

For a given set of points in two dimensions, the diameter ∆ of the set is defined

as usual: the maximum distance between a pair of points in the set For geometriccalculations on a set of points, absolute error is measured as a multiple of the roundingunit µ = 2−BS∆ This multiple is independent of precision and scale

1.5.2 Calculating Angles

An essential calculation in constructing convex hull is to determine if two line ments p1p2 and p2p3 form a convex or concave angle The robust convex hull algorithmrequires the slightly more general operation of computing the angle formed by separateline segments p1p2 and p3p4 (see Fig 1.6) Without loss of generality, from now on

seg-we make the assumption that the two segments have positive slope and “point to theright”: xp1 < xp2, yp1 < yp2, xp3 < xp4, and yp3 < yp4 Define θp1p2 to be the angle thatline p1p2makes with the x-axis Define θ(p1p2, p3p4) = θp3p4−θp1p2 to be the angle thatline p3p4 makes with line p1p2 The following exact arithmetic function determines ifθ(p1p2, p3p4) is greater than or equal to zero

PositiveAngleSign (p1p2, p3p4)

if [(xp2 − xp1)(yp4 − yp3) − (yp2 − yp1)(xp4 − xp3)> 0]

then return true

else return false

Figure 1.6 Angle of 2 segments.

Actually calculating the angle θ(p1p2, p3p4) requires taking a square root and arcsine.However, we can avoid these by computing the relative change in slope,

Trang 24

then return true

else return false

Exact convex hull algorithm use PositiveAngleSign, and the robust algorithms sented here use RelativeSlopeCompare

pre-Lemma 1.1 ([16]) RelativeSlopeCompare can be computed approximately using 6single precision floating point additions and 3 single precision floating point multipli-cations The absolute accuracy is (3 + 6κ) ·2−BS In particular,

i if RelativeSlopeCompare(p1p2, p3p4, κ) = true then τ (p1p2, p3p4)>κ − (3 + 6κ) ·

2−BS;

ii if RelativeSlopeCompare (p1p2, p3p4, κ) = false then τ (p1p2, p3p4) < κ + (3 +6κ) · 2−BS

In practice, we only invoke RelativeSlopeCompare for small values of κ (about 32 ·

2−BS) In this case, we can neglect the error term 6 · 2−BS For this reason, in the rest

of the paper, the error bound will be simply 3 · 2−BS

Proof (Lemma 1.1) A relative error of 2−BS in the calculation of xp2 − xp1 results in

an absolute error of 2−BS(xp 2 − xp 1)(yp 4 − yp 3) in the calculation of the expression,

(xp2 − xp1)(yp4 − yp3) − (yp2 − yp1)(xp4 − xp3)

Similar bounds hold for the two multiplications and three of the other subtractions.The sum of these error is bounded by,

3 · 2−BS((xp 2 − xp 1)(yp 4 − yp 3) + (yp 2 − yp 1)(xp 4 − xp 3))

Trang 25

The final subtraction evaluated results in an absolute error bounded by,

2−BS|(xp2 − xp1)(yp4 − yp3) − (yp2 − yp1)(xp4− xp3)|

This corresponds to a relative error of up to 2−BS in the calculation of the angle.Since this error is relative, we can treat it as if it occurs to the right hand side ofthe inequality Using similarly reasoning, it can be shown that the absolute error incomputing the expression,

κ((xp2 − xp1)(yp4 − yp3) + (yp2 − yp1)(xp4 − xp3)),

is bounded by,

5 · 2−BS((xp2 − xp1)(yp4 − yp3) + (yp2 − yp1)(xp4 − xp3)),(one extra multiplication) The transfer error from the right to the left changes 5 to 6.Together these error bounds imply the lemma

In the rest of this representation, we will treat τ (p1p2, p3p4) as if it were θ(p1p2, p3p4),the actual angle between segments p1p2and p3p4 We can do this for two reasons First,

τ (p1p2, p3p4) is always an overestimation of θ(p1p2, p3p4) In particular,

τ (p1p2, p3p4)>θ(p1p2, p3p4),for all positively sloped line segments that “point to the right.” For p1p2and p3p4nearlyhorizontal or vertical, τ (p1p2, p3p4) is much larger than θ(p1p2, p3p4) This means that

an absolute error of 3 · 2−BS in the measurement of τ corresponds to a much smallererror in the measurement of θ

The second reason that we can replace θ by τ is that for fixed p1p2, τ (p1p2, p3p4) is

a monotonic function of θ(p1p2, p3p4) This implies the following lemma which we use

in Section 1.5.4

Lemma 1.2 ([16]) If τ (p1p2, p2p3), τ (p1p2, p3p4) < κ, then τ (p1p2, p2p4) < κ

Proof This simply follows from the monotonicity of τ and the fact that,

min(θ(p2p3), θ(p3p4))6θ(p2p4)6max(θ(p2p3), θ(p3p4))

1.5.3 Generating Monotonic Sequences

The rest of this subsection will show how to modify the standard Graham algorithm

to generate a convex 36µ-hull of a set of n points in O(n log n) time Let P be a set of

Trang 26

points with real coordinates in the plane, the first step is to extract four monotonic quences of points from P which cover the vertices of the convex hull, called Q1, Q2, Q3and Q4, and all points of P stay inside the region bounded by the 4 monotonic se-quences Let the right of a polyline formed by a monotonic sequence be the inside Foreach sequence, the x and y coordinates are monotonic function of index In Fig.1.7,the increasing sequences are solid and the decreasing sequences are dotted.

se-Figure 1.7 Four monotonic sequences.

Definition 1.5 Let P = {p0, p1, , pn}, where p0 has minimum x coordinate, pn hasmaximum y coordinate A monotonic sequence of P from p0 to pn is defined to be aset of points Q1 satisfying:

1 For every 3 successive points pi−1, pi, pi+1 in Q1, xp i−1 < xp i < xp i+1 and yp i−1 <

ypi < ypi+1

2 No point of P between p0 and pn lies to the left of the polyline formed by Q1

3 The number of point in Q1 is maximum

If several vertices have the same x-coordinate, we throw all but the one with thelargest y-coordinate Condition 3 ensures the uniqueness of the monotonic sequence(Proposition 1.1) Fig.1.8(a) is a part of a spine, Fig.1.8 is not a part of a spine because

it does not satisfy conditon 3 The other 3 monotonic sequences Q2, Q3 and Q4 aredefined in the same manner

Proposition 1.1 Condition 3 for a monotonic sequence guarantees the uniquenessproperty

Trang 27

Proof We will proof by contradiction Let L1 and L2 be two monotonic sequencesfrom p0 to pn The number of vertices in L1 and L2 are the same and are maximum.Assume a contrary that L1 differs from L2 Hence, there exists p1∈ L1\L2.

If p1 lies to the left of the polyline formed by L2 then the 4 monotonic sequences

L2, Q2, Q3 and Q4 don’t cover all the vertices of P This is a contradiction

If p1 lies to the right of the polyline formed by L2 then there exists p2 ∈ L2\L1such that p2 lies the left of the path connecting L1 then the 4 monotonic sequences

L1, Q2, Q3 and Q4 don’t cover all the vertices of P This is a contradiction Therefore,L1 and L2 must be the same

Figure 1.8 Uniqueness of monotonic sequence.

The following algorithm generates the monotonic sequence Q1 in O(n log n) time if

we use an O(n log n) time sorting algorithm such as “quick sort” algorithm to sort P(see [23])

Algorithm 3 (Monotonic sequence)

Given: A set P = {p 0 , p 1 , , p n }, where x p0 = min{x p0, x p1, , x pn}, y pm = max{y p0, y p1, , y pn} Find: monotonic sequence Q 1 of P from p 0 to p m

1: Sort P by increasing x-coordinate.

Trang 28

Definition 1.6 ([16]) Let P = {p0, p1, , pn} and let Qi be a monotonic sequence of

P A spine of P extracting from Qi is defined to be a sequence of edges of two types:vertebrae and extenders These edges satisfy three conditions (see Fig 1.9):

1 The first edge is a vertebra, and each vertebra is followed by at most one extender

2 Each vertebra is rotated at least 18 · 2−Bs radians clockwise w.r.t the precedingvertebra

3 Each extender is rotated between −6 · 2−Bs radians and 24 · 2−Bs radians clockwisew.r.t the preceding vertebra, and it is rotated at most 6 · 2−Bs clockwise w.r.t thesucceeding vertebra

Figure 1.9 A part of a spine.

Algorithm for Determining Spines

Like the Graham algorithm for growing a convex hull, we “grow” a spine fromleft to right by removing vertices from a monotonic sequence At any point in thecomputation, we have a partially constructed spine followed by unprocessed edges([16])

Let p1p2 be the rightmost vertebra, and let p2p3 be the extender that follows it

If no extender follows it , then p2 = p3 (zero-length extender) Let p3p4 be the nextunprocessed edge (see Fig.1.10) RelativeSlopeCompare (p3p4, p1p2, κ) is true if theclockwise rotation of p3p4 with respect to p1p2 is greater than κ, as calculated using

Trang 29

Figure 1.10 Polygonal curve of vertebrae and extenders.

rounded arithmetic Recall that Section 1.5.2 describes how to compute lopeCompare Section 1.5.2 discusses the fact that RelativeSlopeCompare does notactually compute angles but that for the purposes of discussioon and proof of errorbound, one can assume it does

RelativeS-A If RelativeSlopeCompare(p3p4, p1p2, 21 · 2−Bs) = true, make p3p4 a vertebra

B If not, merge p3p4 with the extender p2p3 That is, throw away p3 if p3 6= p2.Vertex p4 changes its name to p3

C If RelativeSlopeCompare(p1p2, p2p3, 3·2−Bs) = true (newly created extender forms

a reflex angle with vertebra), throw away p2also Newly created edge p1p3is added

Condition 1 is easy to check Condition 2 is a consequence of rule A An edgebecomes a new vertebra only if its calculated rotation w.r.t the previous is at least

21 · 2−BS greater This implies that the actual angle is at least 18 · 2−BS greater The

24 · 2−BS bound in Condition 3 is a consequence of rule B An edge is merged withthe current extender if its rotation appears less than 21 · 2−BS This implies that theactual angle is no more than 24 · 2−BS If the extender satisfies this bound before wemerge the new edge, it will satisfy if afterwards

Rule C ensures that −6 · 2−BS bound holds in condition 3 For if it did not, then thecalculated angle of the extender w.r.t the vertebra would at least −3 · 2−BS, and rule Cwould delete it Finally, Rule A ensures that the 6 · 2−BS bound holds in condition 3.The calculated angle of the extender w.r.t the preceding vertebra is at least 21 · 2−BS

Trang 30

Both these computations can be off by 3 · 2−BS, and thus the total error is bounded

by 6 · 2−BS

Some Properties of Spines

Lemma 1.4 ([16]) Let p0 be a vertex which is the left endpoint of a vertebra, and let

L be the line through p0 rotated 6 · 2−Bs radians counter-clockwise with respect to thevertebra Every point of the spine to the right of p0 lies to the right of L (see Fig.1.11).Proof Condition 3 implies that the succeeding extender may be parallel to L at worst.Each subsequent vertebra is rotated at least 18 · 2−Bs clockwise with respect to the of

p0, and each subsequent extender is rotated at least 12 · 2−Bs

Figure 1.11 Points lies to the right of V0 and L.

Lemma 1.5 ([16]) Suppose we run the spine algorithm and at time s, p0 is the leftendpoint of a vertebra p0ps, and at some later time t, it is the left endpoint of a differentvertebra p0pt Then p0pt will be rotated counter-clockwise with respect to p0ps

Proof If suffices to assume that when p0ps was deleted, p0pt was the next vertebracreated However, this means that p0ptwas created from an unprocessed edge generated

by rule C This edge is rotated counter-clockwise from because ∠p0pspt is a reflexangle

Lemma 1.6 ([16]) Let p0p∗0 be any vertebra in the final result For all points p in P

to the right of p0, p0p is rotated at most 6 · 2−Bs counter-clockwise with respect to p0p∗0

In other words, p lies to the right of L in Fig.1.11

Proof Assume there is some p that violates this lemma When we first encounter p attime t, the point q will be the left endpoint of some vertebra Such a point q alwaysexists because of the existence of p0 (in the worst case, q and p0 are concide)

q is the left endpoint of some vertebra, perhaps not the same as the one in the finalresult However, if it is not the same, it will be rotated cockwise with respect to the

Trang 31

final vertebra, by Lemma 1.5 Furthermore, the rightmost vertebra qq1 at time t will

be rotated even more clockwise On the other hand, q lies to the right of L (Lemma1.4) and to the right of p0 Therefore qp will be rotated counter-clockwise with respect

to p0p As a sequence, angles q1qp will be greater than 6 · 2−Bs radians, and growthrule C will assure that q1 will be deleted Ultimately, all the vertices between p0 and

p will be deleted in the same fashion

If p∗0 lies between p0 and p then p∗0 would be deleted form the final result This is acontradiction

If p∗0 lies between p0 and p in the original monotonic sequence, we have xp ∗

0 > xp

and yp∗

0 > yp, then, p lies to the left of p0p∗0 Hence, p0p is rotated clockwise w.r.t p0p∗0,not counter-clockwise This is a contradiction

Lemma 1.7 ([16]) No point lies farther than 30µ outside the spine

Proof It suffice to prove this bound for all points p in the monotonic sequence Let

p1p2 and p2p3 be the vertebra-extender pair such that p appears somewhere in theoriginal monotonic sequence between p0 and p3 Lemma 1.6 implies p lies in a regiondepicted in Fig.1.12 Line L forms an angle of 6 · 2−Bs radians with respect to p1p2,and p2p3 form and angle of at most 24 · 2−Bs radians in the other direction (condition3) Therefore angle ∠p3p1p is bounded by 30 · 2−Bs radians The distance from p tothe spine is bounded by

δ(p, p1p3) < 30 · 2−Bs|p1p3|

< 30 · 2−Bs · ∆ = 30µThis completes the proof that the spine is a 30µ-hull

Figure 1.12 Region trimmed of by exact algorithm.

Trang 32

Proposition 1.2 All the deleted in step C is to the right of the spine with directionfrom left to right Therefore these points are not in CH(P).

Proof First we observe that all points deleted in step C are the right endpoint of avertebra (not the vertebra of the final result) Suppose at the first step of constructingthe spine p1p2 is the first vertebra Then p1 will never be deleted By Lemma 1.5,

at some later time t, p1pt is a different vertebra Then p1pt will be rotated clockwise w.r.t p1p2 Hence, p2 is to the right of p1pt

counter-If ptis not deleted in the final result, ptwill play the same role as p1before Clearly,

p2 is to the right p1pt and to the right the spine

If pt is deleted at some later time, say s, then pt is to the right of p1ps (by Lemma1.5) Consequently, p2 is also to the right p1ps Because the number of point is finite,this process occurs just finite times Therefore, p2 will lie to right of the spine

Corollary 1.1 Any point p lies outside the region bounded by the 4 spines is deleted

in rule B

Let p1p2 be a vertebra, p2p3 be an succeeding extender, and let p3p4 be the cessed edge Let β = θ(p3p4, p1p2), γ = θ(p2p3, p1p2)

unpro-Proposition 1.3 p3 lies to the right of p2p4 if and only if γ > β

Proof p3 lies to the right of p2p4is equivalent to p3p4 is rotated counter-clockwise w.r.t

Proposition 1.4 The output of Graham’s algorithm might be in error when workingwith real case but the output of using spine is a δ-hull

Proof Any floating point calculation might be in error, so does Graham’s algorithm(see Fig.1.13) If Graham’s algorithm is excecuted with real coordinate data, the outputmay be incorrect The Graham’s algorithm itself is correct but error in floating pointcalculation makes the output be incorrect In Fig.1.13 there are three non extremepoints appear in the output It had better use spines for constructing convex hull inreal case because coordinate sorting is better than angular sorting, monotonic sequences

Trang 33

Figure 1.13 Error in output of Graham’s algorithm in real case.

Figure 1.14 A convex 5.3 · 10−5 -hull.

are found correctly whereas simple polylines are not The 4 spines are found exactly,removing reflex angles gives a convex δ-hull Therefore, using spines for constructingconvex hull is much better In Fig.1.14 no point of P lies father than 5.3 · 10−5 fromthe hull

The example in Fig.1.13 and Fig.1.14 uses the following set of points

Trang 34

Table 1.2 Points given in Fig.1.13 and Fig.1.14.

Removing Reflex Angles

The spine may still have some reflex angles This section describes a simple processing stage which removes these angles without introducing much more error

post-If an extender might form a reflex angle with one of the neighboring vertebra (if thecalculated angle is less than 3 · 2−BS), we remove the appropriate endpoint Because ofthe large angle (at least 18 · 2−BS) between successive vertebra, we never remove bothendpoints of an extender Hence, removing potentially reflex angles trims off anotherregion of thickness at most 6µ and alters the orientation of the vertebra by at most

6 · 2−BS radians Since vertebra differ in orientation by at least 18 · 2−BS radians beforethe final trimming, they differ by at least 6 · 2−BS afterward, and thus all angles aremeasurebly convex Total error is 36µ Romoving reflex vertices only requires lineartime Therefore we have shown the following

Theorem 1.1 ([16]) Using floating point arithmetic with P -bit mantissa and roundingunit µ = 2−BS∆, one can construct a convex 36µ -hull of a set of points in O(n log n)time

As we have seen, the techniques of spine construction and trimming are successful

in two dimensions This is the first rounded arithmetic convex hull algorithm whichguarantees a convex output and which has error independent of n

Trang 35

Chapter 2

Delaunay Triangulations

The Delaunay triangulation associated with a finite set S of points in the plane

is a triangulation of the convex hull of S Delaunay triangulations have been used

in a number of domain, including pattern recognition, terrain modeling, and meshgeneration for the solution of partial different equations In this chapter, we disscussthe notion Delaunay triangulation, some properties of Delaunay triangulation, andfinally, describe methods for the construction of Delaunay triangulation

2.1.1 Definition of Delaunay Triangulations

Definition 2.1 (see [17], p.23) Let S be a closed subset of E2, Si be a closed subset

of S and ϕ = {S1, , Sn} (when we deal with an infinite n, we assume that onlyfinitely many Si hit a bounded subset of E2) If elements in the set ϕ satisfy

[Si\∂Si] ∩ [Sj\∂Sj] =∅, i 6= j, i, j ∈ In = {1, 2, , n}

and

[n i=1Si = S1∪ · · · ∪ Sn = Sthen we call the set ϕ a tessellation of S Specially, we call a tessellation in E2 a planartessellation of S

Figure 2.1 shows two planar tessellations The tessellation in panel (a) consists

of polygons with three or more vertices, whereas that in panel (b) consists of onlytriangles We call a planar tessellation like panel (b), i.e a tessellation in which Si in

ϕ is a triangle for all i ∈ In a triangulation of S

Assumption 1 (see [17], p.53) (the non-collinearity assumption) For a given set

P = {p1, , pm} of points, the points in P are not on the same line

Trang 36

Figure 2.1 Tessellation: (a) a tessellation that is not a triangulation; (b) a triangulation.

Note that the non-linearity assumption implicitly implies m>3, because two pointsare always on the same line

Definition 2.2 (see [17], p.55) Let P = {p1, p2, , pm} ⊂ E2 (36 m < ∞) and

pi6= pj for i 6= j, i, j ∈ Im := {1, 2, , m} that satisfies Assumption 1; let xi1, , xiki

be the location vector of the generator points whose circumcircle does not contain anyother point pj inside Let Ti be the 2-dimensional convex hull spanning generators

pi1, pi2, , piki

Ti= {x|x =Xki

j=1λjpij, where Xki

j=1λj = 1, λj >0, j ∈ Iki}Let

D(P ) = {T1, T2, , Tmv}

If ki= 3 for all i ∈ Imv, we call the set D(P ) the 2-dimensional Delaunay tessellation

or the Delaunay triangulation of the convex hull CH(P ) spanning P (see Fig.2.2)

Figure 2.2 Delaunay triangulation.

If there exists at least one ki > 4, we partition Ti having ki > 4 into ki − 2triangles by non-intersecting line segments joining the vertices, and denote the re-

Trang 37

sulting triangles by Ti1, , Tiki−2 (Tiki−2 = Ti1 = Ti for ki = 3) Let D(P ) ={T11, , T1k1−2, , Tmvkmv−2} We call the set D(P ) the Delaunay triangulation ofthe convex hull CH(P ) spanning P , a simplex in D(P ) is a Delaunay triangle, and anedge of a Delaunay triangulation is called a Delaunay edge In this thesis, we assumethat P contains no 4 points on a circle It should be noted that the problem of dealingwith degeneracies of P such as points with coincident xi coordinates, collinear andcoplanar points have not been entirely solved in this thesis.

2.1.2 Basic Properties of Delaunay Triangulations

Having defined a Delaunay triangulation in Section 2.1.1, we now wish to observetheir geometric properties We deal mainly with the properties of a planar Delaunaytriangulation, but some of them may be readily extended to an n-dimensional Delaunaytessellation We recall the following properties:

Property 1 (see [17], p.70) The external Delaunay edges in D(P ) constitute theboundary of the convex hull of P Thus the Delaunay triangulation spanning P is atriangulation of CH(P ) spanning P Since CH(P ) is bounded, all Delaunay trianglesand Delaunay edges are finite

Property 2 (see [17], p.74) All circumcircles of Delaunay triangles are empty circles.Note that the circumcircle of a Delaunay triangle is sometimes called a Delaunay circle.The notion of Delaunay circle can be extended in E3, and we call the circumsphere of

a Delaunay tetrahedron a Delaunay sphere

Property 3 (see [17], p.74) If there are 4 points of P on the same circle then theDelaunay triangle is not unique (see Fig.2.3) This assumption can be extended toassumption in En if we replace a circle with a hypershere and 4 with n + 2 In thiscase we may call the assumption the non-cosphericity assumption

Figure 2.3 Two Delaunay triangulations.

Property 4 (see [17], p.82) For the Delaunay triangulation D(P ) spanning a finiteset P of distinct points, which satisfies the non-cocircularity assumption, let ne be the

Trang 38

number of Delaunay edges, nt be the number of the triangles in D(P ) and nv be thenumber of the vertices on the boundary on CH(P ) The following equations hold:

Proof First since the Delaunay graph is a planar graph, Euler’s formula for planargraphs holds, i.e n - ne + (nt+ 1) = 2 Second, since every internal edge is shared bytwo Delaunay triangles and every external edge belongs to only one Delaunay triangle,the number of Delaunay edges is given by

ne = (3nt+ nv)/2Upon substituting this into n - ne+ (nt+1) = 2, we have the equalities 2.1 and 2.2.For a given finite set P if distinct points we have many possible triangulations

of CH(P ) spanning P In some applications we want to choose a triangulation inwhich triangles are as closely equiangular as possible One of the criteria is to choose

a triangulation in which the minimum angle in each triangle is as large as possible

To state this criterion more explicitly, let us consider an internal edge pi1pi2 in atriangulation T , and let 4pi1pi2pi3 and 4pi1pi2pi4 be triangles sharing the edge pi1pi2(see Fig.2.4 (a), (b)) The quadrangle pi1pi2pi3pi4 may be non-convex (see Fig.2.4 (a)),

or convex (see Fig.2.4(b)) If it is convex and it does not degenerate into a triangle (pi1

is on pi3pi4 or pi2 is on pi3pi4), we have another possible triangulation, i.e 4pi1pi3pi4and 4pi2pi3pi4 (see Fig2.4(c)) We are concerned with which triangulation is locallybetter (‘locally’ in the sense that a triangulation is made in a local area, i.e thequadrangle pi1pi2pi3pi4) In the triangulation in panel (b), the minimum angles amongthe six angles in 4pi1pi2pi3 and 4pi1pi2pi4 is ∠pi2pi1pi3 = α∗i In the triangulation

in panel (c), the minimum angle among the six angles in 4pi1pi3pi4 and 4pi2pi3pi4 is

∠pi2pi4pi3= βi∗ Comparing α∗i and βi∗, we notice that α∗i > βi∗ or α∗= max{α∗i, βi∗}

We may thus conclude that the triangulation in panel (b) is locally better than that inpanel (c) because the minimum angle is maximized in the triangulation in panel (b).This criterion may be written generally as follows

The local max-min angle criterion: (see [17], pp.87-88) For a triangulation

T of CH(P ) spanning P , let pi1pi2 be an internal edge in CH(P ), and 4pi1pi2pi3and 4pi1pi2pi4 be two triangles sharing the edge pi1pi2 For the convex quadrangle

pi1pi2pi3pi4 which does not degenerate into a triangle, let αij, j ∈ I6 := {1, 2, 3, 4, 5, 6},

be the six angles in 4pi1pi2pi3 and 4pi1pi2pi4; and βij, j ∈ I6, be the six angles in4pi1pi3pi4and 4pi2pi3pi4 If the quadrangle pi1pi2pi3pi4is non-convex or it degenerates

Ngày đăng: 08/11/2014, 11:18

Nguồn tham khảo

Tài liệu tham khảo Loại Chi tiết
[1] Aggarwal, A., Chazelle, B., Guibas, L., ´ O D´ unlaing, C., and Yap, C. (1988):“Parallel Computational Geometry”. Algorithmica, 3(3), pp. 293-327 Sách, tạp chí
Tiêu đề: Parallel Computational Geometry
Tác giả: Aggarwal, A., Chazelle, B., Guibas, L., ´ O D´ unlaing, C., and Yap, C
Năm: 1988
[2] An, P.T. (2010): “Method of orienting curves for determining the convex hull of a finite set of points in the plane”. Optimization, 59(2), pp. 175-179 Sách, tạp chí
Tiêu đề: Method of orienting curves for determining the convex hull ofa finite set of points in the plane
Tác giả: An, P.T
Năm: 2010
[3] An, P.T (2007): “A modification of Graham’s algorithm for determining the convex hull of a finite planar set”, Annales Mathematicae et Informaticae, 34, pp. 269-274 Sách, tạp chí
Tiêu đề: A modification of Graham’s algorithm for determining the convex hull of a finite planar set
Tác giả: An, P.T
Nhà XB: Annales Mathematicae et Informaticae
Năm: 2007
[4] An, P.T, Giang, D.T., and Hai, N.N. (2010): “Some computational aspects of geodesic convex sets in a simple polygon”. Numerical Functional Analysis and Optimization, 31(3), pp. 221-231 Sách, tạp chí
Tiêu đề: Some computational aspects ofgeodesic convex sets in a simple polygon
Tác giả: An, P.T, Giang, D.T., and Hai, N.N
Năm: 2010
[5] An, P.T. and Trang, L.H (2012): “A parallel algorithm based on convexity for the computing of Delaunay tessellation”. Numerical Algorithms, 59(3), pp. 347-357 Sách, tạp chí
Tiêu đề: A parallel algorithm based on convexity for thecomputing of Delaunay tessellation
Tác giả: An, P.T. and Trang, L.H
Năm: 2012
[6] An, P.T., Viet, D.V., and Giang, D.T. (2012): “Spines for constructing convex hulls in 2D and their applications”, in preparation Sách, tạp chí
Tiêu đề: Spines for constructing convexhulls in 2D and their applications
Tác giả: An, P.T., Viet, D.V., and Giang, D.T
Năm: 2012
[7] Aurenhammer, F. and Edelsbrunner, H. (1984): “An optimal algorithm for con- structing the weighted voronoi diagram in the plane”. Pattern Recognition, 17(2), pp. 251-257 Sách, tạp chí
Tiêu đề: An optimal algorithm for con-structing the weighted voronoi diagram in the plane
Tác giả: Aurenhammer, F. and Edelsbrunner, H
Năm: 1984
[8] Blelloch, G.E., Miller, G.L., Hardwick, J.C., and Talmor, D. (1999): “Design and implementation of a practical parallel Delaunay algorithm”. Algorithmica, 24 (3&amp; 4), pp. 243-269 Sách, tạp chí
Tiêu đề: Design andimplementation of a practical parallel Delaunay algorithm
Tác giả: Blelloch, G.E., Miller, G.L., Hardwick, J.C., and Talmor, D
Năm: 1999
[9] Brown, K.Q (1979): “Voronoi diagrams from convex hulls”. Information Process- ing Letters, 9(5), pp. 223-228 Sách, tạp chí
Tiêu đề: Voronoi diagrams from convex hulls
Tác giả: Brown, K.Q
Năm: 1979
[10] Center for High Performance Computing CPHC-HUS, Hanoi University of Science,“http://www.chpc.vnu.edu.vn” Sách, tạp chí
Tiêu đề: Center for High Performance Computing CPHC-HUS
Tác giả: Hanoi University of Science
[11] Cole, R., Goodrich, M.T., and ´ O D´ unlaing, C. (1990): “Merging free trees in parallel for efficient Voronoi Diagram Construction”. Languages and Programming, pp. 32-45 Sách, tạp chí
Tiêu đề: Merging free trees inparallel for efficient Voronoi Diagram Construction
Tác giả: Cole, R., Goodrich, M.T., and ´ O D´ unlaing, C
Năm: 1990
[12] Edelsbrunner, H. and Seide, R. (1986): “Voronoi diagrams and arrangments”.Discrete &amp; Computational Geometry, 1(1), pp. 25-44 Sách, tạp chí
Tiêu đề: Voronoi diagrams and arrangments
Tác giả: Edelsbrunner, H. and Seide, R
Năm: 1986
[13] Hisley, D. and Pollock, L. (2006): “Beginner’s Guide to MPI”. University of Delaware Sách, tạp chí
Tiêu đề: Beginner’s Guide to MPI
Tác giả: Hisley, D. and Pollock, L
Năm: 2006
[14] J´ aJ´ a, J. (1992): “Introduction to Parallel Algorithms”. Addison-Wesley, Reading Sách, tạp chí
Tiêu đề: Introduction to Parallel Algorithms
Tác giả: J´ aJ´ a, J
Năm: 1992
[15] Kirpatrick, D.G. and Seide, R. (1986): “The Ultimate Planar Convex Hull Algo- rithm?”. SIAM Journal on Computing, 15(1), pp. 287-299 Sách, tạp chí
Tiêu đề: The Ultimate Planar Convex Hull Algo-rithm
Tác giả: Kirpatrick, D.G. and Seide, R
Năm: 1986
[16] Li, Z. and Milenkovic, V. (1992): “Constructing Strongly Convex Hull Using Exact or Rounded Arithmetic”, Algorithmica, vol. 8, pp. 345-364 Sách, tạp chí
Tiêu đề: Constructing Strongly Convex Hull Using Exactor Rounded Arithmetic
Tác giả: Li, Z. and Milenkovic, V
Năm: 1992
[17] Okabe, A., Boots, B., and Sugihara, K. (1992): “Spatial Tessellations: Concepts and Applications of Voronoi Diagrams”, 1st edn. Wiley, New York Sách, tạp chí
Tiêu đề: Spatial Tessellations: Conceptsand Applications of Voronoi Diagrams
Tác giả: Okabe, A., Boots, B., and Sugihara, K
Năm: 1992
[18] O’Rourke, J. (1998): “Computational Geometry in C”, 2nd edn. Cambridge Uni- versity Press, Cambirdge Sách, tạp chí
Tiêu đề: Computational Geometry in C
Tác giả: O’Rourke, J
Năm: 1998
[19] O’Rourke, J. (1998): C code in the book “Computational Geometry in C”, 2nd edn, available from http://maven.smith.edu/∼orourke/books/ftp.html Sách, tạp chí
Tiêu đề: Computational Geometry in C
Tác giả: O’Rourke, J
Năm: 1998
[20] Preparata, F.P. and Shamos, M.I. (1988): “Computational Geometry - An Intro- duction”, 2nd edn. Springer, New York Sách, tạp chí
Tiêu đề: Computational Geometry - An Intro-duction
Tác giả: Preparata, F.P. and Shamos, M.I
Năm: 1988

TỪ KHÓA LIÊN QUAN

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

w