Lecture 11 Intersection - PowerPoint PPT Presentation

1 / 57
About This Presentation
Title:

Lecture 11 Intersection

Description:

Detect any edge intersection between P and Q by using the Line Segment Intersection Test. ... which side of X' (right or left) any feasible value of X may lies; ... – PowerPoint PPT presentation

Number of Views:73
Avg rating:3.0/5.0
Slides: 58
Provided by: Kai71
Category:

less

Transcript and Presenter's Notes

Title: Lecture 11 Intersection


1
Lecture 11 Intersection
2
The goal of the chapter
  • To study intersection problems of a set of
    geometric objects
  • Geometric objects polygons, segments, polyhedra,
    etc.
  • To study four kinds of intersection problems

3
Intersection Problems 4
  • Intersection Construction
  • Given two geometric objects, compute (or
    construct) their intersection.

4
Intersection Problem 3
  • Intersection Detection
  • Given two geometric objects, do they
    intersect?
  • Intersection detection is frequently easier than
    the corresponding construction problem

5
Intersection Problem 2
  • Pairwise Intersection
  • Given n geometric objects,
  • determine whether any two intersect?
  • report all intersecting pairs.
  • For testing problem we look for an algorithm that
    avoids testing each object against every other
    object.

6
Intersection Problem 1
  • Common Intersection
  • Given n geometric objects, find the common
    intersection of all geometric objects.

7
Linear Programming 2
  • LP can be viewed as a common intersection
    problem.
  • The feasible region of an LP problem is the
    intersection of the half-spaces determined by its
    constraint set.
  • The objective function is optimized at some
    vertex (extreme point) of the feasible region
    (convex polyhedron or polytope).

8
Linear Programming 1
  • By constructing the common intersection of these
    n half-spaces, we can obtain a solution to LP by
    examining each extreme point.
  • However, all we need is the identification of one
    vertex for which the objective function is
    optimized and there is no reason to think that
    the complete construction of the feasible region
    is necessary.
  • The two problems are not equivalent !

9
Intersection of convex polygons
  • Problem Given two convex polygons, P with L
    vertices and Q with M vertices, compute their
    intersection
  • Brute force method O(LM)
  • Theorem The intersection of a convex L-gon and a
    convex M-gon can be computed in ?(LM) time.

10
Trivial method for computing intersection of
convex polygons 2
  • The boundary of P?Q consists of alternate chains
    of vertices of the two polygons, interspersed
    with points at which the boundaries intersect.

Red, Black, Blue, Black,
11
Trivial method for computing intersection of
convex polygons 1
  • To proceed around P, edge by edge, finding all of
    the boundary intersection point involving Q and
    keeping a list of the intersection points and
    vertices along the way.
  • This takes O(LM) time because each edge of P will
    be checked against every edge of Q to see if they
    intersect.
  • Can this method generalize to solve the
    intersection of two general polygons ? YES

12
?(LM) algorithm for computing intersection of
convex polygons 2
  • The approach consists in subdividing the plane
    into regions, in each of which the intersection
    of the two polygons can be easily computed.

Inside a slab each polygon forms a trapezoid
13
?(LM) algorithm for computing intersection of
convex polygons 1
  • To partition plane into regions. O(LM)
    merge-sort
  • The boundary of each polygon is divided into two
    monotone chains by the left and right extreme
    points.
  • Perform a plane-sweep algorithm (merge-sort) from
    left to right to partition the interior of each
    polygon into trapezoids.
  • The key observation is that in each slab the
    intersection of P and Q is an intersection of two
    quadrilaterals, which can be found in O(1) time.
    The resulting pieces can be fitted together in
    O(LM) time. O(LM)
  • Question Can this method generalize to solve the
    intersection of two star-shaped polygons or two
    general polygons ? NO

14
Intersection of star-shaped polygons 3
  • Problem Given two star-shaped polygons, P and Q,
    compute their intersection

Figure 1
15
Intersection of star-shaped polygons 2
  • The intersection of two star-shaped polygons P
    Q is not a polygon, but is a union of many
    polygons.
  • In figure 1, P Q both have n vertices, and
    every edge of P intersects every edge of Q, so
    the intersection has order of n2 vertices.

16
Intersection of star-shaped polygons 1
  • Theorem Finding the intersection of two
    star-shaped polygons requires ?(n2) time in the
    worst case.

17
Intersection of general polygons
  • Problem Given two general polygons, P and Q,
    compute their intersection

18
Intersection computation
  • The intersection of two convex polygons ?(n)
  • The intersection of two star-shaped polygons
    ?(n2).
  • The intersection of two general polygons ?(n2).
  • But it may not be necessary to spend this much
    time if we only want to know whether two polygons
    P Q intersect at all.

19
Intersection of line segments
  • Problem (Line Segment Intersection Test) Given n
    line segments in the plane, determine whether any
    two intersect.
  • Brute-force Take each pair of segments and
    determine whether they intersect. This takes
    O(n2) time.
  • Theorem Whether any two of n line segments in
    the plane intersect can be determined in ?(n log
    n) time.

20
Polygon Intersection Test
  • Problem (Polygon Intersection Test)
  • Given two simple polygons P and Q, determine
    if they intersect.
  • Polygon Intersection Test ?O(n) Line Segment
    Intersection Test
  • Detect any edge intersection between P and Q by
    using the Line Segment Intersection Test.
  • If no intersection is found, we must test whether
    P?Q or Q?P. If P?Q, then every vertex of P is
    internal to Q, so we may apply the single-shot
    point inclusion test in O(n) time using any
    vertex of P.

21
Simple Polygon Test
  • Problem (Simplicity Test)
  • Given a polygon, determine if it is simple.
  • Simplicity Test ?O(n) Line Segment Intersection
    Test

22
Line segment Intersection Problem in R1
  • Suppose we are given n intervals on the real line
    and wish to know whether any two overlap.
  • This can be answered in O(n2) time by inspecting
    all pairs of intervals
  • If we sort the 2n endpoints of the intervals and
    designate them as either right or left, then the
    intervals themselves are disjoint if and only if
    the endpoints occur in alternating order L R L
    R... R L R. This test can be performed in O(n log
    n) time.

23
  • Two questions
  • Can this algorithm be improved?
  • Can it generalize to two dimensions, i.e. to the
    case when the line segments are arbitrarily
    oriented?

24
Lower Bound
  • Element Uniqueness (Element Distinctness) Problem
    (Given n real numbers, are they all distinct ?)
    requires ?(n log n) time in algebraic computation
    tree computation model
  • Element Uniqueness ?O(n) Interval Overlap.
  • Given a collection of n real numbers xi, they can
    be converted in linear time to n intervals xi,
    xi. These intervals overlap if and only if the
    original points are not distinct .
  • We conclude that ?(n log n) comparisons are
    necessary and sufficient to determine whether n
    intervals in R1 are disjoint.

25
Generalize Interval Overlap Problem in R1 to R2
  • The idea behind Interval Overlap Algorithm in R1
    If any two intervals contain a point of the same
    x-coord, then the two intervals overlap.
  • The idea behind Line Segment Intersection
    Algorithm in R2 Even though two line-segments
    contain a point of the same x-coord., i.e. both
    are intersected by a vertical line, it doesnt
    mean that these two line-segments intersect.
  • For each vertical line L, the line segments
    intersected by L are ordered in y-coord. by their
    intersections.
  • When two line segment cross each other, they must
    be adjacent in y-coord. for some vertical line L.

26
Line-segment Intersection Algorithm 10
  • Line-segment Intersection problem can be solved
    by plane-sweep technique.
  • plane-sweep technique makes use of two basic data
    structures the sweep-line status and the
    event-point schedule.

27
Line-segment Intersection Algorithm 9
  • sweep-line status a data structure maintaining
    the ordering of line segments intersecting with a
    give sweep line L and must support the following
    operations (a height-balanced tree will do)
  • INSERT(s, L). Insert segment s into the total
    order maintained by L. O(log n)
  • DELETE(s, L). Delete segment s from L. O(log n)
  • ABOVE(s, L). Return the name of the segment
    immediately above s in the ordering. O(1)
  • BELOW(s, L). Return the name of the segment
    immediately below s in the ordering. O(1)

28
Line-segment Intersection Algorithm 8
  • event-point schedule a data structure recording
    the ordering of events at which the sweep-line
    status changes and it must support the following
    operation (A min-priority queue will do)
  • MIN(E). Determine the smallest element in E and
    delete it O(log n)
  • INSERT(x, E). Insert abscissa x into the total
    order maintained by E. O(log n)
  • MEMBER(x, E). Determine if abscissa x is a member
    of E. O(log n)

29
Line-segment Intersection Algorithm 7
  • The ordering of line segments can change in only
    three ways for each sweep-line
  • 1. At the left endpoint of segment s. In this
    case s must be added to the ordering.
  • 2. At the right endpoint of segment s. In this
    case s must be removed from the ordering.
  • 3. At an intersection point of two segments s1
    and s2. Here s1 and s2 exchange places in the
    ordering.

30
Line-segment Intersection Algorithm 6
  • We now outline the algorithm as the vertical
    line sweeps the plane, at each event point
    sweep-line status L is updated and all pairs of
    segments that become adjacent in this update are
    checked for intersection.

S1 ABOVE(s2, L) S3 BELOW(s2, L)
31
Line-segment Intersection Algorithm 5
  • procedure LINE SEGMENT INTERSECTION
  • sort the 2n endpoints lexicographically by x and
    y and place them into priority queue E
  • A ?
  • while (E ? ?) do
  • p MIN(E)
  • if (p is left endpoint)
  • then HANDLE LEFT EVENT(p)
  • else if (p is a right endpoint)
  • then HANDLE RIGHT EVENT(p)
  • else HANDLE INTERSECTION EVENT(p) /P is an
    intersection/
  • while (A ? ?) do
  • (s, s') ? A
  • x common abscissa of s and s'
  • if (MEMBER(x, E) FALSE)
  • then output (s, s')
  • INSERT(x, E)

32
Line-segment Intersection Algorithm 4
  • HANDLE LEFT EVENT(p)
  • s segment of which p is an endpoint
  • INSERT(s, L)
  • s1 ABOVE(s, L)
  • s2 BELOW(s, L)
  • if (s1 intersects s) then A ? (s1, s)
  • if (s2 intersects s) then A ? (s2, s)

33
Line-segment Intersection Algorithm 3
  • HANDLE RIGHT EVENT(p)
  • s segment of which p is an endpoint
  • s1 ABOVE(s, L)
  • s2 BELOW(s, L)
  • if (s1 intersects s2 to the right of p)
  • then A ? (s1, s2)
  • DELETE(s, L)

34
Line-segment Intersection Algorithm 2
  • HANDLE INTERSECTION EVENT(p)
  • (s1, s2) segment of which p is intersection
  • / with s1 ABOVE(s2) to the left of p /
  • s3 ABOVE(s1, L)
  • s4 BELOW(s2, L)
  • if (s3 intersects s2) then A ? (s3, s2)
  • if (s1 intersects s4) then A ? (s1, s4)

35
Line-segment Intersection Algorithm 1
  • That no intersection is missed by this algorithm
    follows from the observation that only adjacent
    segments may intersect and that all adjacencies
    are correctly examined at least once.

36
Example
37
  • Problem (Line Segment Intersection)
  • Given n line segments in the plane, find all
    intersecting pairs.
  • TheoremBentley-Ottmann(1979) The K
    intersecting pairs of a set of n line segments
    can be reported in time O((nK) log n).
  • TheoremChazelle-Edelsbrunner(1988) The K
    intersecting pairs of a set of n line segments
    can be reported in time ?(K n log n).

38
Intersection Detection
  • Polygon Intersection Test ?(n log n)
  • Simplicity Test ?(n log n)

39
Pairwise Intersection
  • Pairwise Line Segment Intersection
  • ?(K n log n)
  • Line Segment Intersection Test
  • ?(n log n)

40
Common Intersection of Half-Planes in R2 2
  • PROBLEM (Common Intersection of half-planes in
    R2)
  • Given n half-planes H1, H2,..., Hn in R2
    compute their intersection H1?H2 ?...?Hn.
  • There is a simple O(n2) algorithm for computing
    the intersection of n half-planes in R2.
  • Theorem The intersection of n half-planes in R2
    can be found in ?(n log n) time, and this is
    optimal.

41
Common Intersection of Half-Planes in R2 1
  • Theorem The intersection of n half-planes in R2
    can be found in ?(n log n) time, and this
    is optimal.
  • Proof.
  • (1)To show upper bound, we solve it by
    Divide-and-Conquer
  • T(n) 2T(n/2) O(n) O(n log n)
  • Merge the solutions to sub-problems solutions
    by finding the intersection of two resulting
    convex polygons.
  • (2)To prove the lower bound we show that
  • Sorting ?O(n) Common intersection of
    half-planes.
  • Given n real numbers x1,..., xn
  • Let Hi y ? 2xix xi2
  • Once P H1?H2 ?...?Hn is formed, we may read
    off the x.'s in sorted Order by reading the slope
    of successive edges of P.

42
Linear Programming in R2 14
  • PROBLEM (2-variable LP)
  • Minimize ax by, subject to aix biy ci ?
    0, i 1,...,n.
  • 2-variable LP ?O(n) Common intersection of
    half-planes in R2
  • Theorem A linear program in two variables and n
    constraints can be solved in O(n log n) time.

43
Linear Programming in R2 13
  • Theorem A linear program in two variables and n
    constraints can be solved in ?(n).
  • It can be solved by Prune-and-Search technique.
    This technique not only discards redundant
    constraints (i.e. those that are also irrelevant
    to the half-plane intersection task) but also
    those constraints that are guaranteed not to
    contain a vertex extremizing the objective
    function (referred to as the optimum vertex).

44
Linear Programming in R2 12
  • The 2-variable LP problem
  • Minimize ax by
  • subject to aix biy ci ? 0, i 1,...,n.
    (LP1)
  • can be transformed by setting Yaxby Xx as
    follows O(n)
  • Minimize Y
  • subject to ?iX ?iY ci ? 0, i 1,...,n.
    (LP2)
  • where ?i(ai-(a/b)bi) ?i bi/b.

45
Linear Programming in R2 11
  • In the new form we have to compute the smallest Y
    of the vertices of the convex polygon P (feasible
    region) determined by the constraints.

46
Linear Programming in R2 10
  • To avoid the construction to the entire boundary
    of P, we proceed as follows. Depending upon
    whether ?i is zero, negative, or positive we
    partition the index set 1, 2, , n into sets
    I0, I?, I.

47
Linear Programming in R2 9
  • I0 All constraints in I0 are vertical lines and
    determine the feasible interval for X
  • u1?X ?u2
  • u1 max-ci/?i i?I0, ?ilt0
  • u2 min-ci/?i i?I0, ?igt0
  • I All constraints in I define a piecewise
    upward-convex function F mini?I(?i X ?i),
    where ?i - (?i / ?i) ?i - (ci / ?i)
  • I- All constraints in I- define a piecewise
    downward-convex function F- maxi?I-(?i X ?i),
    where ?i - (?i / ?i) ?i - (ci / ?i)

48
Linear Programming in R2 8
  • Our problem so becomes O(n)
  • Minimize F-(X)
  • subject to F-(X) ? F(X) (LP3)
  • u1?X?u2
  • Given X of X, the primitive, called evaluation,
    F(X) F-(X) can be executed in O(n)
  • if H(X) F-(X) - F(X) gt 0, then X
    infeasible
  • if H(X) F-(X) - F(X) ? 0, then X feasible

49
Linear Programming in R2 7
  • Given X of X in u1, u2 , we are able to reach
    one of the following conclusions in time O(n)
  • X infeasible no solution to the problem
  • X infeasible we know on which side of X
    (right or left) any feasible value of X may lies
  • X feasible we know on which side of X (right
    or left) the minimum of F-(X) lies
  • X achieves the minimum of F-(X)

50
Linear Programming in R2 6
  • We should try to choose abscissa X where
    evaluation takes place s.t. if the algorithm does
    not immediately terminate, at least a fixed
    fraction ? of currently active constraints can be
    pruned. We get the overall running time T(n) ? ?i
    k(1-?)i-1nltkn/?O(n)

51
Linear Programming in R2 5
  • We show that the value ?1/4 as follows
  • At a generic stage assume the stage has M active
    constraints
  • let I I- be the index set as defined earlier,
    with I I-M.
  • We partition each of I I- into pairs of
    constraints.
  • For each pair i, j of I , O(M)
  • If ?i ?j (i.e. the corresponding straight lines
    are parallel)
  • then one can be eliminated. (Fig a)
  • Otherwise, let Xij denote the abscissa of their
    intersection
  • If (Xij lt u1 or Xij gt u2)
  • then one can be eliminated. (Fig b)
  • If (u1 ? Xij ? u2)
  • then we retain Xij with no elimination. (Fig
    c)
  • For each pair i, j of I- , it is similar to I
    O(M)

52
Linear Programming in R2 4
53
Linear Programming in R2 3
  • For all pairs, neither member of which has been
    eliminated, we compute the abscissa of their
    abscissa of their intersection. Thus, if k
    constraints have been eliminated, we have
    obtained a set S of (M-k)/2 intersection
    abscissae. O(M)
  • Find the median X1/2 of S O(M)
  • If X1/2 is not the extreminzing abscissa, then We
    test which side of X1/2 the optimum lies. O(M)
  • So half of the Xijs lie in the region which are
    known not to contain the optimum. For each Xij in
    the region, one constraint can be eliminated O(M)
    (Fig d)
  • This concludes the stage, with the result that at
    least k (M-k)/2/2 ?M/4 constraints have been
    eliminated.

54
Linear Programming in R2 2
55
Linear Programming in R2 1
  • Prune Search Algorithm for 2-variable LP
    problem
  • Transform (LP1) to (LP2) (LP3) O(M)
  • For each pair of constraints
  • if (?i ?i or Xijltu1 or Xijgtu2),
  • then eliminate one constraint O(M)
  • Let S be all the pairs of constraints s.t. u1?Xij
    ?u2,
  • Find the median X1/2 of S test which side of
    X1/2 the optimum lies O(M)
  • Half of the Xijs lie in the region which are
    known not to contain the optimum. For each Xij in
    the region, one constraint can be eliminated.
    O(M)

56
Common Intersection
  • Common Intersection of half-planes in R2 ?(n log
    n)
  • 2-varialbe Linear Programming ?(n)

57
  • We must point out that explicit construction of
    the feasible polytope is not a viable approach to
    linear programming in higher dimensions because
    the number of vertices can grow exponentially
    with dimension. For example, n-dim hypercube has
    2n vertices.
  • The size of Common Intersection of half-spaces in
    Rk is exponential in k, but the time complexity
    for k-variable linear programming is polynomial
    in k.
  • These two problems are not equivalent in higher
    dimensions.
Write a Comment
User Comments (0)
About PowerShow.com