visibility graphs and obstacle-avoiding shortest paths

20
ZOR - Zeitschrift ftir Operations Research, Volume 32, page 145-164 Visibility Graphs and Obstacle-Avoiding Shortest Paths By H. Alt and E. Welzl 1 Summary: Two closely related problems in Computational Geometry are determining visibility graphs and shortest paths in a two- or three-dimensional environment containing obstacles. Appli- cations are within Computer Graphics and Robotics. We give a survey on recent research done on efficient algorithms for these problems. Zusammenfassung: Zwei eng miteinander vetwandte Probleme in der algorithmisehen Geometric sind die Bestimmung yon Siehtbarkeitsgraphen und k~zesten Wegen in einer zwei- oder dreidimen- sionalen Umgebung mit Hindernissen. Anwendungen finden sich insbesondere auf den Gebieten Computergrafik und Robotik. Diese Arbeit gibt einen Oberbliek fiber kiirzlich ersehienene Arbeiten zum Entwurf effizienter Algorithmen flit diese Probleme. Key words: Visibility Graphs. Shortest Paths, Computational Geometry, Efficient Algorithms. 1 Introduction In recent years extensive research has been done on the design of algorithms for the two fundamental problems in Computational Geometry named in the title of this paper. We will give an overview about the most important results. Moving objects in the presence of obstacles is a frequently occurring problem in everyday life. By the advance of Robotics it has become necessary to do "motion plan- ning" by computers. Typical motion planning problems arise, for example, for a mobile robot moving among obstacles or for an object being moved by a robot arm. In many applications in addition to finding any coUisoion-free path at all for the object, it is desirable to find a short, possibly the shortest path. Frequently, this problem for ob- jects of some nonnegligible diameter can be reduced to a shortest path problem for point-shaped objects by "fattening" the obstalcles in an appropriate way. Most of the 1 Helmut Alt and Emo Welzl, Fachbereich Mathematik, Freie Universitiit Berlin, Arnimallee 2-6, D-1000 Berlin 33, FRG. 0340-9422]88]3/145-164 $2.50 1988 Physica-Verlag, Heidelberg

Upload: jingkui-wang

Post on 03-Oct-2014

71 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Visibility Graphs and Obstacle-Avoiding Shortest Paths

ZOR - Zeitschrift ftir Operations Research, Volume 32, page 145-164

Visibility Graphs and Obstacle-Avoiding Shortest Paths

By H. Alt and E. Welzl 1

Summary: Two closely related problems in Computational Geometry are determining visibility graphs and shortest paths in a two- or three-dimensional environment containing obstacles. Appli- cations are within Computer Graphics and Robotics. We give a survey on recent research done on efficient algorithms for these problems.

Zusammenfassung: Zwei eng miteinander vetwandte Probleme in der algorithmisehen Geometric sind die Bestimmung yon Siehtbarkeitsgraphen und k~zesten Wegen in einer zwei- oder dreidimen- sionalen Umgebung mit Hindernissen. Anwendungen finden sich insbesondere auf den Gebieten Computergrafik und Robotik. Diese Arbeit gibt einen Oberbliek fiber kiirzlich ersehienene Arbeiten zum Entwurf effizienter Algorithmen flit diese Probleme.

Key words: Visibility Graphs. Shortest Paths, Computational Geometry, Efficient Algorithms.

1 I n t r o d u c t i o n

In recent years extensive research has been done on the design of algorithms for the

two fundamental problems in Computational Geometry named in the title of this paper. We will give an overview about the most important results.

Moving objects in the presence of obstacles is a frequently occurring problem in

everyday life. By the advance of Robotics it has become necessary to do "motion plan-

ning" by computers. Typical motion planning problems arise, for example, for a mobile

robot moving among obstacles or for an object being moved by a robot arm. In many

applications in addition to finding any coUisoion-free path at all for the object, it is desirable to find a short, possibly the shortest path. Frequently, this problem for ob-

jects of some nonnegligible diameter can be reduced to a shortest path problem for

point-shaped objects by "fattening" the obstalcles in an appropriate way. Most of the

1 Helmut Alt and Emo Welzl, Fachbereich Mathematik, Freie Universitiit Berlin, Arnimallee 2-6, D-1000 Berlin 33, FRG.

0340-9422]88]3/145-164 $2.50 �9 1988 Physica-Verlag, Heidelberg

Page 2: Visibility Graphs and Obstacle-Avoiding Shortest Paths

146 H. Alt and E. Welzl

Fig. 1. Shortest path between s and t

algorithms assume that the obstacles are polyhedra, i.e. that they are bounded by straight lines in the two-dimensional or by planes in the three-dimensional case, which is a standard representation of geometric objects in computers.

It can be shown that the path of shortest Euclidean length between two points in the plane avoiding polygonal obstacles is a polygonal chain, whose vertices are vertices of the obstacles including source and destination points (cf. Fig. 1).

Consequently, any edge of a shortest path is a straight line segment e between two vertices p and q of obstacles. Since e does not cross any obstacle, p and q are "visible" from each other.

The graph formed by the vertices of the obstacles and these "visibility segments" as edges is called the visibility graph of the polygonal environment. Efficient algorithms for constructing visibility graphs lead to efficient algorithms for the shortest path problem.

There are other applications for visibility graphs, like, for example, the hidden line and hidden surface elimination problems in Computer Graphics.

Algorithms for the visibility graph problem will be presented in Section 2, for the shortest path problem in Section 3.

Unexplained notions from Computational Geometry can be found in [11], [30], or [23 ].

2 Visibili ty Graphs

Let Pbe a set of non-intersecting polygonal obstacles. We denote by V the set of ver- tices and by E the set of edges of polygons bounding the obstacles in P. (From now on we will identify these polygons with the obstacles.) A pair (p, q ) of vertices in V is

Page 3: Visibility Graphs and Obstacle-Avoiding Shortest Paths

Visibility Graphs and Obstacle-Avoiding Shortest Paths 147

-. I \ / /

|1 / II /

J I I /

Fig. 2. Three obstacles and their visibility graph, which consists of the dashed edges and the edges of the polygons

called a visibility if the open line segment joining p and q is either an edge in E or is

disjoint from all obstacles in P. The visibility graph G p of P is the undirected graph with V as set of vertices and

the visibilities as edges (see Fig. 2). There is a straightforward method for computing the visibility graph. For each

pair of vertices in V we check whether the connecting line segment is intersected by any edge in E (or is an edge in E). This gives a simple algorithm using 0(n 3) time,

where n = iV[ = IEi.

2.1 Efficient Construction of Visibility Graphs

We show how to improve the time bound to O(n 2 log n) (such a bound was first

achieved by Lee [18]) and we give some hints how it can be improved further to O(n2). For the purpose of this discussion we assume that no two lines through pairs of points in V are parallel and that no horizontal line contains two points in V.

In order to describe the algorithm we need some notation: Every vertex p in V is endpoint of two edges in E. These edges are denoted by segin(p) and segout(p) in such a way that looking around p in counterclockwise order we encounter segin(p) first, then we look inside the obstacle of which p is a vertex, and then we encounter segout(p)

(see Fig. 3). For a direction d and a vertex p, let raya(p) be the open ray emanating from p in

direction d. The vision visa(p) o fp in direction d is defined as follows:

Page 4: Visibility Graphs and Obstacle-Avoiding Shortest Paths

148 H. Alt and E. Welzl

segout(p} P

segin(p)

Fig. 3. segin(p) and segout(p) of a vertex p in a polygon

(i) visa(p) = ~ if raya(p) intersects no obstacle.

(ii) visa(p) = INT if raya(p) emanates directly into the obstacle of which p is a vertex.

(iii) visa(p) = s if (i) and (ii) do not apply and s is the segment in E which intersects raya(p) closest to p.

The basic idea of the algorithm is to compute visa(p) for all p in V and d = 0 (see Fig. 4). Then we rotate the direction d until d = lr, while updating visa if necessary. Actually, vis a will not change until we "sweep" through a direction determined by two points p and q in V, i.e. q E raya(p), Then visa changes only for p: (d 1 denotes a

direction immediately preceding d, and d 2 denotes a direction immediately succeed- ing d.)

(i) I f visal(P ) = INT and q is the other endpoint of segout(p) or if visal(P) :~ INT and q is an endpoint of visal(p ) then

= / segout(q) i fvisa l (q) = INT

visa2(P) visa 1 (q) otherwise.

Fig. 4. The initial structure for the algorithm

OO

Page 5: Visibility Graphs and Obstacle-Avoiding Shortest Paths

Visibility Graphs and Obstacle-Avoiding Shortest Paths 149

(ii) If visal(p) ~ INT and q lies closer than visal(p ) in direction d then

visa2 (p) = segout(q).

(iii) If viSal(p) = INT and q is not the other endpoint ofsegout(p) or ifvisat(P ) :~ INT and q lies behind visal(P ) in direction d, then no changes occur.

Note that (i) and (ii) imply that (p, q ~ is a visibility and thus an edge of the visibility graph. The algorithm runs now as follows:

(1) Compute vis o ; n,

(2) Sort the (2) pairs of vertices in V by slope of their connecting lines;

(3) Process the pairs in the obtained order as described by the above rules (i) through (iii) and output the respective pair as edge of the visibility graph in cases (i) and (ii).

Step (1) of the algorithm can trivially be implemented in O(n 2) time; a sweep line tech- nique allows to compute vis o even in O(n log n) time. Step (2) takes O(n 2 log n) time by standard sorting techniques. Finally, the processing of every pair in Step (3) can be done in constant time which amounts to O(n 2) for the whole step. We get an overall time complexity of O(n 2 log n).

We observe, however, that the updating schedule (i)-(iii) uses only visax(P) and visa1 (q) for its decisions and computations. It follows that the algorithm still works if we handle the pairs of vertices in an order which ensures that {p, q} preceeds (q, r} whenever the slope of the line through p and q iw smaller than the slope of the line through q and r. In [12] it has been demonstrated that such an order can be computed on the way in O(n 2) time and O(n) working storage. We obtain the following result (see [2], [12], [35]).

Proposition 1: The visibility graph of non-intersecting polygonal obstacles with overall n vertices can be computed in O(n 2) time and linear working storage.

Fig. 5. Obstacle sets with a full and a sparse visibility graph

Page 6: Visibility Graphs and Obstacle-Avoiding Shortest Paths

150 H. Alt and E. Welzl

It should be mentioned that the algorithm even with the O(n 2) improvement is easy to implement (see also [27]), and that the constants hidden in the big "O" are small enough to beat the trivial O(n 3) procedure already for obstacles with 10 vertices.

The result could be considered optimal, since the visibility graph may be the complete graph on the set of vertices and thus have O(n 2) edges, see Fig. 5. However, it is desirable to have an algorithm which runs faster if the visibility graph is small, as, for example, the second picture in Fig. 5 shows.

2.2 Construction of Sparse Visibility Graphs

Ghosh and Mount [14] presented an algorithm using finger trees that computes the visibility graph in O(n log n + m) time, where m denotes the number of edges in the graph. Here we want to sketch a different method from [26] which takes O(m log n) time, but still has two interesting features: First, we still need only O(n) working stor- age, while the other algorithm needs O(m) working storage. Second, the algorithm can be (and has been) implemented with reasonable effort (see [21]) and it showed good performance.

The principal idea is a rotational sweep technique similar to the algorithm we have seen in the previous section. The main difference is that we circumvent "halting" for pairs of vertices where no changes occur and where no edge of the visibility graph is reported (recall case (iii) in the updating scheme). In order to achieve this, we store with every vertex in V the visibility that follows the current direction d. We need a precise definition.

For a vertex p and a direction d, 0 ~< d ~< lr, we define the vertex fola(p) visible from p following direction d as

IOO fola(p) = / q

if viSa'(p) = oo for all d', d <~ d' <~ 7r,

if the previous condition does not apply, and the directed line through p and q is the one with smallest slope among all lines through p and visible vertices (from p) which have slope at least d.

The visibility graph G a of P following direction d is the directed graph with V U {oo) as set of vertices and ((p, fola(p))lp E V) as set of edges (see Fig. 6). An important property of Ga is that its edges never cross.

The first step in the algorithm is the computation of Ga for d = 0. Then we rotate d until d = lr, while replacing edges, when necessary. It is clear that every visibility of P will be replaced once during this rotation, when we report it as an edge of the visibi-

Page 7: Visibility Graphs and Obstacle-Avoiding Shortest Paths

Visibility Graphs and Obstacle-Avoiding Shortest Paths 151

,y / . . - - ' / \ L ,s

Fig. 6. Three obstacles and the visibility graph following direction 0

lity graph. It is clear that always the edge of minimum slope is the next edge to be propagated, and, hence, it remains to understand how such a propagation can be per- formed efficiently.

To this end we need to distinguish properties of edges in Ga. Edge (p, q) is called arriving (departing), if an endpoint of segin(q) or segout(q) lies to the left (right, respectively) of the directed line through p and q.

Informally speaking, an edge is arriving, when it just arrived at an edge in E in the rotational sweep and it is departing, if it will depart from an edge in E. Figure 7 illustrates these notions. Note, that an edge may be both arriving and departing.

Let now (p, q) be the edge we want to propagate. Let d be the slope of the directed line through p and q, and let d 1 and d 2 be directions immediately preceding and suc- ceeding the direction d.

If p and q are the endpoints of segin(p), then p starts to look directly inside its obstacle and so the next vertex visible from p is the other endpoint of segout(p).

P

/ / . ' / ~ "b

Fig. 7. Arriving and departing edges: a), d) arriving; b), e) departing; c) arriving and departing

Page 8: Visibility Graphs and Obstacle-Avoiding Shortest Paths

152 H. Alt and E. Welzl

Fig. 8. Moving a rubber band along a line segment

A more interesting case occurs when the edge (p, q) is an arriving edge and q is not the other endpoint of segin(p). Then let z be the other endpoint of segout(q). Imagine now that a rubber band is stretched from p to q. Keep the end in p fixed and move the end in q along segout(q) until is reaches z, see Fig. 8. Now the rubber band will form a convex polygonal curve from p to z and the first vertex x following p on this curve is the next visible vertex for p.

We proceed in a similar way if (p, q) is not arriving. Then we move the end of the rubber band in q along the edge between q and z = folal (q). The main thing the reader might be worried about right away is that the endpoint to which p is pointing next lies behind the segment between q and z (note that now (q, z) is an edge in the current visibility graph following direction q and not an edge of an obstacle!). Here we recall our remark, that the edges in a visibility graph following a direction d never cross; this immediately outrules this situation, since otherwise the updated graph Ga2 will con- tradict this property.

Now it remains to find the next visible point x algorithmicaUy (if no rubber band is available). Here a new concept becomes crucial.

A chain in a graph Ga (for some d) is a maximal sequence (eo, el . . . . et) of edges in Ga such that the head of e t_ 1 is the tail of e i for all i, 1 ~< i ~< l, and all edges except for e I are last non-departing edges. (An edge e = (p, q) is last non-departing, if it is the

non-departing edge in Ga which is encountered last when rotating counterclockwise a ray around q starting with the direction of segout(q).) It is clear that every edge participates in exactly one chain. Moreover, edges of a chain appear sorted by increas- ing slope and so the edge with smallest slope in Ga (i.e., the edge we want to propagate) is always the first edge of some chain. Going back to the rubber band-approach it can be shown that the polygonal curve from x to z is always a suffix of a chain in the

current graph. The algorithm will identify this chain and compute the tangent point from p on this chain (p, z, and x refer to the rubber band-example!).

Thus chains form the basic data structure for the algorithm and we store them as forward linked lists with two additional pointers from the first to the last element and vice versa. This will allow us to remove the first edge on a chain in constant time, split a chain into two parts at a specific point in constant time, and walk along a chain in constant time per visited edge. Moreover we store with every vertex p a doubly linked list of all ingoing edges sorted by slope, with access to the last edge (i.e. the departing edge not equal segin(p) which is encountered last when rotating counterclockwise a

Page 9: Visibility Graphs and Obstacle-Avoiding Shortest Paths

Visibility Graphs and Obstacle-Avoiding Shortest Paths 153

ray around p starting with the direciton of segout(p)). Now we are ready for an algo- rithmic description of the propagation of an arriving edge (p, q) (when q is not the other endpount of segin (p)):

(1) Let z be the other endpoint ofsegout(q);

(2) Let e be the last edge ofz provided it exists.

(3) If e does not exist, or if (q, z), (p, z), e is the clockwise order of these edges around z, then (p, z) is the edge that replaces (p, q) in the graph. If e exists, then we determine the chain of e (e is the last edge on this chain) and we compute the tangent point x from p on this chain by walking from the first edge of the chain until x is found; now (p, x) replaces (p, q).

If (p, q) is not arriving, then we proceed as in the case of an arriving edge with the ex- ception that (1) and (2) have to be substituted by:

(1') Let z be the point to which q is currently pointing (z = folal(q)).

(2') Let e be the edge which is encountered first when clockwise rotating a ray around

z starting with the direction from z to q.

The only thing that remains to show is how chains change. As mentioned above, the edge we propagate is always the one with minimum slope and so it is the first edge of its chain. So removing this edge from its chain is a simple operation which can be per- formed in constant time. When we add a new edge, either a new chain consisting of this edge is created or the chain we walked along is split into two parts (at the tangent point x) and the new edge is added as the first edge of the second part. The rough

structure of the algorithm is as follows:

(1) Compute G O and initialize the chain structure. Let (p, q) be the edge of minimal slope in G o ;

(2) While q :~ oo do:

Report the pair (p, q) as edge of the visibility graph; Decide whether (i) q is the other endpoint of segin(p), (ii) (p, q) is arriving (and (i) does not apply), or (iii) (p, q) is not arriving (and (i) does not apply); Proceed in either case as described above; Let (p, q) be the edge of minimal slope in the obtained graph.

Using a sweep line technique the graph Go can be computed in O(n log n) time (here we have to apply already some ideas from the main algorithm). In order to find the respective edge of minimum slope we use a priority queue which allows to do so in O(log n) time. Finally, all operations for the propagation of an edge can be performed in constant time, except for the walking along chains. Although these walks may be long in some cases, it can be shown that the average length of such a walk is O(a(n)), where a(n) is the slowly growing inverse of the Ackermann function (we take here the

Page 10: Visibility Graphs and Obstacle-Avoiding Shortest Paths

154 H. Alt and E. Welzl

average over all walks during one computation). Since ct(n) E o(log n), Step (2) has a time complexity of O(log n) per reported edge. The result reads now as follows, see [26] for details.

Proposition 2: The visibility graph of non-intersection polygonal obstacles with overall n vertices can be computed in O(m log n) time with O(n) working storage, where m denotes the number of edges in the computed graph.

As we have mentioned in the beginning of this section, the result is outperformed by the O(n log n + m) bound in [14] if O(m) working space is available. An algorithm by Hershberger [16] computes the visibility graph inside a simple polygon in O(m) time, if the polygon is triangulated. Since the best bound for triangulating a simple polygon with n vertices is O(n log log n) [34], this gives an O(n log log n + m) bound.

We conclude this section by two examples of subgraphs of the visibility graph which are interesting in connection with the subject of the next section, the shortest path problem.

For the first example, let us assume that all obstacles in P are convex. Then Rohnert [32] observes that between any two obstacles P and P' there are at most four visibilities which are possibly used by a shortest path: the four visibilities which lie on the common tangents of P and P'. The reduced visibility graph R p of Pis now the sub- graph of Gp which contains the tangent visibilities only. Rphas at most O(n + k 2) edges, where k denotes the number of obstacles in P, moreover, R pcan be constructed in time O(n + k 2 log n), see [32]. Note that this is considerable saving in time and space if k is small compared to n.

An interesting alternative approach to overcome the drawback of the large num- ber of edges in visibility graphs is described by Chew [6]. He shows that for any set of obstacles P and for any positive integer 1 there is a subgraph of Gpwhich contains O(ln) edges such that the shortest path between any two vertices has length at most

7i" 1 +1 times that of the optimal path in G/9. Since this graph can be constructed in

O(ln log n) time, this approach leads to efficient algorithms for computing approxi- mate shortest paths.

Page 11: Visibility Graphs and Obstacle-Avoiding Shortest Paths

Visibility Graphs and Obstacle-Avoiding Shortest Paths 155

3 Shor tes t Pa th Problems

In this section we will consider shortest path problems (SPP) of the following kind in two- or three-dimensional Euclidean space:

Given a set of obstacles P(like for the visibility problem) and two points s, t, find an obstacle-avoiding path lr(s, t) from s to t (if there is any) of minimum Euclidean length.

In recent years numerous algorithms for shortest path problems of this kind have been developed. We will give an overview of the most important ones. Section 3.1-3.3 will deal with the two-dimensional, Section 3.4 with the three-dimensional case.

3.1 General Polygonal Obstacles

Here we consider the case that the obstacles are polygonal regions, i.e. that they are bounded by straight line segments. Clearly, one can assume that these straight line seg- ments themselves are the obstacles which may not be crossed by any allowable path. (However a path may touch a segment at one of its endpoints or contain the segment partially or completely.)

It is easy to see that there is a strong connection between the shortest path and the visibility problem. Clearly, the shortest path between two points visible from each other is the straight line segment connecting them. An easy geometric argument shows that in general the shortest path between two points must be a polygonal chain whose vertices are vertices of obstacles. Consequently, it must consist of edges of the visibili- ty graph of the set of obstacles including s and t as additional vertices (see Fig. 1). Hence the SPP reduces to an SPP in a graph for which efficient algorithms are known.

These observations, first made by Lozano-Perez and Wesley [20] lead to the fol- lowing algorithm:

Algorithm 3.1 (Planar SPP with Polygonal Obstacles)

1. Determine the visibility graph Gp of the set P o f obstacles including s and t as additional vertices. Mark the edges of Gpwith their Euclidean lengths.

2. Find all shortest paths in G starting from s using Dijkstra's algorithm (see [1] or

[221).

Page 12: Visibility Graphs and Obstacle-Avoiding Shortest Paths

156 H. Alt and E. Welzl

Determining the visibility graph by Proposition 1 takes time O(n 2) where n is the num- ber of obstacle vertices. The standard implementation of Dijkstra's algorithm runs in O(n 2) time, too.

If the visibility graph is sparse, consisting of m edges, it is advantageous to use for step 1 the algorithms discussed in Section 2.2. Ghosh and Mount's algorithm [14] takes time O(m + n log n) and in this case Dijkstra's algorithm can be implemented in time O(m + n log n) as well, using Fibonacci heaps (cf. [13]) as a data structure.

Note, that Dijkstra's algorithm not only finds the shortest path from s to t, but also to all other vertices of the obstracles. It is easy to see that the graph formed by all these shortest paths is a tree, the so-called shortest path tree with root s.

We summarize:

Proposition 3: Variants of Algorithm 3.1 solve the SPP with a set P of polygonal obstracles having a total of n vertices in time O(n 2) or O(m + n log n), where m is the number of edges of the visibility graph of P.

Even the shortest path tree for a given root s can be constructed within these time bounds.

An alternative approach for finding shortest paths does not use the visibility graph but the so-called shortest path map (SPM). For a set of obstacles Panda source s, SPM(P, s) is that partition of the plane (or the three-dimensional space) into regions, where two points p and q lie within the same region exactly if the shortest paths rr(s, p) and rr(s, q) are topologically equivalent, i.e. they touch the same sequence of vertices. Figure 9 shows the SPM for two obstacles and a source s. For example, region R consists of all points t, whose shortest path to s traverses t, q, p, s in that order.

It can be shown that the curves separating different regions of the SPM are hyper- bolic.

The SPP on input s, t, and Pcan be solved by first constructing SPM(P, s) and then locating the region containing t. Efficient point location techniques with run time O(log k), where k is the number of regions, can be found in [30] or [ 11 ].

/s

p / . . . . .

~.~. ~ I ~ ' ~ �9 " ~

\ \

\ \

\

R

Fig. 9. A shortest path map

Page 13: Visibility Graphs and Obstacle-Avoiding Shortest Paths

Visibility Graphs and Obstacle-Avoiding Shortest Paths 15 7

Lee and Preparate [19] use the SPM-approach to give an (n log n) shortest path algorithm for the case that Pis a set of parallel line segments.

For the general case of polygonal obstacles Reif and Storer [31] do an SPM-con- struction to solve the SPP in time O(n(k + log n)), where k is the number of obstacles. Observe that this is O(n 2) in general and O(n log n) for a constant number of obstacles.

The problem of determining shortest paths among polygonal obstacles can be solved more efficiently for the L x-metric instead of the Euclidean metric. Clarkson, Kapoor, and Vaidya [9] found an algorithm for this case based on the visibility-graph approach which runs in time O(n log 2 n).

3.2 Shortest Paths within a Simple Polygon

More efficient algorithms than in the general case can be found if it is assumed that there is only one obstacle which is the region outside a simple polygon. In other words, given a simple polygon P and two points s, t, the problem is to find the shortest path between s and t that lies entirely within P. The algorithm we will present here was found by Lee and Preparata [19].

Algorithm 3.2 (SPP within a simple Polygon)

1. Construct a triangulation of P, i.e. a decompoition of P into disjoint triangular cells whose vertices are vertices of P. At the same time construct the dual graph T to the planar graph given by the triangulation. Since each cell has at most three neighbors and P is simple, T must be a tree (see Fig. 10). Various algorithms for triangulating a simple polygon are known, the asymptotically fastest is by Tarjan and van Wyk [34].

2. In T find the unique simple path from the cell C(s) containing s to the cell C(t) containing t by, for example, depth-first-search in T. This path corresponds to a

sequence C(s) = Co, C 1 . . . . . Ck = C(t) of cells. For i = 1 . . . . . k let d i be the diagonal

#

Fig. 10. A triangulation of a simple polygon P and the dual graph T

Page 14: Visibility Graphs and Obstacle-Avoiding Shortest Paths

158 H. Alt and E. Welzl

~ t Fig. 11. The polygon Q

that separates C/_ 1 from 6"/, and v/1 , v/2 its endpoints. To find the shortest path from s to t it suffices to consider the polygon Q consisting of the triangle ~svt 1 v~, cells C1 . . . . . C k _ l and Av~v~t. Figure 11 illustrates the polygon Q obtained from P, s, and t of Fig. 10.

3. Clearly, the shortest paths lr(s, vt/), / = 1,2 are the straight lines from s to v{. Iteratively, for i = 2 . . . . . k, the shortest paths lr(s, v[), / = 1,2 and zr(s, t) can be constructed in the following way:

Assume w.l.o.g, that v/1 = v/1_ 1- Let a be the last vertex which is common to rr(s, v L 1 ) and rr(s, v L 1 ) (see Fig. 12). The segments ofrr(s, v L 1 ) and rr(s, 2 '/)i-- 1) following a are inward convex and form as so-called funnel F. 7r(s, v2i)must coincide with ~r(s, v}_ 1) and zr(s, v~_ 1) up to a. The remaining polygonal chain r starting from a which completes zr(s, v/2) is constructed in the following way:

a) If v/2 is visible from a, then r is the straight line segment av~.

b) otherwise, find, by a sequential search starting from v/2_ 1, that vertex u of F such that the straight line through v/2 and u is tangent to F in u. r is now the polygonal chain rr(a, u) followed by uv/2. Note, that simultaneously we have found the new funnel F ' to be used in the next step of the iteration.

The run time of this algorithm can be analyzed as follows: Step 1 takes time O(n log log n) if the algorithm by Tarjan and van Wyk is used. Step 2 is a depth first-search on a tree with n vertices and consequently, can be

done in O(n) time.

d F ~',,\i-1 . . . . . \ . . . . . .i.V. 2

a ~ F ' t

Fig. 12. Construction of ~r(s, v 2)

Page 15: Visibility Graphs and Obstacle-Avoiding Shortest Paths

Visibility Graphs and Obstacle-Avoiding Shortest Paths 159

In case b) of step 3 edges of the shortest path tree are traversed in order to find the tangent from v/2 to F. But the edges traversed do not appear in the subsequent funnels any more, so that any edge in the shortest path tree is involved in a search at most once. Since the shortest path tree has O(n) edges, the total run time for all executions of step 3 is O(n).

Summarizing this algorithm, it has been shown:

Proposition 4: Algorithm 3.2 solves the SPP within a simple polygon in time O(n log log n). If a triangulation of P is already given, shortest paths can be found in time O(n).

3.3 Further Results About the Planar SPP

3.3.1 Preproeessing

In many applications of the SPP the environment, i.e. the set Pof obstacles and, some- times, even the source s remain unchanged. The SPP reduces to shortest path queries specified by given points s and t, or only t.

In this situation it is useful to preprocess p (and possibly s) to create a data struc- ture so that these queries can be answered efficiently. Clearly, short query times and a data structure not using too much space are the most important aspects and should be achieved, if necessary, at the expense of a longer preprocessing time.

For a fixed source s it is natural to represent SPM(P, s) in the data structure and for a given target t do a point location in the SPM to find the shortest path. The algo- rithm by Reif and Storer [31 ] mentioned in the previous section, actually uses this idea and obtains, using preprocessing time O(n(k + log n)) and space O(n), a query time of O(log n) to determine the length of the shortest path rr(s, t). The path itself can be determined in time O(b + log n), where b is the number of straight line seg- ments it consists of.

By a generalization of the techniques of Algorithm 3.2 Guibas and Hershberger [15] obtain a linear space data structure for shortest path queries within a simple

polygon P specifying both, source s and target t. The preprocessing time is O(n), if the triangulation of P is already known, O(n log log n) otherwise. The query time is O(log n) for the length of the shortest path.

Page 16: Visibility Graphs and Obstacle-Avoiding Shortest Paths

160 H. Alt and E. Welzl

3.3.2 Motion Planning

A generalization of the SPP is the problem of planning a shortest path motion for not only a single point but some larger object 0 from a given initial position S to a given final position T.

Most algorithms for this problem use an approach by Lozano-Perez and Wesley [20] to reduce the motion planning problem to the SPP by condensing 0 to a single point and, therefore, "fattening" the obstacles appropriately. The problem is that for some objects, e.g. disks, the fattened obstacles are no longer polygons and the number of vertices can grow from n to |

Baker [3] and Chew [7] obtained an O(n 2 log n) algorithm for disks by a visibility graph approach, Reif and Storer improved the run time to O(n 2) using the SPM- approach.

The most general result was obtained by Hershberger and Guibas [17], who generalized Baker's and Chew's algorithms. They obtained an O(n 2) algorithm for arbitrary convex objects 0 for the case that the motion consists of a sequence of trans- lations and no rotations are allowed.

The problem becomes very difficult if arbitrary motions, rotations and transla- tions, are allowed. Even the definition of "shortest path" becomes problematic. For the case of a convex polygonal object with one fixed reference vertex which must move along edges of the visibility graph and around which rotations are allowed, Papadimitriou and Silverberg [29] developped an O(n 4 log n) algorithm.

3.3.3 The Weighted Region Problem

An interesting generalization of the shortest path problem is the weighted region prob- lem defined by Mitchell and Papadimitriou in [24]. Here, the plane is partitioned into different polygonal regions to each of which a certain constant weight is assigned. The length of a path is now defined by multiplying for each segment lying within one re- gion its Euclidean length with the weight factor of that region. The problem is to find the shortest path between two given points s and t for this definition of length. Clear- ly, the original SPP is a special case of the weighted region problem, namely, assigning weight 1 to the free space and weight oo to the obstacle regions.

A motivation for the weighted region problem is the so-called terrain navigation problem. Consider a vehicle moving within a terrain consisting of different regions, like for example forest, water, sand, buildings, highways, etc. within which different speeds are possible. The objective is to find a path from a point s to a point t taking minimal time.

Page 17: Visibility Graphs and Obstacle-Avoiding Shortest Paths

Visibility Graphs and Obstacle-Avoiding Shortest Paths 161

Mitchel and Papadimitriou observe that shortest paths consist of straight lines within regions. At transition points from one region to another Snell's law of refrac- tion, known from optics, holds and serves as a local optimality criterion. Using these observations and a continuous version of Dijkstra's algorithm they give an algorithm finding shortest paths in time O(nTL), where n is the number of vertices of the regions and L is the number of bits to represent the input and the output.

3.4 Shortest Paths in Three-Dimensional Space

In three-dimensional space the shortest path problem in the presence of obstacles turns out to be considerably more difficult than in the plane. In the case of polyhedral obstacles shortest paths are still polygonal chains, but their vertices don't have to be vertices of the obstacles any more. Instead, they may lie somewhere in the interior of obstacle edges. Consequently, it seems at first that these points can only be deter- mined by numerical approximation methods.

The first result in this direction was obtained by Schorr and Sharir [33]. They gave an algorithm which essentially tests for each possible sequence of obstacle edges the shortest path passes through. As it can be expected, the run time is more than ex- ponential, in fact O(nn), even when it is assumed that the vertices of shortest paths are approximated numerically in an efficient way. The authors also could show that the problem can be solved exactly by symbolic computation using the cylindrical algebraic decomposition technique by Collins [10]. However, then the complexity of the algo- rithm becomes even doubly exponential, in fact O((4n)3n).

Reif and Storer [31] improved this algorithm and obtained a run time of O(n~r), where k is the number of obstacles and r some constant.

Recently, by introducing new algebraic computation techniques, Canny [4] could improve upon all these results, giving an algorithm of single exponential run time. It works not only if the obstacles are polyhedral, but even if they are bounded by arbi- trary algebraic surfaces. In addition the object to be moved may not only be a single point but a whole connected system of bodies bounded by algebraic surfaces.

Still it is not known if an efficient, i.e. polynomial time algorithm exists even for the SPP with polyhedral obstacles. A recent result by Canny and Reif [5 ] suggests that this is probably not the case. They proved that even the problem of determining the length of the shortest path is NP-hard (see [22]). This was done by reducing the saris- fiability problem of propositional logics to the shortest path problem.

Consequently, it is reasonable to look for efficient approximation algorithms for the SPP in three-dimensional space. Papadimitriou [28] developed a polynomial time approximation algorithm finding a path whose length is at most (1 + e) times the length of the shortest path, where e is a constant which can be chosen arbitrarily.

Page 18: Visibility Graphs and Obstacle-Avoiding Shortest Paths

162 H. Alt and E. Welzl

The algorithm discretizes the problem by dividing obstacle edges into subsegments in a

clever way. Its exact run time is O(n3K2/e), where K is the number of bits necessary

to represent the input including e. Recently, Clarkson [8] gave an alternative approximation algorithm for this prob-

lem, which is faster if e is not too small, i.e. ne 3 is large. This algorithm is based on the

visibility graph approach and constructs a kind of approximate visibility graph in which shortest paths are not much longer than within the real visibility graph. It

should be mentioned that Clarkson also used this approach for the two-dimensional

SPP and obtained an approximation algorithm of runtime O(n log n/e) (see also Chew's

result at the end of Section 2). An interesting special case of the shortest path problem in three dimensions is the

so-called discrete geodesic problem, which means finding shortest paths on the surface

of polyhedra. The problem was first addressed by Schorr and Sharir [33], who for the case of convex surfaces found an algorithm of run time O(n 3 log n). Later Mitchel, Mount, and Papadimitriou [25] gave an algorithm of run time O(n 2 log n), which

solves the problem for arbitrary polyhedra. Their approach is similar to the one used

for the weighted region problem using a continuous version of Dijkstra's algorithm.

Here, instead of Snell's Law, the fact that for a shortest path traversing a polyhedral edge the incoming ray must form the same angle with the edge as the outgoing one, is

used as a local optimality criterion.

R e f e r e n c e s

[1] Aho AV, Hopcroft JE, Ullman JD (1974) The design and analysis of computer algorithms. Addison-Wesley

[2] Asano T, Asano T, Guibas L, Hershberger J, Imai H (1986) Visibility of disjoint polygons. Algorithmica 1:49-63

[3] Baker B (1985) Shortest paths with unit clearance among polygonal obstacles. SIAM Con- ference on Geometrical ModeUing and Robotics

[4] Canny J (1987) A new algebraic method for robot motion planning and real geometry. In: Proceedings of the 28th IEEE Symposium on Foundations of Computer Science, pp 39-48

[5] Canny J, Reif J (1987) New lower bound techniques for robot motion planning problems. In: Proceedings of the 28th IEEE Symposium on Foundations of Computer Science, pp 49-60

[6] Chew LP (1987) Planar graphs and sparse graphs for efficient motion planning in the plane. Manuscript

[7] Chew LP (1985) Planning the shortest path for a disk in O(n 2 log n) time. In: Proceedings of the 1st Annual Symposium on Computational Geometry, pp 214-220

Page 19: Visibility Graphs and Obstacle-Avoiding Shortest Paths

Visibility Graphs and Obstacle-Avoiding Shortest Paths 163

[8] Clarkson K (1987) Approximation algorithms for shortest path motion planning. In: Proceed- ings of the 19th Annual ACM Symposium on Theory of Computing, pp 56-65

[9] Clarkson K, Kapoor S, Vaidya P (1987) Rectilinear shortest paths through polygonal obstacles in O(n log 2 n) time. In: Proceedings of the 3rd Annual Symposium on Computational Geome- try, pp 251-257

[10] Collins GE (1975) Quantifier elimination for real closed fields by cylindric algebraic decom- position. In: Proceedings 2nd GI-Conference on Automata Theory and Formal Languages, Lecture Notes in Computer Science 35, Springer-Verlag, pp 134-183

[11] Edelsbrunner H (1987) Algorithms in combinatorial geometry. Springer-Verlag [12] Edelsbrunner H, Guibas L (1986) Topologically sweeping in an arrangement. In: Proceedings

of the 18th ACM Symposium on Theory of Consumpting, pp 389-403 [13] Fredman M, Tarjan R (1987) Fibonacci heaps and their uses in improved network optimiza-

tion algorithms. J of the Association for Computing Machinery 34:596-615 [14] Ghosh SK, Mount DM (1987) An output sensitive algorithm for computing visibility graphs.

In: Proceedings of the 28th Annual Symposium on Foundations of Computer Science, pp 11- 19

[15] Guibas LJ, Hershberger J (1987) Optimal shortest path queries in a simple polygon. In: Proceedings of the 9rd Annual Symposium on Computational Geometry, pp 50-63

[16] Hershberger JE (1987) Efficient algorithms for shortest path and visibility problems. Disserta- tion, Stanford University

[17] Hershberger JE, Guibas LJ (1986) An O(n 2) shortest path algorithm for a non-rotating con- vex body. Technical Report, DEC Systems Research Center

[181 Lee DT (1978) Proximity and teachability in the plane. Dissertation, University of Illinoisat Urbana-Champaign

[19] Lee DT, Preparata FP (1984) Euclidean shortest paths in the presence of rectilinear barriers. Networks 14:393-410

[20] Lozano-Perez T, Wesley MA (1979) An algorithm for planning collision-free paths among polyhedral obstacles. Communications of the ACM 22:560-570

[211 Masser M (1988) Algorithmen zur Konstruktion yon Sichtbarkeitsgraphen. Diplomarbeit, Institutes for Information Processing, IIG, Technical University of Graz, in preparation

[221 Mehlhorn K (1984) Data structures and algorithms 2: graph algorithms and NP-completeness. Springer-Verlag

[23] Mehlhorn K (1984) Data structures and algorithms 3: multidimensional searching and com- putational geometry. Springer-Verlag

[24] Mitchell JSB, Papadimitriou CH (1987) The weighted region problem. In: Proceedings of the 3rd Annual Symposium on Computational Geometry, pp 30-38

[25] Mitchel JSB, Mount DM, Papadimitriou CH (1987) The discrete geodesic problem. SIAM J Computing 23:647-668

[261 Overmars M, Welzl E (1987) Construction of sparse visibility graphs. Report RUU-CS-87-9, Department of Computer Science, University of Utrecht

[271 Overmars M, Welzl E (1988) New methods for computing visibility graphs. To appear in: Proceedings of the 4th Annual Symposium on Computational Geometry

[281 Papadimitriou CH (1985) An algorithm for shortest path motion in three dimensions. Inform Process Lett 20:259-263

[291 Papadimitriou CH, Silverberg EB (1986) Optimal piecewise linear motion of an object among obstacles. Technical Report, Dept. of Operations Research, Stanford University

[301 Preparata FP, Shamos MI (1985) Computational geometry. Springer Verlag

Page 20: Visibility Graphs and Obstacle-Avoiding Shortest Paths

164 H. Alt and E. Welzl: Visibility Graphs and Obstacle-Avoiding Shortest Paths

[31] Reif J, Storer JA (1985) Shortest paths in Euclidean space with polyhedral obstacles. Tech- nical Report CS-85-121, Computer Science Department, Brandeis University

[321 Rohner H (1986) Shortest paths in the plane with convex polygonal obstacles. Inform Process Lett 23:71- 76

[33] Schorr A, Sharir M (1986) On shortest paths in polyhedral spaces. SIAM J Computing 15: 193 215

[34] Tarjan RE, van Wyk C (1986) An O(n log log n)-time algorithm for triangulating simple poly- gons. Manuscript

[35] Welzl E (1985) Constructing the visibility graph for n line segments in O(n 2) time. Inform Process Lett 20:167-171