Download - A Tutorial on Computational Geometry
![Page 1: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/1.jpg)
A Tutorial on Computational Geometry
Pham Minh TriPh.D. Candidate and Project OfficerSchool of Computer Engineering
1 Mar 2008
presented by
![Page 2: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/2.jpg)
What will be covered?
• Mainly popular static problems:– Point inside polygon– Convex hull– Line segment intersection– Delaunay triangulation– Closest pair of points
![Page 3: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/3.jpg)
What will be covered?
• Mainly popular static problems:– Point inside polygon– Convex hull– Line segment intersection– Delaunay triangulation– Closest pair of points
![Page 4: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/4.jpg)
Point Inside Polygon Test
• Given a point, determine
if it lies inside a polygon
or not
![Page 5: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/5.jpg)
Ray Test
• Fire ray from point• Count intersections
– Odd = inside polygon– Even = outside polygon
![Page 6: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/6.jpg)
Problems With Rays
• Fire ray from point• Count intersections
– Odd = inside polygon– Even = outside polygon
• Problems– Ray through vertex
![Page 7: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/7.jpg)
Problems With Rays
• Fire ray from point• Count intersections
– Odd = inside polygon– Even = outside polygon
• Problems– Ray through vertex
![Page 8: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/8.jpg)
Problems With Rays
• Fire ray from point• Count intersections
– Odd = inside polygon– Even = outside polygon
• Problems– Ray through vertex– Ray parallel to edge
![Page 9: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/9.jpg)
A Better Way
![Page 10: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/10.jpg)
A Better Way
![Page 11: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/11.jpg)
A Better Way
![Page 12: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/12.jpg)
A Better Way
![Page 13: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/13.jpg)
A Better Way
![Page 14: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/14.jpg)
A Better Way
![Page 15: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/15.jpg)
A Better Way
![Page 16: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/16.jpg)
A Better Way
![Page 17: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/17.jpg)
A Better Way
![Page 18: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/18.jpg)
A Better Way
![Page 19: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/19.jpg)
A Better Way
![Page 20: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/20.jpg)
A Better Way
• One winding = inside
![Page 21: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/21.jpg)
A Better Way
![Page 22: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/22.jpg)
A Better Way
![Page 23: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/23.jpg)
A Better Way
![Page 24: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/24.jpg)
A Better Way
![Page 25: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/25.jpg)
A Better Way
![Page 26: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/26.jpg)
A Better Way
![Page 27: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/27.jpg)
A Better Way
![Page 28: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/28.jpg)
A Better Way
![Page 29: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/29.jpg)
A Better Way
![Page 30: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/30.jpg)
A Better Way
![Page 31: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/31.jpg)
A Better Way
![Page 32: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/32.jpg)
A Better Way
• zero winding = outside
![Page 33: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/33.jpg)
Requirements
• Oriented edges• Edges can be processed
in any order
![Page 34: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/34.jpg)
Computing Winding Number
• Given unit normal n• =0
• For each edge (p1, p2)
• for some integer k• k = winding number
– If k == 1, then inside– If k == 0, then outside
1p
2px
2k
xpxp
xpxp
xpxp
xpxpn
21
211
21
21 )()(cos
)()(
))()((
![Page 35: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/35.jpg)
Advantages
• Extends to 3D!• Numerically stable • Even works on models with holes:
– Odd k: inside– Even k: outside
• No ray casting
![Page 36: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/36.jpg)
What will be covered?
• Mainly popular static problems:– Point inside polygon– Convex hull– Line segment intersection– Delaunay triangulation– Closest pair of points
![Page 37: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/37.jpg)
What will be covered?
• Mainly popular static problems:– Point inside polygon– Convex hull– Line segment intersection– Delaunay triangulation– Closest pair of points
![Page 38: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/38.jpg)
Convex Hulls
Subset of S of the plane is convex, if for all pairs p,q in S the line segment pq is completely contained in S.
The Convex Hull CH(S) is the smallest convex set, which contains S.
p
q
pq
p
q
pq
![Page 39: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/39.jpg)
Convex hull of a set of points in the plane
Rubber band experiment
The convex hull of a set P of points is the unique convex polygon whose vertices are points of P and which containsall points from P.
•
• •
•
• •
•
•
•
![Page 40: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/40.jpg)
Convex Hull
• Input:– Set S = {s1, …, sn} of n points
• Output:– Find its convex hull
• Many algorithms:– Naïve – O(n3)– Insertion – O(n logn)– Divide and Conquer – O(n logn)– Gift Wrapping – O(nh), h = no of points on the hull– Graham Scan – O(n logn)
![Page 41: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/41.jpg)
Graham Scan
• Polar sort the points around a point inside the hull
• Scan points in counter-clockwise (CCW) order– Discard any point that causes a
clockwise (CW) turn• If CCW, advance• If !CCW, discard current point
and back up
![Page 42: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/42.jpg)
Graham-Scan : (1/11)
p1
p0
p3p4
p2
p5p6p7
p8p9
p10
p11
p12
![Page 43: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/43.jpg)
Graham-Scan :(1/11)
p1
p0
p3p4
p2
p5p6p7
p8p9
p10
p11
p12
1.Calculate polar angle
2.Sorted by polar angle
![Page 44: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/44.jpg)
Graham-Scan : (2/11)
p2p1p0
Stack S:
p1
p0
p3p4
p2
p5p6p7
p8p9
p10
p11
p12
![Page 45: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/45.jpg)
Graham-Scan : (3/11)
Stack S:
p1
p0
p3p4
p2
p5p6p7
p8p9
p10
p11
p12
p3p1p0
![Page 46: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/46.jpg)
Graham-Scan : (4/11)
p1
p0
p3p4
p2
p5p6p7
p8p9
p10
p11
p12
p4p3p1p0
Stack S:
![Page 47: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/47.jpg)
Graham-Scan (5/11)
p1
p0
p3p4p2
p5p6p7
p8p9
p10
p11
p12
p5p3p1p0
Stack S:
![Page 48: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/48.jpg)
Graham-Scan (6/11)
p1
p0
p3p4p2
p5p6p7
p8p9
p10
p11
p12
p8p7p6p5p3p1p0
Stack S:
![Page 49: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/49.jpg)
Graham-Scan (7/11)
p1
p0
p3p4p2
p5p6
p7p8
p9
p10
p11
p12
p9p6p5p3p1p0
Stack S:
![Page 50: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/50.jpg)
Graham-Scan (8/11)
p1
p0
p3p4p2
p5p6p7
p8
p9
p10
p11
p12
p10p3p1p0
Stack S:
![Page 51: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/51.jpg)
Graham-Scan (9/11)
p1
p0
p3p4p2
p5p6p7
p8
p9
p10
p11
p12
p11p10p3p1p0
Stack S:
![Page 52: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/52.jpg)
Graham-Scan (10/11)
p1
p0
p3p4p2
p5p6p7
p8
p9
p10
p11p12
p12p10p3p1p0
Stack S:
![Page 53: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/53.jpg)
Time complexity Analysis
• Graham-Scan– Sorting in step 2 needs O(n log n).– Time complexity of stack operation is O(2n)– The overall time complexity in Graham-Scan is O(n log n).
• Demo:– http://www.cse.unsw.edu.au/~lambert/java/3d/hull.html
![Page 54: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/54.jpg)
What will be covered?
• Mainly popular static problems:– Point inside polygon– Convex hull– Line segment intersection– Delaunay triangulation– Closest pair of points
![Page 55: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/55.jpg)
What will be covered?
• Mainly popular static problems:– Point inside polygon– Convex hull– Line segment intersection– Delaunay triangulation– Closest pair of points
![Page 56: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/56.jpg)
Line segment intersection
• Input:– Set S = {s1, …, sn} of n line segments, si = (xi, yi)
• Output:– k = All intersection points among the segments in S
![Page 57: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/57.jpg)
Line segment intersection
• Worst case:– k = n(n –1)/2 = O(n2) intersections
• Sweep line algorithm (near optimal algorithm):– O(n log n + k) time and O(n) space– O(n) space
![Page 58: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/58.jpg)
Sweep Line Algorithm
Avoid testing pairs of segments that are far apart.
Idea: imagine a vertical sweep line passes through the given set of line segments, from left to right.
Sweepline
![Page 59: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/59.jpg)
Assumption on Non-degeneracy
No segment is vertical. // the sweep line always hits a segment at // a point.
If a segment is vertical, imagine we rotate it clockwise by a tiny angle.This means:
For each vertical segment, we will consider its lower endpoint before upper point.
![Page 60: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/60.jpg)
Sweep Line Status
The set of segments intersecting the sweep line.
It changes as the sweep line moves, but not continuously.
Updates of status happen only at event points. left endpointsright endpointsintersections
event points
AG
C
T
![Page 61: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/61.jpg)
Ordering Segments
A total order over the segments that intersect the current position of the sweep line: •Based on which parts of the segments we are currently interested in
A
B
C
D
E
B > C > D(A and E not inthe ordering)
C > D(B drops out ofthe ordering)
At an event point, the sequence of segments changes:
Update the status.
Detect the intersections.
D > C(C and D swaptheir positions)
![Page 62: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/62.jpg)
Status Update (1)
A new segment L intersecting the sweep line
L
M
K
Check if L intersects with the segment above (K) and the segment below (M).
new event point
Intersection(s) are new event points.
Event point is the left endpoint of a segment.
N
K, M, N K, L, M, N
O
![Page 63: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/63.jpg)
Status Update (2)
The two intersecting segments (L and M) change order.
L
M
K
Check intersection with new neighbors (M with O and L with N).
Intersection(s) are new event points.
Event point is an intersection.
N
O
O, L, M, N O, M, L, N
![Page 64: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/64.jpg)
Status Update (3)
The two neighbors (O and L) become adjacent.
L
M
K
Check if they (O and L) intersect.
Intersection is new event point.
Event point is a lower endpoint of a segment.
N
O, M, L, N O, L, N
O
![Page 65: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/65.jpg)
Data Structure for Event Queue
Data structure: balanced binary search tree (e.g., red-black tree).
Ordering of event points:
by x-coordinates
by y-coordinates in case of a tie in x-coordinates.
Supports the following operations on a segment s.
inserting an event
fetching the next event
Every event point p is stored with all segments starting at p.
// O(log m)
// O(log m)
m = #event points in the queue
![Page 66: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/66.jpg)
Data Structure for Sweep-line Status
Describes the relationships among the segments intersected by the sweep line.
Use a balanced binary search tree T to support the following operations on a segment s.
Insert(T, s) Delete(T, s)Above(T, s) // segment immediately above s Below(T, s) // segment immediately below s
e.g, Red-black trees, splay trees (key comparisons replaced by cross-product comparisons).
O(log n) for each operation.
![Page 67: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/67.jpg)
An Example
L
K
M
N
O
K
L O
N M
K
L
N
O
The bottom-up order of the segments correspond to the left-to-right order of the leaves in the tree T.
Each internal node stores the segment from the rightmost leaf in its left subtree.
![Page 68: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/68.jpg)
The Algorithm
FindIntersections(S)Input: a set S of line segmentsOuput: all intersection points and for each intersection the segment containing it.1. Q // initialize an empty event queue2. Insert the segment endpoints into Q // store with every left endpoint // the corresponding segments3. T // initialize an empty status structure4. while Q 5. do extract the next event point p6. Q Q – {p}7. HandleEventPoint(p)
![Page 69: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/69.jpg)
Handling Event Points
Status updates (1) – (3) presented earlier.
Degeneracy: several segments are involved in one event point (tricky).
A
B
C
C
A
D
G
E
H
l
D
D
AG E
HC
A
C
G
ET:
G C
HA
B
A
G
C
B
(a) Delete D, E, A, C (b) Insert B, A, C
p
![Page 70: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/70.jpg)
What will be covered?
• Mainly popular static problems:– Point inside polygon– Convex hull– Line segment intersection– Delaunay triangulation– Closest pair of points
![Page 71: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/71.jpg)
What will be covered?
• Mainly popular static problems:– Point inside polygon– Convex hull– Line segment intersection– Delaunay triangulation– Closest pair of points
![Page 72: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/72.jpg)
Motivation
Transformation of a topographic map
into a perspective view
![Page 73: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/73.jpg)
TerrainsGiven: A number of sample points p1..., pn
Required: A triangulation T of the points resulting in a “realistic” terrain.
"Flipping" of an edge:900
930
2050
900
930
20
50
Goal: Maximise the minimum angle in the triangulation
![Page 74: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/74.jpg)
Triangulation of Planar Point Sets
Given: Set P of n points in the plane (not all collinear).
A triangulation T(P) of P is a planar subdivision of the convex hull of P into triangles with vertices from P.
T(P) is a maximal planar subdivision.
For a given point set there are only finitely many differenttriangulations.
![Page 75: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/75.jpg)
Size of TriangulationsTheorem : Let P be a set of n points in the plane, not all collinear and let k denote the number of points in P that lie on the boundary of the convex hull for P. Then any trianglation of P has 2n-2-k triangles and 3n-3-k edges.
Proof :
Let T be triangulation of P, and let m denote the # of triangles of T. Each triangle has 3 edges, and the unbounded face has k edges. nf = # of faces of triangulation = m + 1every edge is incident to exactly 2 faces. Hence, # of edges ne = (3m +k)/2. Euler‘s formula : n - ne + nf = 2.Substituting values of ne and nf , we obtain:
m = 2n – 2 – k and ne = 3n – 3 – k .
![Page 76: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/76.jpg)
Angle Vector
Let T(P) be a triangulation of P ( set of n points). Suppose T(P) has m triangles. Consider the 3m angles of triangles of T(P), sorted by increasing value.A(T) = { a1..., a3m } is called angle-vector of T.
Triangulations can be sorted in lexicographical order according to A(T).
A triangulation T(P) is called angle-optimal if A(T(P)) A(T´(P)) for all triangulations T´ of P.
![Page 77: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/77.jpg)
Illegal Edge
a1
a2
a6a5
a3
a4 Pj
Pi a1‘
a2‘ a4‘
a3‘ a5‘
a6‘
Pk
Pj Pi
Edge flip
The edge pi pj is illegal if 6i1
min 6i1
min
‘i
Note: Let T be a triangulation with an illegal edge e. Let T´ be the triangulation obtained from T by flipping e. Then, A(T´) A(T) .
i
Consider a quadrilateral:
![Page 78: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/78.jpg)
Legal Triangulation
P i
Pk
P j
P l
Definition : A triangulation T(P) is called a legal triangulation, if T(P) does not contain any illegal edges.
Test for illegality
Lemma :
Let edge pi pj be incident to triangles pi pj pk
and pi pj pl , and let C be the circle thru pi, pj and pk. The edge pi pj is illegal iff the point pl
lies in the interior of C. Furthermore, if thepoints pi, pj, pk, pl form a convex quadri-lateral and do not lie on a common circle, then exactly one of pi pj orpk pl is an illegal edge.
![Page 79: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/79.jpg)
Test of IllegalityObservation:
pl lies inside the circle through pi, pj and pk iff pk lies inside thecircle through pi, pj, pl . When all four points lie on circle, bothpi pj and pk pl are legal.
P i
Pk
P j
P l
P i
Pk
P j
P l
![Page 80: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/80.jpg)
Thales Theorem
a
b
p
q
r
s
pipj
pk
pl
asb aqb = apb arb
illegal
Lemma: Let C be the circle through the triangle pi, pj, pk and let the point pl be the fourth point of a quadrilateral.The edge pi pj is illegal iff pl lies in the interior of C.
![Page 81: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/81.jpg)
Thales Theorem
pi pj
pl
pk
pi pj
pl
pk
Consider the quadrilateral with pl in the interior of the circle that goes through pi, pj, pk.
Claim: The minimum angle does not occur at pk!
(likewise: Minimum angle does not occur at pl )
Goal: Show that pi pj is illegal
![Page 82: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/82.jpg)
pi pj
pk
pl
a1a2
a3
a4
pi pj
pk
pl
a1a2
a3
a4
a1‘a2‘
a3‘ a4‘
pi pj
pk
pl
a1‘a2‘
a3‘ a4‘
W.l.o.g.
a4 minimal
Thales Theorem: Proof
a1‘ > a4
a2‘ > a2
![Page 83: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/83.jpg)
pi pj
pk
pl
a1a2
a3
a4
a1‘a2‘
a3‘ a4‘
Circle criterion violated illegal edge
Thales Theorem: Proof
a4‘ > a1
a3‘ > a3
Hence, min{ai‘} > min{ai}
![Page 84: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/84.jpg)
Circle Criterion
Definition:A triangulation fulfills the circle criterion if and only if the circumcircle of each triangle of the triangulation does not contain any other point in its interior.
![Page 85: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/85.jpg)
Theorems
Theorem:A triangulation T(P) of a set P of points does not contain an illegal edge if and only if nowhere the circle criterion is violated.
Theorem:Every triangulation T(P) of a set P of points can be finally transformed into an angle-optimal triangulation in a finite number of steps.
![Page 86: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/86.jpg)
Definition of the Delaunay Triangulation
A triangulation T(P) is a Delaunay Triangulation of P, denoted as DT(P), if and only if the circumcircle of any triangle of T does not contain any other point of P in its interior (i.e. T fulfills the circle criterion).
![Page 87: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/87.jpg)
Equivalent Characterisations of the Delaunay Triangulation
1. DT(P) is the straight-line-dual of Voronoi Diagram VD(P).
2. DT(P) is a triangulation of P such that all edges are legal (local angle-optimal).
3. DT(P) is a triangulation of P such that for each triangle the circle criterion is fulfilled.
4. DT(P) is global angle-optimal triangulation.
5. DT(P) is a triangulation of P such that for each edge pi pj there is a circle, on which pi and pj lie and which does not contain any other point from P.
![Page 88: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/88.jpg)
Algorithm DT(P) (randomized, incremental)
Given: Point set P = {p1..., pn }
Initially: Compute triangle (x, y, z), which includes the points p1..., pn.
m
z (0,3m)
y (3m,0)
x (-3m,-3m)
![Page 89: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/89.jpg)
Algorithm DT(P)m = max { |xi|,|yi| }
T = ((3m, 0), (3m, 3m), (0, 3m))
1. initialize DT(P) as T.
2. permutate the points in P randomly.
3. for r = 1 to n do
find the triangle in DT(P), which contains pr ;
insert new edges in DT(P) to pr ;
legalize new edges.
4. remove all edges, which are connected with x, y or z.
![Page 90: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/90.jpg)
Inserting a Point
pi
pj
pr
pi
pj
pkpr
pl
pi
pj
pk
pr
2 cases : pr is inside a triangle pr is on an edge
Legalize (pr ,pi pj ,T):if pi pj is illegal then let pi pj pk be the triangle adjacent
to pr pi pj along pi pj.flip pi pj ,i.e. replace pi pj by pr pk
Legalize (pr , pi pk, T)Legalize (pr , pk pj, T)
![Page 91: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/91.jpg)
Algorithm Delaunay Triangulation Input: A set of points P = {p1..., pn } in general position
Output: The Delaunay triangulation DT(P) of P
1. DT(P) = T = (x, y, z)
2. for r = 1 to n do
3. find a triangle pi pj pk T, that contains pr.
4. if pr lies in the interior of the triangle pi pj pk
5. then split pi pj pk 6. Legalize(pr, pi pj), Legalize(pr, pi pk),
Legalize(pr, pj pk)
7. if pr lies on an edge of pi pj pk (say pi pj)
8. then split pi pj pk and pi pj pl Legalize (pr, pi pl), Legalize (pr, pi pk), Legalize (pr, pj pl), Legalize (pr, pj pk)
9. Delete (x, y, z) with all incident edges to P
![Page 92: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/92.jpg)
CorrectnessLemma :Every new edge created in the algorithm for constructing DT during the intersection of pr is an edge of the Delaunay graph of { p1,...,pr } .
pq is a Delaunay edge iff there is a (empty) circle, which contains only p and q on the circumference.
Proof idea : Shrink a circle which was empty before addition of pr !
![Page 93: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/93.jpg)
pr
pr
Observation: After insertion of pr , every new edge produced by edge-flips is incident to pr!
Correctness of the algorithm: Consider newly produced edges:Correctness
![Page 94: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/94.jpg)
pr
pi
pj
pk
Edge-flips produce only legal edges.
Before inserting pr , circle that goes through pi, pj, pk was empty!
Edge-flips produce edges that are always incident to pr !
Edge Flips
![Page 95: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/95.jpg)
Data Structure for Point Location
t1
t2
t3
t2
t3
t4t5
t4
t6
t7
t1 t2
t4 t5
t3
t6 t7
t1 t2 t3
t1 t2 t3
t1 t2
t4 t5
t3
Split t1
flip pi pj
flip pi pk
pi
pj
pi pk
![Page 96: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/96.jpg)
Analysis of the Algorithm
Lemma :
The expected number of triangles created by the incremental algorithm for constructing DT(P) is atmost 9n + 1.
![Page 97: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/97.jpg)
Analysis of the RuntimeTheorem :
The Delaunay triangulation of a set of P of n points in theplane can be computed in O(n log n) expected time, usingO(n) expected storage.
Proof :
Running time without Point Location :Proportional to the number of created triangles = O(n).
Point Location :The time to locate the point pr in the current triangulationis linear in the number of nodes of D that we visit.
![Page 98: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/98.jpg)
Relation to Euclidean MST
• Problem:– Find a spanning tree on a set P of N points in a plane such that
the total length of all the edges of the tree is minimized (Euclidean MST)
• Relation of Delaunay Triangulation– A Euclidean MST is a sub-graph of a Delaunay Triangulation– Blindly applying MST finding methods like Kruskal’s or Prim’s on
this problem gives O(m) where m = n(n-1)/2.– If one builds the DT(P) in O(nlogn) and then does Kruskal’s or
Prim’s, one get an O(nlogn) solution.
![Page 99: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/99.jpg)
What will be covered?
• Mainly popular static problems:– Point inside polygon– Convex hull– Line segment intersection– Delaunay triangulation– Closest pair of points
![Page 100: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/100.jpg)
What will be covered?
• Mainly popular static problems:– Point inside polygon– Convex hull– Line segment intersection– Delaunay triangulation– Closest pair of points
![Page 101: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/101.jpg)
Geometry and Air Traffic Control
» Avoid collisions at all costs.» Start by finding the two aeroplanes closest to each other, at specific elevations.
» During peak times over 5000 planes, per hour, around Frankfurt airspace.
![Page 102: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/102.jpg)
Geometry and Astronomy» Find the two nearest objects in space.
![Page 103: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/103.jpg)
Search Quickly… and Why?» Find the two nearest objects in space.
![Page 104: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/104.jpg)
Problem Description
• Input: A set S of n points in the plane.• Output: The pair of points with the shortest Euclidean distance
between them.
• Other applications in fundamental geometric primitive:– Graphics, computer vision, geographic information systems, molecular
modeling
– Special case of nearest neighbour, Euclidean MST, Voronoi
![Page 105: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/105.jpg)
Closest Pair of Points
• Naïve method: Brute force.– Check all pair of points p and q with Θ(n2) comparisons.
• 1D version– Simple if all points are on a single line.
– Run time O(n log n)
Key to reducing quadratic runtime of the naïve method:
Simply don´t visit each point n times.
![Page 106: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/106.jpg)
Algorithm: DAC – Divide
• Sort S in ascending order of x-coordinates.
• Find the median line L, so that we have ½ n points in SL and ½ n points SR.
SL SR
![Page 107: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/107.jpg)
Algorithm: DAC – Conquer
• Recursively, find the closest pair in SL and SR.
SL SR
![Page 108: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/108.jpg)
Algorithm: DAC – Merge (Strip-Margins)
• Assuming that distance < S = min(SL, SR).
• Observation: Only need to consider the points within S of line L.
SL SRS
S = min(12,21)
![Page 109: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/109.jpg)
Handling Merge
• Sort points in 2S-strip in ascending y-coordinate order.
• (First observation) Only check those points within 11 positions in sorted list.
SL SRS
S = min(12,21)
![Page 110: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/110.jpg)
Comparing EfficientlyDefinition: Let si be the point in the 2S-strip with the
ith smallest coordinate.
Claim: If |i - j| 12, then the distance between si and sj is at least S.
Proof:
• The points si and sj cannot lie in same ½ S-by- ½ S box.
• si and sj are at least 2 rows apart, and have distance 2(½ S).
Fact:
• The above still holds if we replace 12 with 7.SS
![Page 111: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/111.jpg)
Closest Pair: DAC AlgorithmAlgorithm: Closest-Pair( S = {p1, …, pn} )
Sort all n points in ascending x-coordinate order
Compute the median line L, and divide S into SL and SR
Set SL Closest-Pair(SL)
Set SR Closest-Pair(SR)
Set S min(SL,SR)
Delete all points further than S from separation line L
Sort remaining points in ascending y-coordinate order
Scan points in y-order and compare distance between each point and next 7 neighbours. Update S if new shorter distance is found.
Return S
![Page 112: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/112.jpg)
Closest Pair: DAC Analysis
Run time:T(N) 2T(N/2) + O(N log N) T(N) = O(N log2 N)
Can we achieve a better run time?Yes. Don’t sort points in strip from scratch each time.• Each recursive step returns two lists: all points sorted by y-coordinate,
and all points sorted by x-coordinate.• Sort by merging two pre-sorted list.
T(N) 2T(N/2) + O(N) T(N) = O(N log N)
Space:O(n)
![Page 113: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/113.jpg)
Algorithm: Scan-Line
• Sort S in ascending order of x-coordinates.
• Place sorted points p1, …, pn in the event-queue.
• Initialise distance(p1, p2).
• Start scanning from p3.» Event-points?
» Status structure?
![Page 114: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/114.jpg)
The Status-Structure
• Maintain the status-structure (-slab):
– Insert the new event-point pi.
– Remove all points that are greater than distance to the left of the current event-point pi.
– All points in the status structure are maintained in ascending y-coordinate order.
![Page 115: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/115.jpg)
The Status-Structure
• Maintain the status-structure (-slab):
– Insert the new event-point pi.
– Remove all points that are greater than distance to the left of the current event-point pi.
– All points in the status structure are maintained in ascending y-coordinate order.
– Perform the ‘Efficient Comparison’, as described earlier, BUT only between the new event point pi and at most 7 other nearest points to pi.
– Update if a shorter distance is found.
![Page 116: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/116.jpg)
Closest Pair: Scan-Line Analysis
Invariant:
Whenever an event-point pi has been handled, then is the minimum distance between any pair of points encountered from p1 up to pi.
Run time:
O(n log n)
Space:
O(n)
![Page 117: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/117.jpg)
Related Problems
• Nearest neighbour query:– Given a set S of n points, and a query point q,
determine which s S is closest to q.
– Brute force: O(n)
– Goal: O(n log n) pre-processing, O(log n) per query.
• Voronoi region, VR(S): – A set of points closest to a given point.
• Voronoi diagram, VD(S):– Planar subdivision deliniating Voronoi regions.
• Delaunay Triangulation (the dual of VD(S)).
![Page 118: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/118.jpg)
What will be covered?
• Mainly popular static problems:– Point inside polygon– Convex hull– Line segment intersection– Delaunay triangulation– Closest pair of points
![Page 119: A Tutorial on Computational Geometry](https://reader036.vdocuments.site/reader036/viewer/2022062307/555096a9b4c90590208b460e/html5/thumbnails/119.jpg)
Acknowledgment
• Slides prepared mainly from the materials of Prof. Dr. Thomas Ottman