A cgal-based implementation for the Voronoi diagram of ellipses Ioannis Z. Emiris University of Athens, Greece
Elias P. Tsigaridas INRIA Sophia-Antipolis, France
[email protected]
[email protected]
George M. Tzoumas University of Athens, Greece
[email protected]
December 3, 2007
Abstract We present a C++ open-source implementation of an incremental algorithm for the computation of the Voronoi diagram of ellipses in the Euclidean plane. This is the first complete implementation, under the exact computation paradigm, for the given problem. It is based on the cgal package for the Apollonius diagram in the plane: exploiting the generic programming principle, our main additions concern the predicates. The ellipses are input in parametric representation, which allows us to develop a GUI for input and output. The software concerns non-intersecting ellipses, but the extension to the general case is possible. We develop practical algebraic methods, including an interval Newton solver, bivariate polynomial interpolation, and trivariate system resultant computation, and exploit the factorization of resultants in order to arrive at an efficient and exact C++ implementation of InCircle . The code is up to two orders of magnitude slower than the cgal Apollonius package on circles, which comes as no surprise. We also test different sets of ellipses; as a ballmark estimate, the current version spends about a second to insert a new ellipse, when few degeneracies occur. The software is connected to algebraic library synaps and, through it, to libraries mpfr and ntl, hence illustrating the concept of algebraic support for geometric computing; it is targeted for inclusion in the cgal library. Keywords: Voronoi diagram, ellipse, cgal implementation, exact computation, parametric representation
1
Introduction
This paper discusses our implementation of an algorithm for the Euclidean Voronoi diagram of ellipses, in the exact computation paradigm. cf. fig. 1. Applications in motion planning and visibility should benefit from this diagram, given the ability of ellipses to model rather accurately a large class of obstacles. Other applications involve the computation of the medial axis or the skeleton of objects, which is used in pattern recognition and feature extraction. The distance of an exterior point to an ellipse is defined to be the minimum Euclidean distance to any point of the ellipse. The algorithm may simply compute the dual Delaunay graph, since no computation of Voronoi vertices or edges is required. This is the first complete solution of how to implement the Voronoi diagram (and Delaunay graph) of ellipses under the exact computation paradigm and, probably, one of the hardest problems tackled in nonlinear computational geometry, because of the complexity of the algebraic operations involved. In particular, the real algebraic numbers involved in the InCircle predicate are of degree 184. We implement the incremental algorithm of [28], based on the cgal library1 . Insertion of a new ellipse to the current Voronoi diagram consists of the following: (i) Find a conflict between an edge of the current diagram and the new ellipse, or detect that the latter is internal (hidden) in another ellipse, in which case it does not affect the diagram. (ii) Find the entire conflict region of the new ellipse and repair the dual Delaunay graph. We focus on non-intersecting ellipses, given parametrically or, equivalently, constructively in terms of their axes, center and rotation angle, which are all rational. Our code is based on the cgal package for the Apollonius (or Voronoi) diagram of circles [13], which uses the same incremental algorithm as we do. cgal follows the generic programming paradigm, hence the main issue was to analyze and implement all 4 predicates for ellipses.
1.1
Previous work
The theoretical foundations of our approach were laid in [17, 16], where algorithms for the first two predicates were designed, optimal in terms of algebraic degree. Their implementation in C++ ran in milliseconds, which is satisfactory and, therefore, integrated in the present implementation. That paper established a tight bound of 184 on the number of complex tritangent circles to three ellipses; the number of real circles remains open. An exact solution to InCircle was implemented on Maple; the latter offers certain very efficient routines, such as symbolic resultant computation. The fourth predicate was reduced to a small number of calls to the other predicates. A certified iterative subdivision algorithm with quadratic convergence was proposed in [19] for answering the InCircle predicate fast in non-degenerate instances. It was implemented using the alias [?] library of interval arithmetic. Voronoi diagrams have been studied extensively, however the bulk of the existing work in the plane concerns point or linear sites. Related to the Voronoi diagram is the Power diagram [9, sec.2.3.3], which simplifies the predicates, but changes the distance function. An extension of this diagram to ellipses should lead to a simpler algorithm, but would solve a different problem. We use the Euclidean distance as a more natural metric. Certain efforts have extended Voronoi diagrams to the case where the sites are curves (e.g. [1, 4]) or have non-empty interior [8]. In [25] an optimal combinatorial algorithm is derived for Voronoi diagrams of strictly convex rounded sites in R3 , but the predicates are not considered. Anton [2] examines the InCircle predicate for the diagram of ellipses but his algebraic system has high complexity. His matrix methods for solving InCircle are impractical or do not guarantee exactness; resorting to interval arithmetic led to runtimes of about 2 minutes. We have already referred to the cgal Apollonius package for the diagram of circles [13]; for this problem, see also [3, 29]. 1
www.cgal.org
1
Figure 1: The Voronoi diagram of ellipses. Shown is also the dual Delaunay graph; some Delaunay edges pass outside the window.
A very related problem concerns visibility among circles and ellipses. In [22], the second predicate needed for the Voronoi diagram of ellipses is solved in a different way than ours. We compare it to our solution in [17, 16]. Exact computation on curves and surfaces has been considered in problems including Voronoi diagrams, arrangements, and lower envelopes, see [9] and more recent advances e.g. [5, 20]. These methods, though efficient in their contexts, do not apply to our problem. One exception is the lower envelope construction of [23], thanks to its generality; however, this approach is slow if used to construct the Voronoi diagram of ellipses. A different line of work is to approximate the curved sites by polygons, e.g. [7]. A notable implementation is VRONI [26]: it reads in circular arcs, which are approximated by line segments, then the segment diagram is computed, so as to arrive at an approximate Voronoi diagram of the input. The approach of [24] traces the bisectors in order to compute Voronoi cells of arbitrary B´ezier or B-spline curves up to machine precision. The algorithm uses floating point arithmetic and the implementation, as part of the irit2 software, has runtimes ranging “from a few seconds to a few minutes” for computing one Voronoi cell, on a 1.8 GHz Pentium 4 with 256MB RAM. The algorithm runs with any prescribed precision, but does not comply with the exact computation paradigm; for instance, it does not handle (near-)degenerate configurations. The subdivision-based methods in [11] find all solutions to the InCircle predicate on circles in about 12 sec. In section 3.1, we examine general-purpose algebraic software and show that it performs poorly on our predicates, when compared to our adapted methods. 2
www.cs.technion.ac.il/˜irit/
2
1.2
Our contribution
Our main contribution is the first implementation for the exact Voronoi diagram of ellipses, including a Graphical User Interface (GUI) for input, and visualization tools that can be used for any parametric curve. Our methods generalize to intersecting ellipses and pseudo-circles, but also to arbitrary closed smooth parametric curves [18]. They can also compute an approximate Voronoi diagram of ellipses, with any predetermined precision. We implement certain algebraic methods in C++ to support InCircle , thus improving upon previous implementations, and the use of general algebraic software as black boxes. Our algebraic methods use, in specific ways, the algebraic library synaps3 and, through this software, library mpfr4 , and ntl5 . We thus illustrate the concept of providing algebraic support to a geometric computing library such as cgal. Lastly, we report on experiments when we vary the number of ellipses, their bitsize, and the degeneracy of their configuration. We also test our code on sets of circles, which allows us to compare it against the Apollonius package; our software is one to two orders of magnitude slower, which is to be expected because of the adapted methods employed for circles. The paper is organized as follows. The next section defines the parametric representation of ellipses. In section 3, the InCircle predicate is studied, and the exact method for its solution is revisited, in order to arrive at an efficient implementation. The overall implementation appears in section 4, whereas experiments are discussed in section 5. We conclude with further work in section 6. The appendix contains the proof of the algebraic lemma.
2
Parametric Representation
We assume that an ellipse is given in rational parametric form. It is more intuitive for a GUI to offer constructive input rather than require the coefficients of the implicit form. The parametric approach is suitable for following the boundary of an ellipse, which is crucial for the subdivision algorithm for InCircle . Moreover, given the parametric form it is always possible to derive the implicit one using only rational arithmetic. The opposite is not always possible. The parametric representation of an ellipse is 1 − t2 2t 2w 1 − w2 − β , x(t) = xc + α 1 + w2 1 + t2 1 + w2 1 + t2 2w 1 − t2 1 − w2 2t y(t) = yc + α +β , 1 + w2 1 + t2 1 + w2 1 + t2 where 2α, 2β are the lengths of the major and minor axes, respectively, t = tan(θ/2) ∈ (−∞, ∞), θ is the angle that traces the ellipse, w = tan(ω/2), ω is the rotation angle between the major and horizontal axes and (xc , yc ) is its center. This representation leaves out of the boundary a single point, called the i-point. These points at infinity have to be dealt with separately. The symmetric ellipse (with respect to its center) is x ¯(t) = x(−1/t) and y¯(t) = y(−1/t) Every point of an ellipse is different from its symmetric point. Considering the symmetric points allows as to work with arcs that contain the i-point. 3
synaps.inria.fr/ www.mpfr.org/ 5 www.shoup.net/ntl/ 4
3
3
The InCircle predicate
We focus on the implementation of InCircle , which is clearly the most challenging predicate and the only one that had not been satisfactorily implemented in C++. We refer to the two different systems used in the subdivision algorithm of [19] and in the exact approach for solving InCircle . We focus on the latter and describe certain advances which make this algorithm into an efficient C++ implementation. We also mention other existing software that might implement the algebraic operations, and discuss our implementations as well as the connection to algebraic software libraries. Given ellipses Et , Er , Es , we wish to determine the relative position of ellipse Eh with respect to the Voronoi circle of the first three. The result of InCircle is whether Eh is outside, intersects the open Voronoi disk, or is externally tangent to the Voronoi circle of Et , Er , Es . In order to decide InCircle , we need to represent the Voronoi circle suitably. In [17, 16], we proved that there can be 184 complex tritangent circles to three ellipses, hence this is the degree of the algebraic numbers involved in an algebraic approach. The corresponding algebraic system is very costly to solve, see [17, 16], therefore we take a different tack. First, we apply the certified subdivision solver of [19] and, if the predicate cannot be decided, we solve system (4) below. This happens at (near)degenerate configurations, where any fixed precision may not suffice. The bisector of two ellipses is the locus of points at equal distance from the two ellipses. Given are ellipses Et , Er parametrized by t, r; a point (x(t), y(t)) on Et , defined by parameter value t, will be referred to as point t, or t ∈ Et . Now take points P, Q on Et , Er : the bisector contains the −−→ −−→ intersection point V of the normal lines at the ellipses, at P , Q, when |P V | = |QV |. This expresses all points on the bisector except for a finite number of them, namely where the two normals are parallel. In this case, the bisector point is the median of segment P Q. The implicit equation of a normal at point t is: x0 (t)x + y 0 (t)y − x0 (t)x(t) − y 0 (t)y(t) = 0
(1)
Point V , with coordinates v1 (t, r), v2 (t, r), is the solution of a linear system of two equations of the form (1), expressing the normals respectively at points t and r. The condition of V (v1 , v2 ) being equidistant from P and Q is (v1 − x(t))2 + (v2 − y(t))2 − (v1 − x(r))2 − (v2 − y(r))2 = 0, which simplifies to 2 x(r) − x(t) v1 + 2 y(r) − y(t) v2 + x(t)2 + y(t)2 − x(r)2 − y(r)2 = 0 (2) which is linear in v1 , v2 expressing the bisector (line) of segment P Q. Now we have 3 linear equations in v1 , v2 which are feasible iff the determinant of its augmented matrix vanishes. This yields, after eliminating nonzero factors of (1 + t2 ) and (1 + r2 ), a bivariate polynomial B(t, r) of degree 6 in t and 6 in r. This degree is optimal because, given two ellipses and a point on the first, there exist up to 6 real bitangent circles, tangent at the specific point. We express the Voronoi circle by considering the intersection of three bisectors, namely the system: B1 (t, r) = B2 (r, s) = B3 (s, t) = 0. (3) This system is used in [19] for the subdivision algorithm with quadratic convergence. It has a mixed volume of 432: mixed volume bounds the number of common affine roots (see [10] for background on mixed volume). The bound of 432 is loose, compared to the optimal bound of 184. Moreover, experiments showed that it is very expensive to compute its resultant in order to use it for exact solving, due to the degrees of the Bi ’s.
3.1
Revisiting the exact method
In [17, 16], we proposed an exact approach for InCircle . We describe the steps required to make this algorithm into an efficient C++ program, since our original implementation had relied on Maple 4
for certain efficient operations. One conclusion is that, instead of carrying out all computation in parametric space or with implicit equations, the method of choice is to use algebraic equations in terms of the parameters, as in systems (3) and (4). We employ resultants, which expresses the solvability of a system of n+1 equations in n variables, as a condition on the coefficients. After one or more applications of resultants, we arrive at a univariate resultant whose roots are the projections of the system’s roots to one coordinate. In the case of InCircle , we obtain a univariate polynomial of degree 184. Here, it suffices to consider the case n = 1, sometimes named after Sylvester, where one variable is eliminated from two equations, and the resultant is a polynomial in the remaining variables. This resultant is expressed as the determinant of the Sylvester matrix. For the required notions from computer algebra, see [10, 35]. We shall use the following alternative polynomial system: Q(t, r, s) = B1 (t, r) = B3 (s, t) = 0.
(4)
Here, Q is the condition that makes the three normals of each ellipse intersect at a single point. Q is a polynomial of total degree 12, four in each variable t, r, s. This system has a mixed volume of 432 like system (3) but, nonetheless, it shall lead to an efficient way of computing the actual resultant. By exploiting the fact that not all variables appear in all equations, we compute the system’s resultant via two Sylvester resultants. The resultant that eliminates s from two polynomials is denoted by ress . R1 (t, r) = ress (Q(t, r, s), B3 (s, t)) = (at28 r24 + · · · )(b12 t12 + · · · + b1 t + b0 )(1 + t2 )4 , {z } | R10
R2 (t) = resr (R10 (t, r), B1 (t, r)) = (a184 t184 + · · · + a1 t + a0 )(c12 t12 + · · · + c1 t + c0 )6 (1 + t2 )28 .
(5)
Lemma 3.1 The factorization of R1 (t, r), given in expression (5), is always true. The shown factors of R2 (t) are always present; if they appear at the indicated powers, then expression (5) gives the full factorization of R2 (t). The proof is in the appendix. The second factor in each factorization is a degree-12 univariate polynomial that corresponds to the condition that the normals to two ellipses are parallel Also, the last factor in each factorization has no real roots. We have no complete proof for the exponents of the extraneous factors in R2 (t). Still, the shown exponents are confirmed by every example we have tried. In practice, we divide out these factors until we obtain the resultant with the optimal degree, namely 184. The above lemma and discussion allow us to exploit the fact that both Sylvester determinants are factored. The factors which have no real roots, or whose roots correspond to the normals being colinear (which is a case handled apart), are divided out. Hence, our approach reduces to solving a univariate polynomial over the reals and comparing real algebraic numbers; the latter may require a univariate GCD computation to identify the case of common roots. In the rest of this section we show that state-of-the-art general solvers are slow on InCircle , compared to our adapted solutions. We recall some experiments; most have appeared in one of [17, 16, 19]. They are run on a Pentium-4 with a 2.6 GHz CPU, with 1GB of RAM, using a 2.6.10 Debian Linux kernel: For non-degenerate configurations, PHCpack6 implements homotopies and took about one minute to solve the system. The iCOs interval-arithmetic solver7 took up to 4 minutes depending 6 7
www.math.uic.edu/∼jan/PHCpack/ www-sop.inria.fr/coprin/ylebbah/icos/
5
on how large the initial domain was. The alias built-in gradient-based methods converge within a few seconds, depending on the initial domain. We solved system (3) with a subdivision solver from synaps in up to one minute, depending on the initial domain. The certified subdivision of [19] exploits several geometric properties of the problem, and allows us to decide InCircle before full precision has been reached. The algorithm approximates Voronoi circle’s tangency points with precision up to 10−15 in up to 100 msec, when using standard floating-point arithmetic. For an exact solution, we tried different software. With some preliminary experiments [30] Gr¨obner bases isolate all real roots in about two minutes with GB-Rs8 . The Kronecker solver [21] took about 30 minutes. The algebraic methods in [17, 16] were in the range of a few seconds, but relied on certain fast routines in Maple, such as symbolic resultant computations. Here, we improve upon the respective algebraic techniques and implement them in C++, thus achieving runtimes of up to 15 sec. To the best of our knowledge, there is no C++ implementation capable of computing efficiently the resultant that appears in InCircle .
4
Implementation
This section starts with some new algebraic implementations, including determinant interpolation, symbolic resultants, and an interval Newton iteration, used for InCircle . We then describe the connections to algebraic libraries, and conclude with the overall implementation. Our code is accessible at http://www.di.uoa.gr/~geotz/vorell/. For the implementation of the required algebraic operations, we have relied on algebraic library synaps and, to be more precise, to library Mathemagix9 . This is an open source, modular library, which now integrates the main functionality of synaps. First, we implemented Newton’s iteration with interval arithmetic as part of the subdivix package of Mathemagix (or synaps). This is important for the numerical iterative algorithm for InCircle . The interval and floating-point types, and the associated arithmetic operations, are implemented in library mpfr which is connected to synaps, and, hence, available to our algorithms. In order to solve the degree-184 univariate polynomials for InCircle , we use the fast implementation of Continued Fractions [33], available in synaps. Our implementation is comparable and, in most cases, faster than state-of-the-art exact univariate solvers such as Rs, but also numeric solvers such as mpsolve10 . The algorithm isolates all real roots in rational intervals, which also allows us to compare roots from different resultants. We implemented bivariate and univariate polynomial interpolation in synaps, c.f. e.g. [35, 34], in order to compute the resultant of the system of bisectors, refer to eq. (5). This is essentially a Chinese remaindering algorithm in the ring of polynomials, where the moduli are values of the polynomial and the output are its coefficients. After computing the numeric Sylvester determinants by ntl (see below), we use lemma 3.1 to divide out the values of the factors described in this lemma. Therefore, the number of moduli does not depend on the total degree of the determinant but rather on the total degree of the factor of interest, considered as a univariate or bivariate polynomial. When two roots are equal, we compute the GCD of the defining polynomials. For this, we use ntl which is, to the best of our knowledge, the only open source C++ library that provides efficient implementation of asymptotically fast algorithms for polynomial GCD’s and univariate Sylvester-resultant computation. We developed an interface between ntl and synaps. The interface eliminates the need for unnecessary copies, and allows us to work directly with ntl objects in synaps (and vice versa). We take advantage of the fact that integer arithmetic in ntl can be based on gmp, and we build a wrapper around these objects. 8
fgbrs.lip6.fr/salsa/Software/index.php www.mathemagix.org/ 10 www.dm.unipi.it/cluster-pages/mpsolve/ 9
6
In short, it suffices to develop a connection to synaps, through which we develop connections to the other software. In fact, synaps is proposing an algebraic kernel compatible with the specifications of such a kernel adopted by cgal. Our aim is that the implementation of predicates is independent from any specific algebraic library, so as to make it possible to use different such libraries. The concept of an Algebraic kernel for the Voronoi diagram of ellipses is quite demanding. It requires, just to name the most important operations, symbolic univariate polynomial resultant and GCD computations, real root isolation and comparison of real algebraic number and computation of the resultant of a trivariate polynomial system. For a detailed presentation of the concept of the Algebraic kernel, the reader may refer to [6]. An example of a model of such a kernel is the following, actually corresponding to the synaps model of algebraic kernel, augmented with our ntl interface. typedef AK_Ring AK; typedef AK::Coefficient NT; // Number Type typedef AK::AlgebraicRealSet_1 RootSet; typedef AK::Polynomial_1 Poly; ... Poly f ("x^184 - 2*x^12 - 3"); RootSet sol = AK:Solve_1( f, CF()); In connecting to algebraic software, it was important to separate the geometric from the algebraic operations. This work is in line with the concept of kernels, adopted by cgal, where different types of operations are grouped into separate modules. This is in the spirit of [12], where the concept of an algebraic kernel that supports the implementation of the predicates is described. In implementing the algebraic kernel functionality, our work can be seen as a continuation of [12]. For the combinatorial part of the algorithm, we relied on cgal. cgal follows the generic programming paradigm, hence the main issue is to implement the 4 predicates for ellipses and generalize circular sites to ellipses. We are based on the Apollonius graph 2 package. Besides the predicates, the most important class is the Apollonius site 2, which represents the sites of the Voronoi diagram; in our case the ellipses. We modified the corresponding class so that to inherit from our Ellipse class. A snapshot of the corresponding code is as follows: template < class K > class Apollonius_site_2: public Ellipse { public: typedef K Kernel; typedef typename K::Point_2 Point_2; typedef Apollonius_site_2 Self; typedef typename K::FT FT; // Field Number Type typedef typename K::RT RT; // Ring Number Type .... };
5 5.1
Experiments Against the CGAL Apollonius package
We performed experiments per predicate, when the input is restricted to circles, against the cgal Apollonius package. We used three data sets, each containing 500 instances; the sets are explained
7
below. The results of these experiments are on table 2 (appendix). These experiments were carried out on a machine with a 1.83GHz Core 2 Duo processor and 1GB RAM. The fourth predicate is not compared because its implementation in the Apollonius package is specifically adapted to circles. For the case of ellipses we have not optimized this predicate, however it uses the same subpredicates as in the case of circles. The dominant operation is deciding the order of the tangency points of two Voronoi circles, therefore having to compare algebraic numbers of degree 184. Thus, this predicate also benefits from the subdivision-based approach. The first predicate (κ1 ) decides which of two given circles is closer to a given point. In the case of the Apollonius diagram, the predicate is implemented by simply comparing the distances between the point and the two centers. The instances were as follows: 1. Two circles with centers (−2, 0) and (2, 0), both of radius 1; we compute the closest circle to a point “moving” from (0, −100) to (100, 0), with step 1/2. 2. The same as (1), but we perturb randomly all points by (a) 1/102 , (b) 1/104 and (c) 1/106 . 3. In [−10, 10] × [−10, 10], choose uniformly 2 random circles of radii ∈ [0, 2], and one point. The second predicate (κ2 ) decides the position of a query ellipse with respect to one of the common tangents to two given ellipses. The inputs are as follows: 1. Two circles, with centers at (−2, 0) and at (2, 0), both of radius 1, and a query circle with center “running” from (0, −100) to (100, 0), with step 1/2. 2. The same as (1), but we perturb randomly all points by (a) 1/102 , (b) 1/104 , and (c) 1/106 . 3. In [−10, 10] × [−10, 10], we choose uniformly three random circles of radii in [0, 2]. In the case of the Apollonius diagram, InCircle is implemented by an adapted algorithm, using inversion. The instances for InCircle are: 1. Three circles, with centers at (−3, 0), (3/2, 0) and (0, −2), and radii 2, 1/2 and 1, respectively. The query circle has radius 1 and center at (0, y), where 1 ≤ y ≤ 50, step = 1/8. 2. The same as (1), but we perturb randomly all circles by (a) 1/102 , (b) 1/104 and (c) 1/106 . 3. In [−10, 10] × [−10, 10], we choose uniformly four random circles with radii in [1/3, 5/2]. Degenerate inputs are the sets (1), near degenerate are in (2), while (3) represents random inputs. In most cases, degenerate inputs are solved faster than near-degenerate ones because the former, from the algebraic point of view, imply lower degree algebraic numbers. This is not the case for the subdivision-based algorithm, since in the degenerate cases it has to use large precision in order to make a decision. Another interesting observation is that runtime increases linearly in the bitsize, especially with perturbed input, i.e. data (2). This is because we implemented algorithms of constant arithmetic time complexity, which do not depend on how close to degeneracy the configuration lies, but bit complexity depends of course on bitsize. Notice also that both implementation behave almost identically on dataset (1) and (2a), since bitsize is the same, and neither approach depends on separation bounds. This is an inherent feature of specialized algebraic algorithms that do not depend on separation bounds. It seems, from table 2, that our current implementation of the predicates for ellipses is up to two orders of magnitude slower that the dedicated one, when we restrict to circles. The worst relative performance is observed, expectedly, for InCircle , which is the most expensive predicate and, in the case of circles, has been optimized. The best relative performance occurs for κ2 , because the 8
two approaches follow similar algorithms. The difference of performance is not surprising, since the case of circles reduces to computations with real algebraic numbers of degree 2 and the Apollonius predicates are specifically designed to exploit this. In the current implementation, this is recognized in running time only. Since the runtime of the predicates on the circles is relatively small, the overhead of recognizing this special case in our implementation is significant. For example, our implementation is designed for handling algebraic numbers of degree 4 in constant time. Such numbers are ubiquitous with ellipses, and suffice for treating κ1 , κ2 . In the case of circles, the algebraic numbers are of degree 2 so we should free the extra space allocated because we were expecting degree-4 polynomials. Moreover, for most algebraic operations we test the degree and call the appropriate (sub-)algorithm, while in the Apollonius package the degree is known to be two. These are costly steps, because they lie in the inner loop of the algorithm. We may conclude that specialized implementations for predicates involving small degree algebraic numbers, combined with algorithms exploiting the geometric characteristics of the problem, are more efficient than generic approaches.
5.2
Other experiments
In this subsection we present results regarding elliptic sites. These experiments have been carried out on a P4 2.6-Ghz machine with 1.5GB of RAM. Firstly, we consider the overall time for the construction of the combinatorial structure of the dual (Delaunay) graph. While the first few sites are inserted almost instantly, subsequent ones cause many updates on the graph and require about a second for their insertion. Total timings are shown in the first two columns of table 1. The runtime increases roughly linearly with 15 sites or more. This is in accordance with theoretical bounds, although larger instances shall have to be tested to verify this. We have measured the performance of the first three predicates with varying bitsize. The subsequent columns of the table present the timings on a set of ellipses with randomly perturbed coefficients by either adding or subtracting 10−e , with varying e; this leads to large rational numbers. All runtimes appear to grow subquadratically in e. Note that for InCircle , the subdivision algorithm was used, since the situation was non-degenerate. In case of degeneracies, the runtime of InCircle is dominated by the resultant computation, presented in the following column. Note that the resultant computation is over 50 times slower than the time required by the subdivision algorithm. Finally, we measured time needed for the subdivision algorithm to reach a precision of 2−b when using mpfr floats. This version currently lacks some optimizations making it about 2 times slower than the one in [19] using alias. Note that standard floating-point precision is achieved in about 0.2s, while 1 second suffices for almost 2000 bits of precision. However, higher approximations slow down considerably, such the 24k-bit approximation that needs about half a minute. This raises some questions on whether the theoretical separation bound of several million bits can be achieved in practice by an implementation.
6
Further work
We aim at submitting the optimized version of our software to the cgal library. For this, we plan to apply geometric filters, extending the work for circles e.g. [31]. Another issue is to apply the cgal filtered type Lazy exact nt, mainly for the last two predicates. For κ1 , κ2 , we used this type in [17, 16] with no significant improvement, because the involved quantities are large and the filter almost always failed.
9
# sites 5 10 15 20 25
insertion 0.752 5.916 13.000 19.200 25.602
e 20 40 60 80 100
κ1 0.0270 0.0696 0.1286 0.1996 0.2848
κ2 0.033 0.076 0.135 0.197 0.285
InCircle 0.49 1.02 1.70 2.49 3.40
e 4 8 12 16 20
resultant 25.12 57.24 102.63 160.44 231.19
b 53 900 2000 12000 24000
subdivision 0.20 0.58 1.06 10.65 31.61
Table 1: Performance of the predicates on elliptic sites. Timings are in seconds.
The final code shall use the Curved Kernel of cgal, cf. [12]. Our work respects the principles of code design based on kernels, as adopted by cgal. Nonetheless, the existing Curved Kernel will have to be enhanced to support ellipses. This is a project already initiated for the case of circles, see [14]. We also plan to use different algebraic libraries, such as EXACUS11 , for supporting the implementation of predicates, in order to evaluate our algebraic methods, and to further improve the resultant computations. Acknowledgments. George Tzoumas is partially supported by State Scholarship Foundation of Greece, Grant No. 4631. All authors acknowledge partial support by IST Programme of the EU as a Shared-cost RTD (FET Open) Project under Contract No IST-006413-2 (ACS - Algorithms for Complex Shapes). We thank Athanasios Kakargias for help with the overall code design, Michael Hemmer for suggestions on kernel design, and Costas Tsirogiannis for help with the GUI.
References [1] H. Alt, O. Cheong, and A. Vigneron. The Voronoi Diagram of Curved Objects. Discrete and Computational Geometry, 34(3):439–453, Sep 2005. [2] F. Anton. Voronoi diagrams of semi-algebraic sets. PhD thesis, The University of British Columbia, January 2004. [3] F. Anton, J.-D. Boissonnat, D. Mioc, and M. Yvinec. An exact predicate for the optimal construction of the additively weighted Voronoi diagram. In Europ. Workshop Comput. Geom., 2002. [4] F. Anton and D. Mioc. A certified predicate for maintaining the topology of the Voronoi diagram for conics. In Proc. X Encuentros de Geometr´ıa Computacional, pages 180–186, Sevilla, Spain, 2003. [5] E. Berberich, E. Fogel, D. Halperin, K. Mehlhorn, and R. Wein. Sweeping and maintaining two-dimensional arrangements on surfaces: A first step. In Proc. ESA, pages 645–656, 2007. [6] Eric Berberich, Michael Hemmer, Menelaos Karavelas, and Monique Teillaud. Revision of interface specification of algebraic kernel. Research Report ACS-TR-243300-01, INRIA, NUA, MPI, 2007. [7] I. Boada, N. Coll, and J.A. Sellar`es. Multiresolution approximations of generalized Voronoi diagrams. In Proc. Intern. Conf. Comp. Science, pages 98–106, 2004. 11
www.mpi-inf.mpg.de/projects/EXACUS/
10
[8] J.-D. Boissonnat and M. Karavelas. On the combinatorial complexity of Euclidean Voronoi cells and convex hulls of d-dimensional spheres. In Proc. 14th ACM-SIAM Sympos. Discrete Algorithms (SODA), pages 305–312, 2003. [9] J.-D. Boissonnat and M. Teillaud, editors. Effective Computational Geometry for Curves and Surfaces. Springer-Verlag, 2007. [10] D. Cox, J. Little, and D. O’Shea. Using Algebraic Geometry. Number 185 in GTM. Springer, New York, 2nd edition, 2005. [11] G. Elber and M.-S. Kim. Geometric constraint solver using multivariate rational spline functions. In Proc. 6th ACM Symp. Solid Modeling Appl., pages 1–10, New York, NY, 2001. ACM Press. [12] I.Z. Emiris, A.V. Kakargias, M. Teillaud, E.P. Tsigaridas, and S. Pion. Towards an open curved kernel. In Proc. Annual ACM Symp. on Computational Geometry, pages 438–446, New York, 2004. ACM Press. [13] I.Z. Emiris and M.I. Karavelas. The predicates of the Apollonius diagram: algorithmic analysis and implementation. Comp. Geom.: Theory & Appl., Spec. Issue on Robust Geometric Algorithms and their Implementations, 33(1-2):18–57, 2006. [14] I.Z. Emiris, M.Karavelas, A.Kakargias, and C. Tsirogiannis. CGAL package for the 2d curved kernel. Technical Report ACS-TR-123203-03, Algorithms for Complex Shapes, University of Athens, 2007. www.di.uoa.gr/˜grad0847/ACS-TR-123203-03.pdf. [15] I.Z. Emiris and E.P. Tsigaridas. Computing with real algebraic numbers of small degree. In Proc. ESA, LNCS, pages 652–663. Springer, 2004. [16] I.Z. Emiris, E.P. Tsigaridas, and G.M. Tzoumas. The predicates for the Euclidean Voronoi diagram of ellipses. Intern. J. Comp. Geometry & Appl., 2006. Special Issue on SoCG’06. To appear. [17] I.Z. Emiris, E.P. Tsigaridas, and G.M. Tzoumas. The predicates for the Voronoi diagram of ellipses. In Proc. Annual ACM Symp. on Computational Geometry, pages 227–236, June 2006. [18] I.Z. Emiris and G.M. Tzoumas. An efficient algorithm for the incircle predicate among smooth closed curves. In Proc. Europ. Workshop Computat. Geometry, Graz, Austria, 2007. http://www.di.uoa.gr/˜geotz/papers/EmiTzo-EWCG07.pdf. [19] I.Z. Emiris and G.M. Tzoumas. A real-time implementation of the predicates for the Voronoi diagram of parametric ellipses. In Proc. ACM Symp. Solid Physical Modeling, pages 133–142, Beijing, 2007. [20] H. Everett, D. Lazard, S. Lazard, and M. Safey El Din. The Voronoi diagram of three lines. In Proc. 23th ACM Symp. Computat. Geometry, pages 255–264, 2007. [21] M. Giusti, G. Lecerf, and B. Salvy. A Gr¨obner free alternative for polynomial system solving. J. Complexity, 17(1):154–211, 2001. [22] L. Habert. Computing bitangents for ellipses. In Proc. 17th Canad. Conf. Comp. Geom., pages 294–297, 2005. [23] D. Halperin, O. Setter, and M. Sharir. Exact and efficient construction of general twodimensional Voronoi diagrams via divide and conquer of envelopes in space, 2007. Manuscript. Tel Aviv University. 11
[24] I. Hanniel, R. Muthuganapathy, G. Elber, and M.-S. Kim. Precise Voronoi cell extraction of free-form planar piecewise c1 -continuous closed rational curves. In Proc. ACM Symp. Solid Phys. Modeling, pages 51–59, Cambridge, Mass., 2005. (Best paper award). [25] P. Harrington, C.O. D´ unlaing, and C. Yap. Optimal Voronoi diagram construction with n convex sites in three dimensions. Tech. Rep. TCDMATH 04-21, School of Mathematics, Dublin, 2004. [26] M. Held. Vroni: An engineering approach to the reliable and efficient computation of Voronoi diagrams of points and line segments. Comput. Geom. Theory Appl., 18:95–123, 2001. [27] J-P. Jouanolou. Le formalisme du r´esultant. Adv. in Math., 90(2), 1991. [28] M.I. Karavelas and M. Yvinec. Voronoi diagram of convex objects in the plane. In Proc. Europ. Symp. Algorithms, LNCS, pages 337–348. Springer, 2003. [29] D.-S. Kim, D. Kim, and K. Sugihara. Voronoi diagram of a circle set from Voronoi diagram of a point set: II. Geometry. CAGD, 18:563–585, 2001. [30] D. Lazard, 2006. Personal communication. [31] Sylvain Pion, Monique Teillaud, and Constantinos Tsirogiannis. Geometric filtering of primitives on circular arcs. Technical Report ACS-TR-121105-01, Algorithms for Complex Shapes, INRIA, 2006. http://www.di.uoa.gr/˜grad0847/ACS-TR-121105-01.ps. [32] V. Shoup. NTL: A library for number theory. http://www.shoup.net/ntl/. [33] E.P. Tsigaridas and I.Z. Emiris. Univariate polynomial real root isolation: Continued fractions revisited. In Proc. Europ. Symp. Algorithms 2006 (LNCS), pages 817–828, 2006. [34] J. von zur Gathen and J. Gerhard. Modern Computer Algebra. Cambridge Univ. Press, Cambridge, U.K., 2nd edition, 2003. [35] C.K. Yap. Fundamental Problems of Algorithmic Algebra. Oxford University Press, New York, 2000.
Appendix Proposition [27, sec. 5] Let g0 , . . . , gk be polynomials in variables x1 , . . . , xk , y1 , . . . , yt and f0 , . . . , fn be polynomials in variables x1 , . . . , xn , y1 , . . . , yt , where k ≤ n. Suppose fi , i = 0, . . . , n, lies in the polynomial ideal hg0 , .Q . . , gk imi , mi ≥ 1. If resx (·) denotes the resultant that eliminates the xi , then e resx (g0 , . . . , gk ) , e = ni=0 mi , divides resx (f0 , . . . , fn ) exactly, where both are viewed as polynomials over the yi . Proof of lemma 3.1 The polynomial b12 t12 +· · ·+b1 t+b0 in the factorization of R1 (t, r) corresponds to the condition that the normals to the ellipses t and s, used to define Q(t, r, s), B3 (s, t), are parallel. In this case, R1 vanishes, so this polynomial must divide R1 exactly. If we set 1 + s2 = 0, then Q and B3 are factored so that they contain a 1 + t2 and (1 + t2 )2 term, respectively. If we set 1 + t2 = 0, then Q and B3 are again factored and contain a 1 + s2 and (1 + s2 )2 term, respectively. Hence, Q ∈ h1 + s2 , 1 + t2 i, B3 ∈ h1 + s2 , 1 + t2 i2 . By the proposition ress (1 + t2 , 1 + s2 )2 divides R1 (t, r). By the construction of the Sylvester resultant, ress (1 + t2 , 1 + s2 ) is divisible by (1 + t2 )2 , hence (1 + t2 )4 divides R1 (t, r).
12
Figure 2: The Voronoi diagram of ellipses.
By Sylvester’s construction, the matrix defined by Q(t, r, s), B3 (s, t) contains 6 lines with coefficients from Q(t, r, s) and 4 lines with those of B3 (s, t). These coefficients are polynomials in t of degree 4 and 6 respectively. Hence, the total degree of R1 (t, r) in t is 48, which implies that we have identified all factors and their exact powers. For the case of R2 (t), the polynomial c12 t12 + · · · + c1 t + c0 in expression (5) is the same as the second factor in R1 (t, r), and corresponds to colinear normals of t and r. Hence it divides R2 (t). As above, B1 ∈ h1+r2 , 1+t2 i2 . Moreover, by a similar argument as before, R10 ∈ h1+r2 , 1+t2 i6 . By the proposition, resr (1 + t2 , 1 + r2 )12 divides R2 (t) exactly. Now, resr (1 + t2 , 1 + r2 ) is divisible by (1 + t2 )2 , from Sylvester’s construction. Therefore (1 + t2 )24 divides R2 (t). The Sylvester matrix for R10 (t, r), B1 (t, r) contains 6 lines with coefficients from R10 (t, r) and 24 lines with those of B1 (t, r). These coefficients are polynomials in t of degree 28 and 6 respectively. Hence, the total degree of R2 (t) is 312, which implies that if the powers in expression (5) are correct, then this gives the full factorization of R2 (t). 2
13
(1) (2a) (2b) (2c) (3) (1) (2a) (2b) (2c) (3) (1) (2a) (2b) (2c) (3)
Our code 0.490 0.675 0.850 1.060 1.920 1.290 1.590 1.740 2.091 4.650 4.220 6.010 6.090 7.017 11.180
Apollonius 0.010 0.015 0.016 0.017 0.016 0.038 0.047 0.054 0.061 0.096 0.040 0.052 0.057 0.069 0.295
Table 2: Experiments against the Apollonius package. Timings are in msec.
14