0% found this document useful (0 votes)
6 views

Epsilon Geometry BuildingRobustAlgorithms Computations-P208-Salesin

this book is very interesting

Uploaded by

Phan Thanh An
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Epsilon Geometry BuildingRobustAlgorithms Computations-P208-Salesin

this book is very interesting

Uploaded by

Phan Thanh An
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Epsilon Geometry: Building Robust Algorithms

from Imprecise Computations


Leonidas Guibas1t2 David Salesinl Jorge Stolfi2

‘Stanford University 2DEC Systems Research Center

1 Introduction possible to create a robust segment-intersection algo-


rithm assuming a scalar-product operator that is ex-
We describe a new general framework, called Epsilon act to within the machine’s precision. By contrast, our
Geometry, for coping with computational errors in geo- framework is designed to cope with computations that
metric algorithms that arise from the use of finite pre- are significantly less accurate than the machine’s preci-
cision arithmetic. sion limits. Greene and Yao [2] showed how a discrete
The Epsilon Geometry framework allows us to build version of the segment-intersection problem can be for-
robust geometric algorithms out of imprecise geomet- mulated and satisfactorily solved, but they too assume
ric primitives. Our method combines the techniques of precise computations.
interval arithmetic and backward error .analysis, along Our approach is more similar to those of
with agood deal of geometric reasoning. Our algorithms Milenkovic [S] and of Hoffmann, Hopcroft, and Kara-
compute an exact solution for a perturbed version of the sick [3]. These methods compute an exact result for a
input., and they return a bound on the size of this im- perturbed version of the input data, but they assume
plicit perturbation. a perturbation bounded by a constant chosen a priori.
The problem of building robust geometric algorithms Among other differences, the algorithms in our frame-
has received a good deal of attention in the last few work can determine the size of the required perturbation
years. For example, Yap [9] and Edelsbrunner and based on the size of the rounding errors observed during
Miicke [l] studied the problem of coping with geometric the computation.
degeneracies, such as the possibility of three collinear
points. The methods they propose are vaguely reminis- 1.1 Epsilon-Predicates
cent of ours, in that they too make use of use perturba-
tions on the input data. However, their perturbations The following definitions attempt to capture the notion
are infinitesimal and bear only a superficial resemblance of “‘approximate tests” in a very general setting. Let 0
to ours. Furthermore, the problem of imprecise compu- be a set of objecis endowed with some distance metric
tations that we address is distinct and much harder, in II., .I]. Let P be a predicate defined on 0. Then for
the sense that rounding errors not only increase the like- any X E 0 and any d 1 6, we define e-P(X) as a
lihood of degenerate cases, but they also introduce the shorthand for “P(X’) is true for some X’ E 0 such
possibility of inconsistencies. For example, imprecise that IlX, X’ll 2 E.” That is, X is at most E away from
computations may tell us that points a, b, c and b, c, d satisfying P(X). Therefore, the truth-set of 6-P is that
are collinear, but that points a,b, and d are not. of P, “fattened” by E. Note that O-P(X) is the same as
Ottmann, Thiemt, and Ullrich [8] showed how it is P(X)-
In order to extend these definitions to an n-ary pred-
icate P, we note that if 01, . . . , 0, are metric spaces
with distance functions II Iii,. . . , II Iln, then Uix...xO,
is a metric space with the distance function given by
Permission to copy without fee all or part of this material is granted pro-
vided that the copies are not made or distributed for direct commercial
advantage, the ACM copyright notice and the title of the publication and
its date appear, and notice is given that copying is by permission of the Thus, for example, if CIi = 02 = % with metric
Association for Computing Machinery. To copy otherwise, or to ]]z,z’]~ = ]Z - ~‘1, then 01 x 02 has the implicit metric
republish, requires a fee and/or specific permission.
]l(z, y), (z’, y’)][ = max (1~ - 2’1, ]y - y’]). Therefore, if
0 1989 ACM 0-89791-318-3/89/0006/0208 $1.50 P(x,y) is the predicate (Z > y), then &-P(z,y) means

208
that x > y can be made true by perturbing x and y by More precisely, the procedure P(X) should return a par-
at most .5. tition of the real line into three sets F, U, T, such that
Throughout this paper we will assume that 1111is a the predicate E-P(X) is false for 6 E F, true for E E T,
Minkowski metric. Minkowski metrics include all L, and unknown for E E U. We call such a procedure an
distance functions, in particular the Euclidean (Lz) and epsilon-box for P.
Manhattan (Ll) metrics. Note that the composite met- Given that E-P(X) is a monotonic boolean function
ric (1) is Minkowski if the metrics 11[Ii are Minkowski. of E, for any fixed X, we can assume that F, U, and
It follows immediately from the definition of an T are intervals of the real line (empty, bounded, or un-
c-predicate that bounded), with F before U before T. Since the floating-
point numbers are a discrete set, such a partition can be
E-P(X) * &‘-P(X) for all 6’ 2 E (2) represented by a pair of numbers e = (e.lo, e.hi), such
that a-P(X) is false for e < e.lo, true for E > e.hi, and
and unknown for e.lo 5 E < e.hi. To cover all possible tri-
Ilot(&-P(X)) =R not(&-P(X)) for all 8 < e (3) partitions of 3, we must let e.lo and e-hi assume also
the special values +oo or -oo.
We can extend our definition of c-predicate to negative We will call such pairs intervals ofuncetiaintyor sim-
values of E, in such a way that properties (2) and (3) ply intervals. Note that this name is slightly misleading,
remain true for all E. If E > 0, we define (+)-P(X) as because the pairs cannot be viewed as ordinary intervals
a shorthand for “P(X’) is trzle for all X’ E 0 S&J ihat of the real line. The difference is that two degenerate
11x,X’ll 5 E.” Intuitively, an object X that is (-6)-P pairs (2, x) and (Y, Y) with z # y are quite distinct out-
is “extremely P,” whereas an X that is only E-P is just comes, even though they define the same (empty) set U
“nearly P.” This definition can also be expressed by of “uncertain” E-values.
the identity Informally, the pair e returned by P(X) tells us that
X is at least e.lo and at most e.hi away from satisfying
(-&)-P(X) * not(s-(not P(X))) the predicate P. In particular, if e.lo > 0, then P(X)
is definitely false; if e.hi 5 0, then P(X) is definitely
The following properties of epsilon-predicates follow true; and if e.lo 5 0 < e.hi, the procedure was unable
readily from the definitions and the triangle inequality to decide whether P(X) is true of false because of com-
for distances: putation errors.
As we shall see, this approach allows us to build ro-
Lemma 1 For any predicates, P and Q, and any E 2 0,
bust geometric algorithms out of arbitrarily inaccurate
E-(P v Q)(X) (j E-P(X) v E-Q(X) primitives. In general, such an algorithm will produce
results that are correct only in an approximate sense.
E-(P A Q)(X) =$ E-P(X) A E-Q(X)
However, the algorithm will always be able to combine
Note that in the case of A the implication only works the uncertainty intervals returned by the primitives into
in one direction, because even if it is possible to satisfy a “warranty” for the result: that is, an interval of uncer-
P(X) and Q(X) separately with c-perturbations to X, tainty that states how far the result that was returned
it may not always be possible to satisfy both constraints may be from the exact one.
simultaneously. In principle, we do not make any assumptions on
the size of the uncertainty intervals U returned by an
Lemma 2 For any ~,6 1 0, and any predicates epsilon-box. We consider an epsilon-box to be correct
P, Q, R, if P(X) implies E-Q(X), and Q(X) implies as long as E-P(X) is false for all E E F, and true for all
&R(X), then P(X) implies (E + 6)-R(X). E E T. An epsilon-box box is always allowed to say “I
don’t know” for an arbitrarily large range U or E values.
In particular, the trivial epsilon-box that always returns
1.2 Implementing Epsilon-Predicates
T = F = 4, U = SRis a correct implementation of any
When geometric tests such as collinearity or convex- predicate P.
ity are implemented using floating point arithmetic in In practice, of course, an epsilon-box should keep its
the straightforward way, their outcome becomes subject uncertainty trange U reasonably small in order to be
to errors. In order to quantify those errors and allow useful. Typically, a primitive box P(X) will compute
geometric algorithms to cope with them, we propose the distance from X to the truth-set of P using floating
to implement each geometric test P(X) as a procedure point arithmetic, and estimate the uncertainty of the
P(X) that, instead of simply returning true or false, result according to standard numerical analysis tech-
returns an estimate of how far X is from satisfying P. niques. For most primitives, this epsilon-box will be

209
only a few times slower than the naive implementation that E-R(X) is false for & < min{a.lo,b.lo}, and true
of P(X). We will come back to this topic in section 2. for E 1 max {a.hi, b.hi). Therefore, the procedure R(X)
can safely return the pair T = a LI b, which we call the
1.3 Combining Epsilon-Boxes join of a and b.
As a final example, suppose again that we have com-
The following operations on uncertainty intervals turn puted two possible results a and b for R(X), but now
out to be useful for combining primitive epsilon-boxes we know that both intervals are correct. This tells us
into more complex algorithms. Given two uncertainty that E-R(X) is false for E < max{a.Zo, b.lo}, and true
intervals a, b, we define for E 1 min {ahi, b.hi}. Therefore, R(X) can return the
pair r = a 176, which we call the meet of a and b.
min{a,b} = ( min{a.lo,b.lo}, min{a.hi,b.hi))
Note that if both a and bare correct outcomes, the re-
max {a, b} = (max {ale, b.Zo}, max {a.hi,b.hi}) sult r = an b is bound to satisfy r-lo 5 r.hi. IIowever, in
sub = (min{a.lo,b.Zo}, max{a.hi,b.hi}) more complicated expressions this need not be the case.
anb = (max {a.lo, b.lo}, min {ahi, b.hi}) For those situations, it is useful to define the “impossi-
ble” interval 0 = (+oo, -00) and define by convention
For example, suppose we managed to prove that the a fl b = 0 whenever a and b are incompatible outcomes,
predicate e-R(X) is equivalent to e-P(X) V E-&(X), for that is, whenever a.10 > b.hi or b.lo > a.hi. Note that
all X and all E. Then the predicate R(X) can be imple- 0lla=a~0=0,andaU0=0Ua=a,foranya.
mented as the procedure R(X) that evaluates the inter-
vals a = P(X) and b = Q(X), and returns the interval
min{a, b}. Note that this interval is generally noi the 2 Some Basic Predicates
union of the intervals a and b.
This rule is easy to understand with the help of Now let’s consider in more detail the implementation
figure 2, which shows the “graphs” of the predicates of basic geometric predicates of two-dimensional geom-
E-W) 9 dxw, and E-R(X), for a particular X, as a etry. Unless said otherwise, we will measure distances
function of &. The “fuzzy” portion of each graph rep- between points in the plane with the familiar Euclidean
resents the uncertainty interval returned by the corre- (~52) metric, tlp,qll = &.z - 4.z12 + (I-V - q412.
sponding epsilon-box. However, many of the results that follow can be adapted
to any other L, metric. In fact, some of the algorithms
q.lo ehi described below may be easier to code (but probably
harder to prove) if we defined 1111to be the L, or L1
metric.

2.1 Coincidence
Let’s consider first the Coincident predicate, which
merely tests whether two points of the plane are coinci-
T-Qcle
dent or distinct. According to the general definition, the
*C:
Figure 2. derived predicate E-Coincident(p, q) is true if and only
if& 2 alIp, qll. Therefore, the procedure Coincident
Similary, if we know that the predicate &-R(X) is that implements this predicate should compute the dis-
equivalent to &-P(X) A E-Q(X), for all X and all &, then tance IIp,qII, and return a pair (e.lo,e.hi) such that
the procedure R(X) should return max {P(X), Q(X)}. e.lo 5 fllp,qll 5 e.hi. This interval tells us that it
Note that in most machines these operations can be is possible to make p and q coincident if we displace
performed without any rounding errors. Note also that both points by e.hi in suitable directions, and it is not
the uncertainty c.hi - c.10 of the result c is no greater possible to make p and q coincident if we displace them
than the uncertainty in the inputs a and b. by less than e.lo.
Another situation that often arises in algorithms is Note that depending on the application, it may
the following. Suppose we computed two possible re- not be necessary to compute the Euclidean distance
sults a and b for the epsilon-box R(X), by two differ- Ilp,q(l with high accuracy. For example, we can use
ent algorithms, and we know that the first algorithm the property that IIP, !?II, I III? !7II 5 fillP7 qll,,
is correct when some condition P(X) is true, and the where IIP,4, = max(1p.z - q.zl, 1p.y - q.yl}. The
second one is correct when P(X) is false. If we cannot Coincident box may then compute D = IIp,qII,, and
decide whether P(X) is true or false, we can still tell return the interval (e.lo, e.hi) = (D/2, D/d). This is a

210
very coarse approximation, with a relative uncertainty the Coincident procedure can return the uncertainty
of the result is almost 50%; however, it is somewhat interval
faster to compute than the square root formula, and it
may still be accurate enough for many applications. e = (e.lo, e.hi) = (d*(l - 3u)/2, d*(l + 3u)/2) (7)

Note that the division by 2 is exact, and the rounding


2.2 Estimating Roundoff Errors error in the multiplication by (1 + 3u) is on the order of
In practice, besides the approximation error that results u2 and is therefore covered by the safety factor implicit
from using the L, norm to compute a distance, we also in u.
have rounding errors due to the subtraction and the Of course there are many other correct implementa-
division by 4. Fortunately, the magnitude of these tions of Coincident, each with its own cost and accuracy.
errors is easy to estimate. We are not concerned here with the problem of choosing
A fundamental “axiom” of numerical analysis [5] says between those alternatives. Our goal is not so much to
that for each floating-point number system there is a design fast or accurate primitives, but to show how to
constant u (the machine precision) such that the result make good use of arbitrarily inaccurate ones.
c* of computing c = a * b in floating point (where * is
either +, -, a, or /) satisfies c* = c( 1 + A), for some A
with [Al < u. Furthermore, the same guarantee applies
2.3 Collinearity and Orientation
to the basic numerical functions (J, sin, exp, etc.), if The tests for collinearity and orientation of three given
they are properly implemented. points deserve careful discussion, since they are basic
So, for example, the computed value d’ of the distance building blocks of many two-dimensional geometric al-
gorithms. We denote by Collinear(p, q, r) the predi-
d = d(p.z - q.x)2 + (P.Y - Q.YJ2 (4) cate that checks whether the points p, q and P of ?R2
is actually lie on a common straight line, in any order. There-
fore, c-Collinear(p,q, r) is true if there exists a line 1
8 = { [(P.X - VW+ h)12(l + A2) that passes within & of all three points. The predicates
Collinear and e-Collinear are obviously symmetric in
+ KP.Y- !l.Y)Pf W12(1+ bp2 0 + J45) (5) their three arguments.
where I&( 5 21for all i. We can visualize the .c-Collinear predicate as follows.
We can simplify the last expression by resorting to Consider the disks P and & of radius E centered at p
a standard numerical analysis trick. Observe that the and Q, respectively. The set of all lines passing through
maximum relative rounding error IA1 in a floating-point a point of r-and a point of Q cover a bow-tie-shaped
operation is normally very small, typically 10-s or less. region of the plane bounded by the two inner and two
If we define u to be just a little bigger than this max- outer tangents of P and Q. (If P and Q have a point
imum error (say, twice as big), then we can prove that in common, then this region degenerates to the entire
any expression of the form plane.) We call this region the c-buttefly determined
by p and q. See figure 3.

fi(l+xi)/fi(l+J;)
i=l j=l

lies in the interval 1 f (m + n)u, provided m and n are


not too big. In particular, this “safety factor” built into
u allows us to ignore second and higher powers of the
Ai in error bounds, and freely move factors of (1 f Xi)
between the numerator and denominator. Using this
trick, formula (5) simplifies to
Figure 3. The E-butterfly of p and q.
d“ = j/[(p.x - q.x)2 + (p.9 - q.y)]‘(l + 3A6) (1 + A5)
Obviously, the three points p, q, and r are E-collinear
and finally to
if and only if the E-disk centered at r intersects the
d’ = &.x - q.x)2 + (p.y - q.y)2 (1 + ;A,) (6) c-butterfly of p and q. Equivalently, the three points
are E-collinear if and only if one of the c-disks intersects
for some Ji with IAil 5 21. We conclude that the exact the c-stroke of the other two points, which is how we
distance d is well inside the interval d’ f 3u. Therefore, call the convex hull of the two c-disks centered at those

211
points. See figure 4. Geometrically, the determinant D is twice the area of
the triangle pqr, with a plus or minus sign depending
on the orientation of the three points. In the Euclidean
metric, the smallest perturbation that makes the three
points collinear is one that moves them onto the perpen-
dicular bisector of the shortest altitude of the triangle.
See figure 6.

Figure 4. E-Collinearity.
In exact geometry, a triangle T = (p, q, r) whose ver-
tices are not collinear can be further classified by its ori-
entation, either positive (counterclockwise) or negative
(clockwise). The orientation is the sign of the determi-
nant
Figure 6.
1 Pax P*Y
D(P, q, r) = 1 q-2 Q*Y (8) Since the area of a triangle is given by one half its base
1 r.2 r.y times its height, the necessary perturbation E is iIDJ/b,
We define the predicates Pos(p, q, r) and Neg(p, q, r) as where b is the length of the longest side.
meaning D(p, q, r) > 0 and D(p, q, r) 5 0, respectively. We can use this result to implement a Pos box that
Note that PM(T) is not the same thing as not Neg(T); uses only single-precision floating-point computations,
in fact Pm(T) A Neg(T) s Collinear(T). (This conven- as follows. First, we need to estimate the rounding er-
tion is a bit confusing, but it seems to simplify many of rors incurred in the computation of IDl/b. From equa-
the proofs and algorithms we will see later on.) tion (8) we get
By definition, then, E-Pos(p, q, r) means that is possi-
D= (q.x-p.z)(r.y-p.y)-(q.y-p.y)(r.x-p.x) (9)
ble to make D(p, q, r) 1 0 by displacing the three points
by at most E in suitable directions. In graphical terms, If we compute this formula using floating-point opera-
E-Pos(p, q, r) means that the closed e-disk centered at r tions, we obtain an approximate result D’ satisfying
either intersects the c-butterfly ofp and Q, or lies fully to
Dk = ((4.x - p.x)(r.y - p.y)(l + 3X1)
the left of it (as looking from p towards q). See figure 5.
-(q.y - p.y)(r.+ - p.x)(l + W))(l + X3)

= D(l + X3) + 3A4M

where M = IQ.2 - p.xl1r.y - p-yI+lq-y - p4llr.x - p.21,


and l&l < U. We can compute the longest side b by the
obvious formula

b= max{IIP,41,Ilq,41,Ilv4lI
where II II is the familiar square root formula (4). As we
discussed in section 2.2, if we assume that the square
root operation is accurate to the machine precision, then
Figure 5. E-Orientation.
the the computed value b’ satisfies b’ = b(1 + 3Xe).
From linear algebra we know that the the determinant Therefore, the computed value h* for the triangle’s
D changes sign if we swap any two of the three points, height h = D/b satisfies
and remains unchanged if the three permuted are per- D( 1+ A3) + 3X&4
muted in a cyclic fashion. Thus, h* = (1 + k3)
b(l + 3A7)
E-Pos(p, q, r) G e-Pos(q, r,p) E c-Pos(r,p, q)
=
E e-Neg(q, p, r) G c-iVeg(r, q,p) E c-Neg(p, r, q)
Note again that &-Neg(T) is quite different from In fact, since IDI 2 I<, we can further simplify this to
not a-Pas(T), and, in fact, h* = h + 7AllM/b. Therefore, we conclude that

e- Collinear(p, q, r) E c-Neg(p, q, r) A c-Pos(p, q, r) h E h’ f 7uM*/b* (10)

212
Note that M can be as large as b2, and that uM/b can A similar result holds for /?. Therefore, these computa-
easily be greater then h, which means that the rela- tions give us two intervals a and b, which may or may
tive error of h* can be arbitrarily large. Formula (10) not include 0.
says that the absolute error of h’ is small compared to We obtain uncertainty intervals dp and dq for the dis-
the distances between the three points. If this inaccu- tances $l/z,pll and $1jz,qll by calling the Coincident
racy is a problem, one can make the relative error small box. As for ~llz,~lJ, its value is twice the area of
by computing D with extended precision; more specifi- the triangle zpq, divided by the length of pq; that is
cally, with at least 2m + 1 fraction bits, where m is the I%> p,dI/IIp, nil, w here D is the determinant defined
number of fraction bits in single-precision floating-point by equation (8). Therefore the analysis we did for the
numbers. Pos subroutine applies here too (except that b is the
Even though Pos and Neg are not the exact oppo- length of pq, instead of the longest side), and we get the
sites of each other, the asymmetric representation we same uncertainty interval dl = h*f7uM*/b*. (If b’ = 0
use for the outcome of epsilon-boxes allows us to state then we can conclude that b = 0, in which case we let
the following result: if the pair a = (U./O, a.hi) is a valid dl be the pair (O,O).)
outcome for Pas(T), then the pair -a = (-a.hi, -a.lo) We now have to put all this information together and
is a valid outcome of Neg(p, Q,r). Therefore the proce- deduce from it an uncertainty interval e for the distance
dures Pos and Neg can share most of their code, and if from z to the segment pg. The algorithm is relatively
we evaluate Pas(T) we do not need to evaluate Neg(T). straightforward:
1. et0
2.4 Betweenness 2. if a.lo_<OAb.hi_>O then e+-eUd, ii
We say that a point z is between two other points z and Q 3. if b.lo<OAa.hikO then eteUd, ii
if z lies on the closed segment pg. We denote this fact by 4. if a.hi>Ohb.hi>O then e+eUd, ii
Between(z,pq). It is easy to see that E-Between(z,pq) 5. return e
if and only if the distance from z to the segment pq is Step 1 initializes e to the dummy interval 0 that is a
at most 2s; or, equivalently, if and only if the c-disk neutral element of U. Step 2 checks whether the projec-
centered at z intersects the E-stroke of p and q. See tion .z’ could lie before p, in which case the uncertainty
figure 7. interval e is set to the range of possible values of ~&~,pll.
Step 3 does the same thing for q. Finally, step 5 checks
whether z’ could lie strictly between p and q, in which
case it sets to e the range of )IIz, /Il. Note that if the
algorithm cannot decide between any two cases, it will
simply merge the corresponding uncertainty intervals.

3 Approximate Point Inclusion


Figure 7. The &-Between test.
3.1 Point Inclusion in a Triangle
In order to compute the distance from z to the seg-
ment pq we must find the projection z’ oft on the line 1 We now show how these primitives can be combined
through p and q, and then return either illz,pll, $llz, 111, into a more complex algorithm. We consider the prob-
or ~ll~~dl,d P d g
e en in on whether z’ lies before p, be- lem of testing whether a point z is inside a trian-
tween p and Q, or after q, respectively. gle T = (to,tl,tz), which we denote by the predicate
We can check the position of z’ by checking the Inside(z,T). We define “inside” to include the trian-
signs of the dot products LY = (z - p) . (q - p) and gle’s boundary.
The E-version of this predicate is true if the point z
P = (z - 9) ’ (P - q). If cr < 0, then z’ lies before
p; if ,B < 0, then z’ lies after q; otherwise z’ lies be- and the triangle T can be perturbed by at most E so
tween p and q. If we compute these dot products with that Inside(z,T) becomes true. Here, the distance be-
single-precision floating point arithmetic, we must take tween two triangles is defined as the maximum distance
into account the attendant rounding errors. An analysis between a vertex of one triangle and the corresponding
similar to the one we did for the Pos predicate shows vertex of the other. Thus, e-Inside(z, T) is true if and
that the computed value (Y* of Lysatisfies a E a*f4~1(,‘, only if Z it is within 2~ of some point of T.
where I(p* is the computed value of the quantity Assume for the moment that the vertices to, tl, t2 of
T are known to be non-collinear and positively (coun-
ICp = I(= -I-)(9.2: - P.C)l f 1lr.y - P.Y)(9.Y - P.Y)l terclockwise) oriented. Then ordinary geometry tells US

213
that %is inside T if and only if the triangles ztctr , ztrtz, section 1.3: evaluate Between(z,p, q) for all edges p, q
and %-&toare all positively oriented (or flat). Moreover, of T, and return the min of the resulting pairs. In fact,
if %is inside T, any perturbation that puts I outside the it is easy to check that this algorithm works even if T
triangle must reverse the orientation of one (or more) of is replaced by an arbitrary polygon.
these triangles. We conclude that How does the Boundary predicate help us? The an-
swer is given by the foiowing trivial properties:
Lemma 3 If a point % is inside a positively oriented
triangle T = (to, tl, tz), then for any e (positive or neg- Lemma 4 If a point z is outside a triangle T, then for
ative), all E 2 0

E-Inside(z, T) M c-Boundary(z, T) (14)


c-lnside(z,T) e i .z-Pos(z,ti,ti+l) (11)
i=O
Lemma 5 If a point z is inside a triangle T, then for
If T is a negatively oriented triangle, formula (11) holds all E < 0,
with Pos replaced by Neg.
Unfortunately, equation (11) does not hold if %is out- e-lnside(r, T) e not (-&)-Bounday(z, T) (15)
side T. as figure 8 shows, the triangles Aiti+l can be
With these results, we can implement the Inside tests
all c-positive, and yet %may be arbitrarily far from T.
The explanation is that it is indeed possible to make ei- for a point and a triangle by the procedure InTriangle
below:
ther one of the triangles ztotl and ztltz positive with an
c-perturbation, but there is no such perturbation that
1. al) + Pos(r,to,t~)
makes them both positive at the same time.
2. a1 + Pos(%,t&)
3. a2 + Pos(z,t2,to)
4. sp +m={ao,al,a2}
5. if s,.hi < 0 then return sp
6. sn +-max{-a~,-al,-a2)
7. if s,.hi < 0 then return sn
8. s +Pos(to,tl,t2)
9. if s.hi 50 then r tsp
10. elsif s.10 2 0 then r t s,,
ii. else r+-s,Usp
12. ii
13. b + Boundary(t, T)
14. return (All (r.lo-00))Ub
Therefore, when % is outside T, the information re-
turned by the Pos boxes is not sufficient. To handle In this algorithm, steps l-4 compute the perturbation
this case, we introduce the predicate Bounday(z,T), sp needed to independently make each of the triangles
that tests whether the point %lies on the boundary of ztotl, ztlt2, and zt2tO positive or collinear. If this per-
the triangle T. This predicate has a simple expression: turbation is definitely negative, meaning all three tri-
n
angles are positively oriented, then we can deduce that
the triangle T itself is positively oriented, and that %is
Bounday(r,T) e c Betweeu(z,ti, ti+l). . (12) inside it. Lemma 3 then authorizes us to return sp itself
i=O
in step 5 as the uncertainty interval of Pos. Steps 6-
Recall that for E > 0 the e- qualifier distributes over V. 7 perform the symmetric test for the case when T is
Therfore, we can write negatively oriented.
If these two tests fail, the algorithm does some addi-
tional work in order to find the minimum perturbation
c-Bounday(z,T) H c &-Between(z,ti, ti+l). (13)
T that makes each of the three triangles have (idepen-
i=O
dently) the same orientation as T. First the algorithm
In other words, we are E away from the boundary if and tries to determine the orientation of T by evaluating
only if we are e-away from some side. This identity holds Pos(tc, tl, t2). If the result of this test has a definite
also for E < 0, since in that case both sides are false. sign, then r is taken to be either sp or s,. If the test is
The implementation of Boundary follows immediately inconclusive, then r is set to the join of the two intervals.
from equation (13) and the V construction described in Note that in any case we will end up with r.hi 10.

214
As we observed before, the interval P is still not the As figure 8 shows, a point can be well inside the polygon
answer we want, since r was obtained by considering P, even if it is possible to reverse the orientation of some
independent perturbations to each of the three edges, triangle zpipi+r by an arbitrarily small perturbation to
and those perturbations may not be simultaneously re- those three points. Therefore, for InConvex must use a
alizable. The only useful information contained in r is different approach, as follows. When z is inside P, we
its lower endpoint r.10, provided it is less than zero: if will estimate the degree of “insideness” from the output
--E < r.lo < 0, that is, if we cannot change the orien- of the Boundary box alone, using lemma 5. When z is
tation of one of any of the three triangles with any E- outside P, we will estimate its degree of “outsideness”
perturbation, then we cannot move z out of T with any with several calls to InTriangle, using the following
&-perturbation, which means z is (-&)-inside T; and obvious property:
conversely. On the other hand, if r.lo 2 0, we know
only that z is outside, but we can’t tell by how much. Lemma 6 LetTr,Tz,..., T, be a set of triangles whose
In other words, at step 13 the uncertainty interval of union is the set P. If a point z is outside P, then for
Pos is (r.10 _ 00) U(0 _ infty). all E 1 0,
In order to reduce this uncertainty to a useful level,
we evaluate b = Boundary(z, T), the minimum pertur-
c-Inside(t, P) H 6 E-lnside(z, Ti)
bation needed to put z on the boundary of t. The re-
i=l
sulting interval b is always non-negative; moreover, by
lemmas 4 and 5, the result we want is either -b or +b, Note that lemma 6 cannot be extended to E < 0, be-
depending on whether t is inside or outside T. So, the cause J can be near an edge of some triangle Ti and
result we want is the intersection of those two inter- still be arbitrarily far from the boundary of P. Nev-
vals with (r.lo _ oo) Ll (0 _ infty), which simplifies to ertheless, lemma 6 allows us to write an epsilon-box
(-bn(r.lo _ co)) LI b, as returned in step 14. InPolygon(z, P, Tl, . . . , Tm) that implements the Inside
Note that the width of the interval returned by this test for a planar figure P, given a collection of triangles
algorithm is at most twice the size of the widest interval Tl,T2 ,..., Tm whose union is P:
returned by the Pos and Between boxes.
As usual, there is here a tradeoff between speed and 1. r c rain {InTriangle(z, Ti) : 15 i 5 m}
accuracy. One could reduce the width of the uncertainty 2. if r.lo 2 0 then return r f i
interval returned by InTriangle(z, T) by performing 3. r.10 c -00
more elaborate tests, by using more accurate primitives, 4. b c Boundary(z, P)
by combining their results in a more sophisticated fash- 6. return (r fl b) LI (r fl -b)
ion, or by implementing the InTriangle procedure as a
primitive, as we did with Poe. Step 1 computes the perturbation r necessary to put
z inside one of the triangles Ti::. If r.lo 2 0, it means
3.2 Point Inclusion in a Convex Polygon z is outside P, and by lemma 6 we can return r itself
as the outcome. If r.lo < 0, lemma 6 tells us nothing:
Let’s now consider the more general predicate that the uncertainty interval for Inside(z,P) is not r but
tests whether a point z lies inside a convex polygon the whole interval (-oo,r.hi). In order to reduce this
P=(poJQ,... ,pn-r). One might think that the imple- uncertainty, we look at the perturbation b needed to put
mentation InConvex of this predicate is a trivial general- z on the boundary of P (step 4). According to lemmas 4
ization of InTriangle, but that is not the case. While and 5, the InPolygon box can safely return r 17b is z
lemmas 4 and 5 generalize nicely to arbitrary convex is outside P, and r tl -b if z is inside P; therefore, it
polygons, lemma 3 does not. , , can always return return the join of these two intervals
(step 5).
Given this algorithm, the InConvex box that im-
plements the Inside test for convex polygons is triv-
ial: it suffices to note that a convex polygon P =
(Pod%... ,p,-1) is the union of the triangles Popipi+l
for 1 5 i 2 n - 2.
Note that, as in the the case of InTriangle, the width
of the uncertainty interval returned by InPolygon or
InConvex is at most twice that of the widest interval
returned by any of the primitive epsilon-boxes called by
Figure 8. them.

215
Some applications of the InConvex box may not re- z is inside P but not inside Q. Consider the rays from
quire all the information that it returns. In such cases x to P(t) and from z to Q(t). As t goes once -around
the algorithm can often be made simpler and faster, at the unit circle, the first ray makes a non-zero number of
the cost of returning a much wider uncertainty interval. full turns, while the second makes zero full turns. Since
For example, if we only want to know whether we are the curves are continuous, there must exist a value oft
inside or outside P, but we don’t care by how much, we for which the angle between the two rays is a. At that
can omit steps 4 and 5. In that case, when z is inside P moment, 2 is on the segment connecting P(t) and Q(t),
or close enough to it the algorithm will return intervals whose length is at most E, by hypothesis. q
of the form (--00, E). This result is not as trivial as it may sound. For
instance, it is not enough to merely require that every
point of the curve P be within E of Q and vice versa.
4 Approximate Convexity
The InConvex test of the previous section assumes the 4.2 Polygons
polygon is convex in the ordinary sense. By itself, such The next lemma states an elementary property of
a test isn’t very useful, since in many applications we Minkowski metrics is useful when applying lemma 7 to
cannot always ensure that the polygons are strictly con- polygons:
vex, because they can be the result of previous ap-
proximate computations, and the rounding errors in- Lemma 8 Let 11,II be any Minkowski metric. Then for
curred may have introduced slightly concave corners, any four points p, q, p’, q’ such that IIp,p’ll < E and
self-intersections, and other similar defects. Worse still, IIq, q’jl < e, and for any cx E [0 _ 11, we have
if we are allowed to use only approximate primitives
like the ones we described, we will not even be able to ll(1 - @Y)P+ %I, (1 - (Y)p’ + q’ll I E
clrecAwhether a given polygon is convex. Therefore, we
must learn how to handle polygons that are only “ap- The next result is a trivial corollary of lemmas 7
proximately convex.” In order to do this, we must first and 8:
define more carefully the meaning of “inside,,, and prove
l$rny; “, If the polygons P = (~0, pl, . . . ,p,,-1) and
a few results about closed curves in general. = 0, l,.**,!In-1 ) are such that lIpi, gill 5 2~ for
all i, then any point inside P is e-inside Q (and vice
4.1 Closed Curves versa).
We define a closed curve to be a continuous function
from the unit circle Sr into the plane, and we consider 4.3 Inclusion in an E-Convex Polygon
two curves to be the same if they differ only by a simple Now let’s try to extend the InConvex algorithm to
reparametrization, that is, by a homeomorphism of Sl polygons that are not necessarily convex, but merely
to itself. We say that a point z is inside such a curve C &-convex. According to the general definition, a poly-
if the curve passes through Z, or if its winding number gon P is &-convex: if there exists a convex polygon P’
around z is non-zero [4]. Note that the curve need not that is at most E away from P; or, equivalently, if we
be simple. We denote this fact by Inside(z) C). can perturb the vertices of P by at most E in such a
We define the distance between two curves C,C’ way that the result is a convex polygon. We will use
as the smallest value of max {]]C((~(t)),C’(t)]l : t E Si}, the following result:
when cp ranges over all reparametrizations of C. In
spite of this complicated metric, the meaning of Lemma 10 Let P = (po,p1,. . . ,p,,l) be an e-convex
e-Inside(r) C) is quite simple: if E 1 0, this predicate polygon, with E > 0, and z a point of the plane. Let P”
means that z is either inside C or at most 21~1away be the union of the triangles popipi+l for 1 5 i 2 n - 2.
from C; and if E < 0, it means that z is inside C but at Then
least ]&I away from C.
Inside(z) P) =S Inside(z, P’) + &-lnside(z, P)
Lemma 7 Let P and Q be two closed curves with the
property that IIP(t), Q(t)/1 5 E for allt on the unit circle. Proof: Let’s prove first that Inside(r,P) =+
Then any point that is inside P is (E/2)-inside Q, and Inside(z,P*). If the point z is inside the polygon P,
vice versa. then any ray starting from z should meet at least one
edge pipi+ of P for 1 5 i 5 n- 2. (Assuming each edge
Proof: Let x be a point inside P. If x is inside Q or x includes its endpoints.) In particular, this should hap-
is on the curve P, then we are done. Let’s assume that pen for the ray out of z that is directed away from po.

216
This ray proves that z is inside the triangle popipi+l, Acknowledgements
and hence inside P”.
The ideas for this paper grew out of discussions
Now let’s prove that Inside(z, P’) + .e-1nside(r, P).
with Bernard Chazelle, Herbert Edelsbrunner, Michel
By definition there exists a convex polygon P’ such that Gangnet, Ricky Pollack, Franc0 Preparata, and Micha
]]pi,dl] 5 E for all i. By corollary 9, every point inside
Sharir. Victor Milenkovic showed us the proper way
P’ is (a/2)-inside P. By the same argument, any point
to compute the orientation primitive and estimate its
of triangle popipi+l is (E/2)-inside the corresponding tri-
rounding error. We would like to thank the DEC Paris
angle pbp:pi+,; therefore, by lemma 6, any point in P*
Research Lab and the DEC Systems Research Center,
is (s/2)-inside P’. By the triangle inequality (lemma 2),
which supported much of this work.
then, any point of P’ is E-inside P. 0
This lemma gives us an algorithm InEpsConvex(z, P, E)
that tests whether a point z is &Inside a polygon P, References
assuming that P is &-convex. The algorithm is a slight
modification of the InConvex box that we gave in sec- [1] Herbert Edelsbrunner and Ernst Peter Miicke, “A
tion 3.2: technique to cope with degenerate cases in geomet-
ric algorithms.” Proc. 4th Annual ACM Symp. on
1. r e min{InTriangle(z,pcpipi+l) : 1 _< i 5 ta - 2) Computational Geometry (1988), 118-133.
2. r.hi+r.hi+s
[2] Daniel H. Greene and F. Frances Yao, “Finite-
3. if r.10 2 0 then return r ii
resolution computational geometry.” Proc. 27th
4. r.lot--00
IEEE Symp. on the Foundations of Computer Sci-
5. b + Boundary(z,P)
ence (1986), 143-152.
6. return (r ll b) U (r ll -b)
[3] Christoph M. Hoffman, John E. Hopcroft, and
After step 1 we know that I is b-inside some of the Michael S. Karasick, “Towards implementing ro-
triangles papipi+l, for 6 2 r.hi, and not b-inside any of bust geometric computations.” Proc. 4th Annual
them for 6 < r.lo. Step 2 adjusts r.hi to account for the ACM Symp. on Computational Geometry (1988),
fact that the union of those triangles may include points 106-l 17.
that are up to 2~ away from P. This step is justified
by the triangle inequality (lemma 2). The rest of the [4] Leo Guibas, Lyle Ramshaw, and Jorge Stolfi, “A
kinetic framework for computational geometry.”
algorithm is shown correct by the same arguments used
Proc. 24th IEEE Symp. on Foundations of Com-
for InPolygon in section 3.2.
puter Science (October 1983), 100-111.
[5] Donald E. Knuth, “The art of computer program-
5 Conclusions ming, vol. 2: Seminumerical algorithms” (second
edition), section 4.2.2. Addison-Wesley (1981).
The Epsilon Geometry framework we described in this
paper allows us to build robust algorithms using im- [S] Victor J. Milenkovic, “Verifiable implementations
precise computations. Because our framework allows us of geometric algorithms using finite precision arith-
to use ordinary fixed- or floating-point arithmetic and metic.” International Workshop on Geometric Rea-
substitute simpler approximations for hard-to-compute soning (Oxford, England, July 1986).
formulas, we believe it has great practical potential. [7] S. P. Mudur and P. A. Koparkar, ‘qnterval methods
An important feature of the Epsilon Geometry ap- for processing geometric objects.” IEEE Computer
proach is its flexibility, in that it gives the designer of a Graphics and Applications (February 1984), 7-17.
geometric algorithms great freedom to choose between
accuracy, efficiency and simplicity. Our approach allows [S] Thomas Ottmann, Gerald Thiemt, and Christian
us to combine primitive epsilon-boxes into more com- Ullrich, “Numerical stability of geometric algo-
plex algorithms, independently of the number represen- rithms.” Proc. 3rd Annual ACM Symp. on Com-
tation and machine precision used inside each primitive putational Geometry (1987), 119-125.
box.
[9] Chee-Keng Yap, “A geometric consistency theo-
We have barely started to explore the application of rem for a symbolic perturbation scheme.” Proc. 4th
this framework to classical computer geometry prob- Annual ACM Symp. on Computational Geometry
lems. If the examples we give in this paper are too (1988), 134-142.
elementary, it is only because we haven’t had time yet
to consider more complex ones.

217

You might also like