CS133
Computational Geometry
Intersection Problems
4/24/2018 1
CS133 Computational Geometry Intersection Problems 4/24/2018 1 - - PowerPoint PPT Presentation
CS133 Computational Geometry Intersection Problems 4/24/2018 1 Riddle: Fair Cake-cutting Using only one cut, how to split the cake into two equal pieces (by area)? Cake 4/24/2018 2 Riddle: Fair cake-cutting Cake with a hole! Still one
4/24/2018 1
4/24/2018 2
4/24/2018 3
4/24/2018 4
4/24/2018 5
4/24/2018 6
4/24/2018 7
4/24/2018 8
4/24/2018 9
4/24/2018 10
4/24/2018 11
4/24/2018 12
4/24/2018 13
4/24/2018 14
4/24/2018 15
4/24/2018 16
4/24/2018 17
4/24/2018 18
4/24/2018 19
4/24/2018 20
4/24/2018 21
4/24/2018 22
4/24/2018 23
4/24/2018 24
4/24/2018 25
Compare ππ to each π‘ β π Insert ππ to S
Remove ππ from S
4/24/2018 26
4/26/2018 27
4/26/2018 28
Sweep line state (in sorted order)
4/26/2018 29
If p is the top point Add p.l to S at the order p.x (p.l=Si) checkIntersection(Si-1, Si) checkIntersection(Si, Si+1) Add the end point of p.l to P If p is the bottom point Remove p.l from S (p.l=Si before removal) checkIntersection(Si-1,Si) If p is an interior point
Report p as an intersection Find p.l in S (p.l=Si) Swap(Si,Si+1) checkIntersection(Si-1, Si) checkIntersection(Si, Si+1)
4/26/2018 30
4/26/2018 31
4/24/2018 32
4/26/2018 33
l1 l2 l3 If two points have the same y-coordinate, sort them by the x-coordinate Starting point
4/26/2018 34
l1 l2 l3 Allow the event point to store a list of all intersecting line segments When processed, reverse the
5/3/2018 35
5/3/2018 36
r1 r2 r3 r4
5/3/2018 37
r1 r2 r3 r4
5/3/2018 38
5/3/2018 39
5/3/2018 40
r1 r2 r3 r4
5/3/2018 41
5/3/2018 42
5/3/2018 43
X-center
5/3/2018 44
5/3/2018 45
Credit: https://en.wikipedia.org/wiki/Interval_tree
5/3/2018 46
5/3/2018 47
p1 p2 p3 p4 p5 p6 p7 p8 Corners Edge or Segment
5/3/2018 48
1.
2.
3.
5/3/2018 49
5/3/2018 50
5/3/2018 51
P Q
5/3/2018 52
P Q
5/3/2018 53
P Q
5/3/2018 54
P Q
5/3/2018 55
P Q
5/3/2018 56
P Q
5/3/2018 57
P Q
5/3/2018 58
P Q
5/3/2018 59
P Q
5/3/2018 60
P Q
5/3/2018 61
P Q
5/3/2018 62
P Q
5/3/2018 63
P Q
5/3/2018 64
P Q
5/3/2018 65
P Q No intersection points If π β π , then any corner
If π β π, then any corner
The intersection is the contained polygon
5/3/2018 66
P Q No intersection points Neither π β π nor π β π The intersection is empty
5/3/2018 67
P Q
5/3/2018 68
Right-left Right-right left-left Left-right
5/3/2018 69
5/3/2018 70
Compare the end point of
Half space R L If the end point of R is to the right of the segment in L β Skip R. Why?
5/3/2018 71
Compare the end point of
Half space R L Is the end point of R to the right of the segment in L? No! Do the line segments intersect? No! Switch to L Why?
5/3/2018 72
Compare the end point of
Half space R L If the end point of L is to the left of the segment in R β Skip L
5/3/2018 73
Compare the end point of
Half space R L Is the end point of L to the left of R? No! Do the line segments intersect? No! Switch to R
5/3/2018 74
Compare the end point of
Half space R L Is the end point of R to the right of L? Yes! Skip R
5/3/2018 75
Compare the end point of
Half space R L Is the end point of R to the right of L? No! Do the line segments intersect? Yes!
5/3/2018 76