65
1 Computational Geometry Instructor: yedeshi [email protected]

1 Computational Geometry Instructor: yedeshi [email protected]

Embed Size (px)

Citation preview

Page 1: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

1

Computational Geometry

Instructor: yedeshi

[email protected]

Page 2: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

2

Computational Geometry

Algorithms for geometric problems

Applications: CAD, GIS, computervision,…….

E.g., the closest pair problem: Given: a set of points P={p1… pn} in the plane, such that pi=(xi,yi)

Goal: find a pair pi ≠pj

that minimizes ||pi –pj||,

where ||p-q||= [(px-qx)2+(py-qy)2]1/2

Page 3: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

3

Line-segment

A convex combination of two distinct points p1 = (x1, y1) and p2 = (x2, y2) is any point p3 = (x3, y3) such that for some α in the range 0 ≤ α ≤ 1, we have x3 = αx1 + (1 - α)x2 and y3 = αy1 + (1 - α)y2. Also, p3 = αp1 + (1 - α)p2.

Line segment: Given two distinct points p1 and p2, the line segment is the set of convex combinations of p1 and p2. We call p1 and p2 the endpoints of segment

Sometimes the ordering of p1 and p2 matters, and we speak of the directed segment

21 pp

1 2p p��������������

Page 4: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

4

Cross products

Computing cross products is at the heart of our line-segment methods Consider vectors p1 and p2 :

The cross product p1 × p2 can be interpreted as the

signed area of the parallelogram formed by the points (0, 0), p1, p2, and p1 + p2 = (x1 + x2, y1 + y2).

Page 5: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

5

Cross product

An equivalent, but more useful, definition gives the cross product as the determinant of a matrix

1 21 2

1 2

1 2 2 1

2 1

detx x

p py y

x y x y

p p

Page 6: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

6

Cross product

If p1 × p2 is positive, then p1 is clockwise from p2 with respect

to the origin (0, 0); If it is negative, then p1 is

counterclockwise from p2

Boundary condition: cross product is 0; in this case, the vectors are collinear, pointing in either the same or opposite

directions. clockwise and counterclockwise

regions relative to a vector p

p1 × p2 is positive

Page 7: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

7

clockwise

To determine whether a directed segment is clockwise from a directed segment ?

Compute

(p1 - p0) × (p2 - p0) = (x1 - x0)(y2 - y0) - (x2 - x0)(y1 - y0).

0 1p p��������������

0 2p p��������������

(a) If counterclockwise, the points make a left turn

(b) If clockwise, they make a right turn

Page 8: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

8

Two line segments intersect

Determine whether two line segments intersect, we check whether each segment straddles the line containing the other.

A segment straddles a line if point p1 lies on one side of the line and point p2 lies on the other side.

Two line segments intersect if and only if either (or both) of the following conditions holds:1. Each segment straddles the line containing the other.

2. An endpoint of one segment lies on the other segment. (This condition comes from the boundary case.)

21 pp

Page 9: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

9

AlgorithmSEGMENTS-INTERSECT(p1, p2, p3, p4)

1 d1 ← DIRECTION(p3, p4, p1)

2 d2 ← DIRECTION(p3, p4, p2)

3 d3 ← DIRECTION(p1, p2, p3)

4 d4 ← DIRECTION(p1, p2, p4)

5 if ((d1 > 0 and d2 < 0) or (d1 < 0 and d2 > 0))

and ((d3 > 0 and d4 < 0) or (d3 < 0 and d4 > 0))

6 then return TRUE

7 elseif d1 = 0 and ON-SEGMENT(p3, p4, p1)

8 then return TRUE

9 elseif d2 = 0 and ON-SEGMENT(p3, p4, p2)

10 then return TRUE

11 elseif d3 = 0 and ON-SEGMENT(p1, p2, p3)

12 then return TRUE

13 elseif d4 = 0 and ON-SEGMENT(p1, p2, p4)

14 then return TRUE 15 else return FALSE

Page 10: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

10

Algorithm con.

DIRECTION: computes relative orientations using the cross-product method

ON-SEGMENT: which determines whether a point known to be collinear with a segment lies on that segment.

Page 11: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

11

Algorithm con.DIRECTION(pi, pj, pk)

1 return (pk - pi) × (pj - pi)

ON-SEGMENT(pi, pj, pk)

1 if min(xi, xj) ≤ xk ≤ max(xi, xj) and min(yi, yj) ≤ yk ≤ max(yi, yj)

2 then return TRUE

3 else return FALSE

Page 12: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

12

Segment intersection

Given: a set of n distinct segments s1…sn, represented by coordinates of endpoints

Detection: detect if there is any pair si

≠ sj that intersects

Reporting: report all pairs of intersecting segments

Page 13: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

13

Segment intersection

Easy to solve in O(n2) time.Is it possible to get a better algorithm for the reporting problem? NO ! (in the worst-case) How to prove it?However:

We will see we can do better for the detection problem Moreover, the number of intersections P is usually small. Then, we would like an output sensitive algorithm, whose running time is low if P is small.

Page 14: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

14

Θ(n2) intersections

Page 15: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

15

Result

We will show: O(n log n) time for detection

O( (n +P) log n) time for reporting

We will use …… (no, not divide and conquer)

… Binary Search Trees

Specifically: Line sweep approach

Page 16: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

16

Determining segments intersects

Determining whether any two line segments in a set of segments intersect.

Sweeping: is common to many computational-geometry algorithms. An imaginary vertical sweep line passes through the given set of geometric objects, usually from left to right.

Ordering segments: Two segments s1 and s2 ,

comparable at x if the vertical sweep line with x-coordinate x intersects both of them

Page 17: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

17

Order segments

s1 is above s2 at x, written s1 >x s2, if s1 and s2 are comparable at

x and the intersection of s1 with the sweep line at x is higher

than the intersection of s2 with the same sweep line.

For example, we have the relationships a >r c, a >t b, b >t c, a

>t c, and b >u c. Segment d is not comparable with any other

segment. When segments e and f intersect, their orders are reversed: we have e >v f but f >w e.

Page 18: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

18

Moving the sweep line

Sweeping algorithms typically manage two sets of data:The sweep-line status gives the relationships among the objects intersected by the sweep line.The event-point schedule is a sequence of x-coordinates, ordered from left to right, that defines the halting positions of the sweep line. We call each such halting position an event point. Changes to the sweep-line status occur only at event points.

The sweep-line status is a total order T, for which we require the following operations:

INSERT(T, s): insert segment s into T.DELETE(T, s): delete segment s from T.ABOVE(T, s): return the segment immediately above segment s in T.BELOW(T, s): return the segment immediately below segment s in T.If there are n segments in the input, we can perform each of the above operations in O(lg n) time using red-black trees.

Page 19: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

19

Segment-intersection pseudocode

ANY-SEGMENTS-INTERSECT(S) 1 T ← Ø 2 sort the endpoints of the segments in S from left to right, breaking

ties by putting left endpoints before right endpoints and breaking further ties by putting points with lower y-coordinates first

3 for each point p in the sorted list of endpoints 4 do if p is the left endpoint of a segment s 5 then INSERT(T, s) 6 if (ABOVE(T, s) exists and intersects s) or (BELOW(T, s) exists and

intersects s) 7 then return TRUE 8 if p is the right endpoint of a segment s 9 then if both ABOVE(T, s) and BELOW(T, s) exist and ABOVE(T, s)

intersects BELOW(T, s) 10 then return TRUE 11 DELETE(T, s) 12 return FALSE

Page 20: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

20

Example

Each dashed line is the sweep line at an event point, and the ordering of segment names below each sweep line is the total order T at the end of the for loop in which the corresponding event point is processed. The intersection of segments d and b is found when segment c is deleted.

Page 21: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

21

Correctness We will prove that the call ANY-SEGMENTS-INTERSECT(S) returns TRUE if and only if there is an intersection among the segments in S.

if it returns TRUE, there is an intersection.

if there is an intersection, then ANY-SEGMENTS-INTERSECT returns TRUE

Let us suppose that there is at least one intersection.

Let p be the leftmost intersection point. And let a and b be the segments that intersect at p.

There exists a sweep line z at which a and b become consecutive in the total order. z is to the left of p or goes through p.

There exists a segment endpoint q on sweep line z that is the event point at which a and b become consecutive in the total order.

If p is on sweep line z, then q = p. If p is not on sweep line z, then q is to the left of p.

Page 22: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

22

Correctness

If q is processed by ANY-SEGMENTS-INTERSECT, there are only two possibilities for the action taken:

Either a or b is inserted into T, and the other segment is above or below it in the total order. Lines 4-7 detect this case.Segments a and b are already in T, and a segment between them in the total order is deleted, making a and b become consecutive. Lines 8-11 detect this case.

In either case, the intersection p is found and ANY-SEGMENTS-INTERSECT returns TRUE.

Page 23: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

23

Running time

If there are n segments in set S, then ANY-SEGMENTS-INTERSECT runs in time O(n lg n). Line 1 takes O(1) time. Line 2 takes O(n lg n) time, using merge sort or heapsort. Since there are 2n event points, the for loop of lines 3-11 iterates at most 2n times. Each iteration takes O(lg n) time, since each red-black-tree operation takes O(lg n) time and, using the method of line intersection, each intersection test takes O(1) time.

The total time is thus O(n lg n).

Page 24: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

24

The closet pair problem

the closest pair problem: Given: a set of points P={p1… pn} in the plane, such that pi=(xi,yi)

Goal: find a pair pi ≠pj

that minimizes ||pi –pj||,

where ||p-q||= [(px-qx)2+(py-qy)2]1/2

Page 25: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

25

Closest Pair

Find a closest pair among p1…pn

Easy to do in O(n2) time For all pi

≠pj, compute || pi –pj || and choose the

minimum

We will aim for O(n log n) time

Page 26: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

26

Divide and conquer

Divide: Compute the median of x-coordinates

Split the points into PL and PR, each of size n/2

Conquer: compute the closest pairs for PL and PR

Combine the results (the hard part)

PL PR

Page 27: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

27

Combine

Let d=min(d1,d2)

Observe: Need to check only pairs which cross the dividing line

Only interested in pairs within distance < d

Suffices to look at points in the 2d-width strip around the median line

2d

d1

d2

Page 28: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

28

Scanning the strip

Sort all points in the strip by their

y-coordinates, forming q1…qk, k ≤ n.

Let yi be the y-coordinate of qi

dmin= d For i=1 to k j=i-1

While yi - yj

< d

If ||qi–qj||<d then

dmin=||qi–qj|| j:=j-1

Report dmin (and the corresponding pair)

Page 29: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

29

Analysis

Correctness: easy

Running time is more involved

Can we have many qj’s that are within distance d from qi ?

No

Proof by packing argument

d

Page 30: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

30

Analysis, ctd.

Theorem: there are at most 7 qj’s such that yi-yj ≤ d.

Pf: Each such qj must lie either in

the left or in the right d × d square

Note that within each square, all points have distance ≥ d from others

We can pack at most 4 such points into one square, so we have 8 points total (incl. qi)

qi

d × d

Page 31: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

31

Running time

Divide: O(n)

Combine: O(n log n) because we sort by y

However, we can: Sort all points by y at the beginning

Divide preserves the y-order of points Then combine takes only O(n)

We get T(n)=2T(n/2)+O(n), soT(n)=O(n log n)

Page 32: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

32

Finding the convex hull

The convex hull of a set Q of points is the smallest convex polygon P for which each point in Q is either on the boundary

of P or in its interior. Ex. CH(Q): p0 , p1 , p3, p10 , p12.

Page 33: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

33

Graham's scan

Graham's scan solves the convex-hull problem by maintaining a stack S of candidate points.

Each point of the input set Q is pushed once onto the stack, and the points that are not vertices of CH(Q) are eventually popped from the stack.

When the algorithm terminates, stack S contains exactly the vertices of CH(Q), in counterclockwise order of their appearance on the boundary.

Page 34: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

34

GRAHAM-SCAN

The procedure GRAHAM-SCAN takes as input a set Q of points, where |Q| ≥ 3. It calls the functions TOP(S), which returns the point on top of stack S without changing S, and NEXT-TO-TOP(S), which returns the point one entry below the top of stack S without changing S. As we shall prove in a moment, the stack S returned by GRAHAM-SCAN contains, from bottom to top, exactly the vertices of CH(Q) in counterclockwise order.

Page 35: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

35

PseudocodeGRAHAM-SCAN(Q) 1 let p0 be the point in Q with the minimum y-coordinate, or the leftmost

such point in case of a tie2 let 〈 p1, p2, ..., pm 〉 be the remaining points in Q, sorted by polar

angle in counterclockwise order around p0 (if more than one point has the same angle, remove all but the one that is farthest from p0)

3 PUSH(p0, S) 4 PUSH(p1, S) 5 PUSH(p2, S) 6 for i ← 3 to m 7 do while the angle formed by points NEXT-TO-TOP(S), TOP(S), and pi

makes a nonleft turn 8 do POP(S) 9 PUSH(pi, S) 10 return S

Page 36: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

36

Illustration:sorts the remaining

points of Q by polar

angle relative to p0,

using the method

comparing cross products

Page 37: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

37

Theorem

Theorem. If GRAHAM-SCAN is run on a set Q of points, where |Q| ≥ 3, then at termination, the stack S consists of, from bottom to top, exactly the vertices of CH(Q) in counterclockwise order.

Pf. After line 2, we have the sequence of points 〈 p1, p2, ..., pm 〉 . Let us define, for i = 2, 3, ..., m, the subset of points Qi = {p0, p1, ..., pi}. The points in Q - Qm are those that were removed because they had the same polar angle relative to p0 as some point in Qm; these points are not in CH(Q), and so CH(Qm) = CH(Q).

Note that just as p0, p1, and pm are vertices of CH(Q), the points p0, p1, and pi are all vertices of CH(Qi)

Page 38: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

38

Prof.

At the start of each iteration of the for loop of lines 6-9, stack S consists of, from bottom to top, exactly the vertices of CH(Qi-1) in counterclockwise order.Initialization: The invariant holds the first time we execute line 6, since at that time, stack S consists of exactly the vertices of Q2 = Qi-1, and this set of three vertices forms its own convex hull. Moreover, they appear in counterclockwise order from bottom to top.Maintenance: Entering an iteration of the for loop, the top point on stack S is pi-1.

Let pj be the top point on S after the while loop of lines 7-8 is executed but before line 9 pushes pi, and let pk be the point just below pj on S.

Page 39: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

39

Prof.

Focus on this moment just before pi is pushed.

Because pi's polar angle relative to p0 is greater than pj's polar

angle, and because the angle makes a left turn (otherwise we would have popped pj )

ijk ppp

Page 40: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

40

Pf.

We now show that CH(Qj {∪ pi}) is the same set of points as CH(Qi).

Consider any point pt that was popped during iteration i of the for

loop, and let pr be the point just below pt on stack S at the time pt

was popped (pr might be pj ). The angle ∠pr pt pi makes a nonleft turn, and the polar angle of pt relative to p0 is greater than the polar angle of pr

pt must be either in the interior of the triangle formed by p0, pr, and pi or on a side of this triangle (but it is not a vertex of the triangle).

Clearly, since pt is within a triangle formed by three other points of Qi, it cannot be a vertex of CH(Qi). Since pt is not a vertex of CH(Qi),

Page 41: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

41

Pf.

CH(Qi-{pt}) = CH(Qi) ,

Let Pi be the set of points that were popped during iteration i of the for

loop. CH(Qi - Pi) = CH(Qi).

But Qi - Pi = Qj {∪ pi}, and so we conclude that CH(Qj {∪ pi}) = CH(Qi -

Pi) = CH(Qi).

We have shown that once we push pi , stack S contains exactly the vertices

of CH(Qi) in counterclockwise order from bottom to top. Incrementing i

will then cause the loop invariant to hold for the next iteration.

Termination: When the loop terminates, we have i = m + 1, and so the loop invariant implies that stack S consists of exactly the vertices of CH(Qm), which is CH(Q), in counterclockwise order from bottom to top.

This completes the proof.

Page 42: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

42

Running timeLine 1 takes Θ(n) time.Line 2 takes O(n lg n) time, using merge sort or heapsort to sort the polar angles and the cross-product method of to compare angles. (Removing all but the farthest point with the same polar angle can be done in a total of O(n) time.) Lines 3-5 take O(1) time. Because m ≤ n - 1, the for loop of lines 6-9 is executed at most n - 3 times. Since PUSH takes O(1) time, each iteration takes O(1) time exclusive of the time spent in the while loop of lines 7-8, and thus overall the for loop takes O(n) time exclusive of the nested while loop.

We use aggregate analysis to show that the while loop takes O(n) time overall. For i = 0, 1, ..., m, each point pi is pushed onto stack S exactly once. We observe that there is at most one POP operation for each PUSH operation. At least three points-p0, p1, and pm-are never popped from the stack, so that in fact at most m - 2 POP operations are performed in total. Each iteration of the while loop performs one POP, and so there are at most m - 2 iterations of the while loop altogether. Since the test in line 7 takes O(1) time, each call of POP takes O(1) time, and since m ≤ n - 1, the total time taken by the while loop is O(n).

Thus, the running time of GRAHAM-SCAN is O(n lg n).

Page 43: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

43

Jarvis's march Jarvis's march computes the convex hull of a set Q of points by a technique known as package wrapping (or gift wrapping). The algorithm runs in time O(nh), where h is the number of vertices of CH(Q). When h is o(lg n), Jarvis's march is asymptotically faster than Graham's scan.

Jarvis's march builds a sequence H = 〈 p0, p1, ..., ph-1 〉 of the vertices of CH(Q).

We start with p0, the next convex hull vertex p1 has the smallest polar angle with respect to p0. (In case of ties, we choose the point farthest from p0.) Similarly, p2 has the smallest polar angle with respect to p1, and so on.

When we reach the highest vertex, say pk (breaking ties by choosing the farthest such vertex), we have constructed the right chain of CH(Q).

To construct the left chain, we start at pk and choose pk+1 as the point with the smallest polar angle with respect to pk, but from the negative x-axis. We continue on, forming the left chain by taking polar angles from the negative x-axis, until we come back to our original vertex p0.

Page 44: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

44

Illustration

Page 45: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

45

Running time

If implemented properly, Jarvis's march has a running time of O(nh). For each of the h vertices of CH(Q), we find the vertex with the minimum polar angle. Each comparison between polar angles takes O(1) timeWe can compute the minimum of n values in O(n) time if each comparison takes O(1) time. Thus, Jarvis's march takes O(nh) time.

Page 46: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

46

Divide-and-conquer

Divide: choosing a pivot point p. Partitions the input points into two sets L and R.

L: containing the points to the left of p, including p itself.

R: the points to the right of p. (by comparing x-coordinates.)

Conquer: Recursively solve it.

Combine: the hardest one.

Page 47: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

47

Merge

Connecting the two hulls with a line segment between the rightmost point of the hull of L with the leftmost point of the hull of R. Call these points p and q. Actually, let's add two copies of the segment pq and call them bridges.

Merge:

scanning around the left hull in a clockwise direction (from bridge to points in L) and around the right hull in an anti-clockwise direction (from points in R to bridge).

If above turns happen, update the bridge accordingly.

Page 48: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

48

Illustration of combiningp

q

p

q

III

III

p

q

Page 49: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

49

Illustration of combiningp

q

p

qIV

V

VI

p

q

Page 50: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

50

Up to date

Graham: O(n log n)

Jarvis: O(n h)

Yao: lower bound O(n log n)

Kirkpatrick and Seidel: O(n lg h) 86

Timothy Chan, O(n lg h) 93

Page 51: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

51

Polygon Triangulation

Given a polygon, we want to decompose it into triangles by adding diagonals: new line segments between the vertices that don't cross the boundary of the polygon.

Page 52: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

52

Triangulation of simple polygons

Does every simple polygon admit a triangulation? Simple: it does not cross itself.

If yes, what is the number of triangles?

Does any triangulation lead to the same number of triangles?

• • •

• • •

• •

• • • • wv

u • • • • •

• • •

• • • •

Page 53: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

53

Theorem

Theorem: Every simple polygon admits a triangulation, and any triangulation of a simple polygon with n vertices consists of exactly n-2 triangles.

Pf. by induction.The base case n = 3 is trivial: there is only one triangulation of a triangle, and it obviously has only one triangle.Let P be a polygon with n edges. Draw a diagonal between two vertices. This splits P into two smaller polygons. One of these polygons has k edges of P plus the diagonal, by the induction hypothesis, this polygon can be broken into k - 1 triangles. The other polygon has n - k + 1 edges, and so by the induction hypothesis, it can be broken into n - k -1 tirangles. Putting the two pieces back together, we have a total of (k - 1) + (n - k - 1) = n - 2 triangles.

Page 54: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

54

Exists of diagonal

How do we know that every polygon has a diagonal? [Meisters in 1975]

Lemma. Every polygon with more than three vertices has a diagonal.

Pf. Let P be a polygon with more than three vertices. Let q be the leftmost vertex. Let p and r be two neighboring vertices of q.Case 1: pr completely in P. Then segement pr is a diagonal

rq

p

Page 55: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

55

Pf of Lemma

Case 2: pr not completely in P

rq

p

s

Let s be the vertex furthest away from the segment pr.Then the line qs is a diagnose.

Page 56: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

56

Running time

O(n2) Time.

2 2( ) max ( 1) ( 1) ( )

k nT n T k T n k O n

Page 57: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

57

Applications of Polygon Triangulation

Motivation: Guarding art galleries

Art gallery theorem for simple polygons

Partitioning of polygons into monotone pieces

Triangulation of y-monotone polygons

Page 58: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

58

Guarding art galleries

“Art Gallery“ Problem

Page 59: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

59

Guarding art galleries

The gallery is represented by a simple polygon

A guard is represented by a point within the polygon

Guards have a viewport of 360°

A polygon is completely guarded, if every point within the polygon is guarded by at least one of the watchmen

Page 60: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

60

Demo

Visibility polygon:

The visibility polygon vis(p) of a polygon P is defined by the set of all points that are visible from the base point p.

Demo

Page 61: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

61

Guarding art galleries

Even if two polygons have the same number of vertices, one may be easier to guard than the other.

We will consider the lower bound for the worst case: We want to determine the number of guards that suffice for an arbitrary polygon with n vertices.

Page 62: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

62

Equitable Convex Partition and Applications

Armbruster, Carlsson, Ge, and Ye

Page 63: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

63

Problem Statement

n points are scattered inside a convex polygon P (in 2D) with m vertices. Does there exist a partition of P into n sub-regions satisfying the following:

Each sub-region is a convex polygon

Each sub-region contains one point

All sub-regions have equal area

Page 64: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

64

Motivation: Client/Server Network

This problem has applications in heuristic methods for what we call the Broadcast Network class of problems, in which we connect a set of clients to a set of servers, using a fixed underlying network topology.

Example: Multi-Depot Vehicle Routing Problem (MDVRP).Definition: A set of vehicles located at depots in the plane must visit a set of customers

such that the maximum TSP cost is minimized (min-max MDVRP).

Page 65: 1 Computational Geometry Instructor: yedeshi yedeshi@gmail.com

65

Result

Not only such an equitable partition always exists, but also we can find it exactly in running time O(Nn log N), where N = m + n.