Point in Planar Subdivision

11.2.2 Point in Planar Subdivision

We are now ready to address the more general problem of locating a point in a planar subdivision. Our parallel algorithm uses the mesh of trees architecture (introduced in problem 4.2 and first used in section 9.2.2). Assume that the planar subdivision consists of m polygons, each with at most n edges. We use an m x n mesh. Each of the m rows, numbered 1, .. . , m, is a binary tree of processors storing the edges of one polygon, one edge per processor. Each of the n columns, numbered 1, ... , is also a binary tree (although in this context we shall only make use of the tree in column 1).

The idea of the algorithm is to feed the coordinates of the query point p to the root processor of every row tree. This can be done using the tree connections in column 1. Procedure POINT IN POLYGON is now performed simultaneously by all

rows. The procedure is slightly modified so that (i) when it starts, the root processor in every row already contains

and (ii) when it terminates, the root processor in row i produces the pair

i) as output if p is inside the associated polygon; otherwise it produces

i). By using the tree connections in column 1 and the logical or operation on the first

components of the output pairs, either (i) the (unique) polygon containing p can be identified or

(ii) the fact that p is not inside any of the polygons can be established. The algorithm is given in what follows as procedure POINT IN SUBDIVISION. The

processor in row i and column j is denoted j). The output pair for root processor

1) is denoted (a,, where is either or 1 and is a row number.

Computational Geometry Chap. 11 procedure POINT IN SUBDIVISION

Step 1:

reads

Step 2: for i =

+ 1) - 1 1 do

1 do in parallel

end for end for.

Step 3: for i =

1 to m do in parallel

Processors

1) to

n) execute POINT IN POLYGON

end for.

Step 4: for i =

1 to

+ 1) - 1 do

o in parallel if

else if

end if end if end for end for.

Step 5:

produces (a,,

as output.

Note that when the procedure terminates, if a, = 1, then this means that the polygon numbered

contains p. Otherwise a, = in which case p is outside of the planar subdivision.

Example 11.2

The subdivision in Fig. 11.1 requires a 7 x 6 mesh of trees, as shown in Fig. 11.4 (where the tree connections are omitted for simplicity). When the coordinates of point p in Fig.

while all other rows produce

11.1 are given as input to the mesh of trees, row 3 produces

i), i

3. Thus ( 1 , 3) is the mesh's output.

Analysis. Steps 1 and 5 run in constant time. Steps 2 and 3 take m) and n) time, respectively. Step 4 also requires

m) time. Assuming that m is

= O(n 2 log n). This cost is not optimal given that a sequential algorithm that applies the

n). Since

= n 2 , the procedure's cost is

polygon inclusion test to each of the m polygons runs in

time.

If k points p are queued for processing, they can be pipelined and the procedure would require O(k + logn) time to answer all k queries. Finally, using the same

1 1.3 An Intersection Problem

Figure 11.4 Testing point inclusion using procedure POINT IN SUBDIVISION.

approach as with procedure POINT I N POLYGON, procedure POINT IN SUBDIVISION can be made to have a cost of O(n 2 ). This is illustrated in the next section.

11.3 A N INTERSECTION PROBLEM

In many applications, it is required to determine whether a set of geometric objects intersect. Thus, for example,

(i) in pattern it is necessary to determine whether different regions in space representing different classes have common subregions;

286 Computational Geometry Chap. 11 (ii) in integrated circuit design it is important to avoid crossing wires and

overlapping components; and (iii) in computer graphics it is required to remove hidden lines and hidden surfaces

from two-dimensional representations of three-dimensional scenes. In this section we examine one such intersection problem.

Two polygons Q and R are said to intersect if an edge of Q crosses an edge of R. Note that the two polygons need not be simple, that is, two or more edges of Q (or two or more edges of R) may cross. Figure 11.5 illustrates two intersecting polygons. Let Q and R be two polygons, each given by a list of its edges. It is required to determine whether Q and R intersect. Our parallel solution to this problem is based on a straightforward approach: For each edge of Q we determine whether it crosses one of

the edges of R. Assume that Q and R have m and n edges, respectively, each being given by the coordinates of its two endpoints. We use a mesh of trees with m rows and

n columns. Each processor is loaded with log n edges of R so that (i) the set of edges contained in a row is the set of edges of R and

(ii) the processors in each column contain the same subset of logn edges of R. Loading the processors in each column is done by pipelining the log n edges assigned

to that column through its root processor. When a processor receives an edge, it stores it in its own memory and sends a copy of it to each of its two children using the tree connections in that column. It therefore takes

n) time to load a column. If all columns are loaded simultaneously, then this would also be the time taken to load the entire mesh. In addition, each processor receives an edge of Q so that

m) +

(i) the set of edges contained in a column is the set of edges of Q and (ii) the processors in each row contain the same edge of Q.

Figure 11.5 Two intersecting polygons

A Proximity Problem 287 The edges of Q are fed into the mesh, one edge per row, through the root processor in

each row. When a processor in a given row receives the edge assigned to that row, it stores it in its own memory and sends a copy of it to each of its two children, using the

tree connections in that row. It takes n) steps to load a row. If all rows are loaded simultaneously, then this would also be the time taken to load the entire mesh. Now each processor tests whether the edge of Q assigned to it crosses one of the log n edges of R it also contains. If this is the case, it produces a 1 as output; otherwise it produces a With all processors operating simultaneously, this step takes

n) time. The outputs in each row are combined level by level, beginning from the leaves and all the way to the row's root processor. This is accomplished by requiring each processor to compute the logical or of three quantities: the two inputs received from its children and its own output. The processor then sends the result of this operation to

its parent. After steps the root processor in each row would have computed the logical or of all outputs in that row, which it retains. These processors combine their results in the same way using the tree connections in column 1. This

requires another log m steps. Assuming that m n, the overall running time of the algorithm is

n).

Since = O(n 2 /log n), the algorithm's cost is O(n 2 ). The only known lower bound on the number of steps required to solve this problem is the trivial one of

operations performed while reading the input. Furthermore, it is not known whether a sequential algorithm exists with a smaller than quadratic running time. The algorithm's cost optimality is therefore an open question.