Professional Documents
Culture Documents
Jaehyun Park
CS 97SI
Stanford University
Outline
Cross Product
Convex Hull Problem
Sweep Line Algorithm
Intersecting Half-planes
Notes on Binary/Ternary Search
Cross Product
Cross Product
Applications:
Cross Product
Cross Product
Define ccw(A, B, C) = (B A) (C A) =
(bx ax )(cy ay ) (by ay )(cx ax )
Cross Product
Cross Product
Cross Product
Non-proper Intersections
Cross Product
Outline
Cross Product
Convex Hull Problem
Sweep Line Algorithm
Intersecting Half-planes
Notes on Binary/Ternary Search
Simple Algorithm
10
11
Incremental Construction
12
Example
13
Example
14
Example
15
Example
Thats better...
16
Example
17
Example
18
Example
19
Example
20
Example
Bad corner!
21
Example
22
Example
23
Example
24
Example
25
Example
Done!
26
Pseudocode
Set the leftmost point as (0, 0), and sort the rest of the points
in increasing order of y/x
Initialize stack S
For i = 1, . . . , n:
27
Outline
Cross Product
Convex Hull Problem
Sweep Line Algorithm
Intersecting Half-planes
Notes on Binary/Ternary Search
28
29
30
Example
31
Example
32
Example
33
Example
34
Example
35
Example
36
Example
37
Example
38
Example
39
Example
40
Example
41
Pseudo-pseudocode
Right edge?
Move to the next event, and add the area(s) of the green
rectangle(s)
Finding the length of the union of the blue segments is the
hardest step
There is an easy O(n) method for this step
42
Exercise problems
Finding the perimeter of the union of rectangles
Finding all k intersections of n line segments in
O((n + k) log n) time
43
Outline
Cross Product
Convex Hull Problem
Sweep Line Algorithm
Intersecting Half-planes
Notes on Binary/Ternary Search
Intersecting Half-planes
44
Intersecting Half-planes
Representing a half-plane: ax + by + c 0
The intersection of half-planes is a convex area
If the intersection is bounded, it gives a convex polygon
Intersecting Half-planes
45
Intersecting Half-planes
Intersecting Half-planes
46
Intersecting Half-planes
Intersecting Half-planes
47
Outline
Cross Product
Convex Hull Problem
Sweep Line Algorithm
Intersecting Half-planes
Notes on Binary/Ternary Search
48
49
Ternary Search
50