# keypoints (DOC)

Document Sample

```					                            Polygon Intersection
intersection. A brute force approach will be to compare all the possible n2
pairs possible with n line segments, which takes O(n2) time.

Bentley and Ottmann proposed a line segment intersection reporting
algorithm. A plane-sweep algorithm, maintaining active list of segments that
intersect the sweepline, sorted from bottom to top by intersection point. Thus
we need to compare only consecutive pairs rather than all n2 pairs. It takes
O((n+k) log n) time for reporting which has the worst time O(n2).

Edlesbrunner and Chazelle presented an improved algorithm with O(n log n +
k) complexity. Their algorithm takes O(n + k) space. Later Clarkson and Shor
came with a randomized algorithm with same expected running time but only
O(n) space.

S3
S4

S2

S1

Fig 1 : Illustrating plane-sweep algorithm
Intersection Detection in Convex Polygon

With this introduction we move on to Polygon Intersection. The problem of
intersection detection is to yield an efficient intersection test of two convex
polygons. This is a Dobkin and Krickpatrick algorithm that runs in O(log n)
time.

Consider two convex polygons P and Q which are represented as array of
vertex coordinates. The vertices with highest and lowest
y-coordinates can be found in O(log n) time. The
P
boundary of each polygon is split into two semi-infinite
convex chains, denoted PL, PR and QL, QR. P and Q
intersect if and only if PL and QR intersect, or PR and QL

PR             intersect.
PL

(a)

QR         eq
PL                 QR
QR              PL
ep                                         eq
ep

PL

(b)                                             (c)                           (d)

Fig 2: Intersection detection for two convex polygons

This algorithm applies a variant of binary search. By simple analysis of the
relative positions and intersection point of the two lines on which the
medians lie, it si possible to determine in constant time either that the
polygons intersect, or that half of at least one of the two boundary chains
can be eliminated from further consideration. In the above figure, the shaded
lines indicate the eliminated boundary portion.

Convex Polyhedra in 3-Space

Dobkin and Kirkpatrick showed that the detection of intersection in 3-space
can be performed effectively by some preprocessing involving Kirkpatrick‟s
hierarchial decomposition of planar triangles.

Dobkin – Kirkpatrick Decomposition

k-2 level                             k-1 level                               k level

Fig 3: Hierarchical Decomposition of convex polyhedra 3-space

Assume that P‟s faces have been triangulated and P = P0 be the initial
polyhedron. Let „n‟ denote the number of vertices in this graph. Every planar
graph has an independent set that contains a constant fraction of the vertices
formed entirely from vertices of bounded degree. Such an independent set is
computed and is removed along with any incident edges and faces from P.
Then any resulting “holes” in the boundary of P are filled with triangles,
resulting in a convex polyhedron with fewer vertices.

These holes can be triangulated in constant time, independently of one
another. The resulting convex polyhedron is denoted P1. The process is
repeated until reaching a polyhedron of at most four vertices. The result is a
sequence of polyhedra, <P0, P1,…, Pk>, called Dobkin - Kirkpatrick hierarchy.
The depth of the hierarchy is O(log n).

Intersection Detection Algorithm
The intersection detection algorithm computes the separation, i.e., the
minimum distance between the two polyhedra P and Q. The separation at the
highest common level of the two hierarchies is computed so that at least one
of the decomposed polyhedra is of bounded complexity. It is shown that it
takes O(log np + log nq) to determine the separation of the polyhedra at the
next lower level of the hierarchies. This leads to a total running time of O(log
np log nq).

The Algorithm
Briefly...
Let P and Q be two convex polygons whose intersection is a convex polygon.
The algorithm for finding this convex intersection polygon can be described
by these three steps:

1. Construct the convex hull of the
union of P and Q;
2. For each pocket lid of the convex
hull, find the intersection of P and
Q that lies in the pocket;
3. Merge   together     the   polygonal
chains between the intersection
points found in 2.

Fig 4 (a): Pocket Lid
What's a pocket lid?
A pocket lid is a line segment belonging to the convex hull of the union of P
and Q, but which belongs to neither P nor Q.

Why does it connect a vertex of P with a vertex of Q?
A pocket lid connects a vertex of P with a vertex of Q; if it were to connect
two vertices of P, then P would not be convex, since the lid lies on the convex
hull and is not a segment of P.

In detail...

Computing the Convex Hull: the Rotating Calipers

To compute the convex hull of the two convex polygons, the algorithm uses
the rotating calipers. It works as follows:

1. Find the leftmost vertex of each polygon.
2. At each of those two vertices, place a vertical line passing through it.
Associate that line to the polygon to which the vertex belongs. The line
does not intersect its associated polygon, since the polygon is convex.
See the figure below:

Fig 4 (b), 4(c): Finding the pocket lids
3. Rotate these two lines (called calipers) by the smallest angle between
a caliper and the segment following the vertex it passes through (in
clockwise order). The rotation is done about the vertex through which
the line passes on the associated polygon. If the line passes through
more than one vertex of the associated polygon, the farthest (in
clockwise order) is taken. The result is show in fig 4(c).
4. Whenever the order of the two calipers change, a pocket has been
found. To detect this, a direction is associated to one of the lines (for
example the green one, associated to P). Then all points of the red line
(associated to Q) are either to the left or to the right of the green line.
When a rotation makes them change from one side to the other of the
green line, then the order of the two lines has changed. Here's what
our example looks like just before and after the algorithm has found
the first pocket; as you can see, if the line associated with P initially
had its associated direction pointing up, then the line associated with
Q was to the right of it at the beginning, and is now to the left of it:

Fig 4(d), 4(e): Finding the pocket lids

5. The algorithm terminates once it has gone around both polygons.

Finding the intersection of P and Q in the pocket

Once the pockets have been found, the intersection of the polygons at the
bottom of the pocket needs to be determined. The pockets themselves form
a very special type of polygon: a sail polygon: that is, a polygon composed of
two concave chains sharing a common vertex at one extremity, and
connected by a segment (the mast) at the other end. By a procedure similar
to a special-purpose triangulation for sail polygons, the segments of P and Q
which intersect can be identified in O(k+l), where k and l are the number of
vertices of P and Q which are inside the pocket. The idea is to start the
triangulation from the mast, and as points from P and Q are considered, a
check is made to see that the chain from Q is still on the same side as the
chain from P.

Merging

What remains to be done is to build the resulting polygon. One way of doing
this   is   to   start   at   one   of   the   vertices   given   by   the   above
algorithm, compute the intersection, add that point, and then to continue
adding points by following either P or Q deeper below the pocket until it
comes out of another pocket (i.e. until the vertex to consider for addition
happens to have been the output of the algorithm for another pocket). Then
from that pocket the chain of the other polygon can be followed under the
pocket. This would be done until the pocket the chain comes out of is the
pocket that the merging started with.

Checking for intersection

All of this assumes that the polygons do intersect. However, there are three
ways in which no polygonal intersection could exist:

1. The intersection is either a point or a line. No provisions are made for
this in the algorithm, and in this case the output will be a polygon
consisting of either two vertices at the same location(in the case of a
point), or four vertices on two distinct locations (in the case of a line);
2. The polygons simply do not intersect each other and are separable;
3. The polygons are one inside another. One could argue that the
intersection of two such polygons is the contained polygon, but that is
the computer graphics way of seeing things. In mathematics, there is
no intersection in such a case. In any event, the algorithm has to
detect this case independently of whether or not it outputs it as an
intersection or not.

For case 2, this is detected if, during the triangulation step, the algorithm
makes a complete loop around one of the polygons. Detecting case 3 is even
easier to detect; in such a case no pockets will be found by the convex hull
algorithm.
Bibilography

•   A Hand book of Discrete and Computational Geometry – Goodmann
and Rourke
•   The Intersections for a Set of 2D Segments, and Testing Simple
Polygons - Dan Sunday
•   Determining the Separation of preprocessed Polyhedra–A Unified
Approach – David P.Dobkin, David G.Kirkpatrick
•   Intersecting Convex Polygons

```
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
 views: 5 posted: 11/30/2011 language: English pages: 9