Dynamic Convex Hull for Simple Polygonal Chains in Constant Amortized Time Per Update
Total Page:16
File Type:pdf, Size:1020Kb
EuroCG 2015, Ljubljana, Slovenia, March 16{18, 2015 Dynamic Convex Hull for Simple Polygonal Chains in Constant Amortized Time per Update Norbert Bus∗ Lilian Buzer∗ Abstract Our contribution In this paper we give an on-line algorithm to construct the dynamic convex hull of a We present a new algorithm to construct a dynamic simple polygonal chain in the Euclidean plane sup- convex hull in the Euclidean plane, supporting inser- porting deletion of points from the back of the chain tion and deletion of points. Both operations require and insertion of points in the front of the chain. Both amortized constant time. At each step the vertices of operations require amortized constant time consid- the convex hull are accessible in constant time. The ering the real-RAM model. The main idea of the algorithm is on-line, does not require prior knowledge algorithm is to maintain two convex hulls, one for of all the points. The only assumptions are that the efficiently handling insertions and one for deletions. points have to be located on a simple polygonal chain These two hulls constitute the convex hull of the and that the insertions and deletions must be carried polygonal chain. out in the order induced by the polygonal chain. 2 Overview of our algorithm 1 Introduction Our algorithm works in phases. For a precise for- mulation let us first define some necessary notations. The convex hull of a set of n points in a Euclidean A polygonal chain S in the Euclidean plane, with space is the smallest convex set containing all the n vertices, is defined as an ordered list of vertices points. Constructing the convex hull of a point set S = (p1; p2; : : : ; pn) such that any two consecutive is a fundamental problem in computational geometry. vertices, pi and pi+1 are connected by a line segment. It has applications in, e.g., pattern recognition, image A polygonal chain is called simple when it is not self- processing and micro-magnetic analysis [2, 6]. Many intersecting. For simplicity, we assume that the points problems can be reduced to determining the convex are in general position. Our algorithm handles inser- hull of a point set, such as Delaunay triangulation tion and deletion of points into the current convex hull and half space intersection [5]. Therefore developing in the order induced by S. This results in the fact that the current convex hull always contains a contiguous robust and efficient algorithms for the core problem j has received much attention. If one considers the real- subchain of S, let us denote it by Si = (pi; ··· ; pj) and the points are effectively inserted/deleted in a RAM model, an optimal output sensitive algorithm j FIFO manner. Let us denote the convex hull of Si to construct the convex hull of n points in a plane j j was published in [7] having O(n log h) time complexity with Ci . Therefore, given a convex hull Ci , inserting j+1 where h is the output size. If the point set is a simple a point results in Ci while removing the first point j polygonal chain, the best algorithm, a result of Melk- results in Ci+1. man, runs in linear time [1]. If one requires the data At the beginning of each phase, we initialize a sim- structure to be dynamic, namely to handle insertions ple data structure called the phase convex hull that and deletions of arbitrary points an optimal algorithm maintains the representation of the convex hull of a requiring O(log n) time for both operations was pro- subrange of the polygonal chain. Each phase handles posed in [3]. Changing the computational model to an arbitrary number of insertions and handles deleting the word-RAM model and using Graham's scan [8] to the points that were present when the phase started. b construct a convex hull the running time is essentially Assuming that the phase convex hull first covered Sa the time to sort the points, taking, e.g., O(n log log n) this means we can delete the points pa : : : pb. A phase time [9]. Dynamic data structures supporting dele- ends, when we first delete a point that was not cov- tion and insertion in the word-RAM model require an ered by the initial convex hull. After that, a new phase log n optimal O( log log n ) time for both operations assuming starts and we initialize a new phase convex hull. See that word length is Θ(log n), see [4]. Figure 1. We state the main result of our algorithm in Theo- rem 1. ∗Universit´eParis-Est, LIGM, A3SI-ESIEE, France, fbusn, [email protected] This is an extended abstract of a presentation given at EuroCG 2015. It has been made public for the benefit of the community and should be considered a preprint rather than a formally reviewed paper. Thus, this work is expected to appear in a conference with formal proceedings and/or in a journal. 31st European Workshop on Computational Geometry, 2015 b b+1 c c c d data structure used in the Melkman algorithm. At Ca ! Ca !···! Cb −! Cb+1 ! Cb+2 !···! Cc ∗ b the beginning of the phase C is built for Sa using b c phase starting with Sa phase starting with Sb+1 the Melkman algorithm. initialize new deque phase convex hull Figure 1: Example of two phases pb pj pj−1 p Theorem 1 The amortized time complexity of inser- i tion and deletion of points in a convex hull of a simple polygonal chain is constant. Figure 2: The two dequeues (blue and yellow) consti- tuting C∗. For clarity we include one schematically. Proof. Assume that each point has been inserted and + − later removed. In Section 6 we show that the i − th In green and red we depict C and C respectively. phase runs in O(ki + li) time where ki is the num- ber of insertions in the phase and l is the number i The following data structures aid to handle inser- of deletions. During the whole algorithm each point tion or more importantly deletion of points (since the has been inserted and deleted exactly once hence there phase convex hull itself could handle insertions). have been n insertions and n deletions overall. There- fore the overall running time of the phases is O(n), Incremental convex hull The incremental convex yielding the desired result. hull is a convex hull incrementally built with the Melkman algorithm for the points in the polygonal 3 Convex hulls chain added after the initialization of the phase. Let + j + In this section we introduce the phase convex hull us denote it by C . At any step Si , formally, C is j representing the convex hull of the polygonal chain. the same as Cb+1. Furthermore, we describe two convex hulls that are maintained during the phase. These two hulls' pur- Decremental convex hull The decremental convex pose is to enable that insertion and deletion of points hull is a convex hull built with the Melkman algo- for the phase convex hull run in constant amortized rithm for the points present at the beginning of the time. We suggest that the reader is familiar with the phase but according to the reverse order of the points. Melkman algorithm [1] as our method builds heavily Let us denote it by C−. At each deletion a point is − j − on it. Briefly, the method builds the convex hull of removed from C . At any step Si , formally, C is i a polygonal chain by iteratively (in the proper order) the convex hull of the points Sb (note the reverse or- adding the points to the convex hull and modifying der). This data structure has to maintain additional b it as necessary. At the beginning of the phase let Sa information that will be used for efficient deletion of − a be the current polygonal chain while at the end let it points. First, while creating C , for each point in Sb , c j be Sb . Let us denote by Si the polygonal chain at the list of points that were removed from the previous j an arbitrary step during the phase and Ci the corre- convex hull should be kept. Let us call these points sponding convex hull. the history of a point. This enables that the algo- rithm can be `rewound', i.e, the points of C− can be − Phase convex hull The phase convex hull denoted deleted in a FILO order. As C was built in the re- by C∗ is the data structure representing the convex verse order this is exactly the deletion order we need. j Second, the polygonal regions defined by CjnCj for hull Ci , containing all of its points in two dequeues. k k+1 Every point is contained in exactly one of the two de- a ≤ k ≤ b, in other words the difference between con- queues except for two: the front of both dequeues refer secutive convex hulls in the Melkman algorithm for − to the same point of the subchain, the one contained building C , have to be kept. At the beginnning of in Cj with highest index and similarly, the back of each phase we build the decremental convex hull for i a both dequeues refer to the same point of the subchain, Sb . In Figure 3 we show the regions where the red j b polygonal chain is Sa. The green line corresponds to the one contained in Ci with lowest index. We refer to the front of both dequeues as front opening and to the the polygonal chain of the points inserted during the back as back opening.