CSE 4101/5101 Prof. Andy Mirzaian Computational Geometry
Overview
Computational Geometry: Study of algorithms, data structures, and computational complexity of computational problems in geometry. Dimension: 1 2 3 … d … Objects: Finitely specifiable points lines ( line segments, rays, oriented, …) circles ( conics ) polygons … Computational Model & Primitive operations: real-RAM (Random Access Machine with exact real arithmetic) Arithmetic: + - Comparison: = < > Logic: not and or other: sin cos … ( as little as possible)
Landscape of Computational Geometry Applications: Graphics Robotics Vision GIS CAD VLSI Pattern Recognition Optimization Transportation Statistics . . . Algorithmic Tools: general incremental divide-&-conquer space sweep topological sweep prune and search random sampling locus approach multidimensional search dynamization . . . Data Structures: general interval trees range trees segment trees priority search trees K-d trees fractional cascading persistent D.S. . . . Analysis Tools: general amortization Davenport-Schinzel . . . Geometric Tools: Convex Hull Space subdivision Arrangements Voronoi / Delaunay Diagram Triangulations Geometric Transforms Duality . . . Implementation Issues: Degeneracy (symbolic perturbation) Robustness (inexact arithmetic) . . .
Example 1: Convex Hull
Example 1: Convex Hull
Example 2: Point set triangulation
Example 2: Point set triangulation
Example 3: Simple Polygon Polygon: A closed curve in the plane consisting of finitely many straight segments. Simple Polygon: A connected non-self-crossing polygon. Convex Polygon: A simple polygon with no interior angle exceeding 180°. Non-simple Convex Simple
Example 3: Simple Polygon Triangulation
Example 4: Planar Line Arrangement
Example 4: Planar Line Arrangement
Example 5: Voronoi Diagram & Delaunay Triangulation
Example 5: Voronoi Diagram & Delaunay Triangulation Nearest site proximity partitioning of the plane
Example 5: Voronoi Diagram & Delaunay Triangulation Delaunay Triangulation = Dual of the Voronoi Diagram.
Example 5: Voronoi Diagram & Delaunay Triangulation Delaunay triangles have the “empty circle” property.
Example 5: Voronoi Diagram & Delaunay Triangulation
Example 6: 2D Delaunay Triangulation via 3D Convex Hull z z=x2+y2 y x
Example 7: Hidden Surface Removal B B Applications: Graphics Multi-window user systems …
Example 8: Planar Graph Drawing Koebe-Andreev-Thurston’s Circle Packing Theorem: [1] Any planar graph can be drawn in the plane with vertices as centers of non-overlapping circles, such that edge between two vertices the two circles touch. Applications: CAD, VLSI, Graphics, …
Geometric Preliminaries
Metric Space (S,d) S = a set of objects called “points” of the space, d: S2 called the distance metric Metric Axioms: (x,y,z S) d(x,y) 0 (non-negativity) d(x,y) = 0 x=y (positive definiteness) d(x,y) = d(y,x) (symmetry) d(x,y) + d(y,z) d(x,z) (triangle inequality)
d = d-dimensional real space is the set of d-vectors x=(x1,x2, … ,xd)d, xi (for i=1..d). d forms a vector space, i.e., it is closed under: scaling: x = (x1, x2, … ,xd) d , . addition: x+y = (x1+y1, x2+y2, … , xd+yd) d. x3 3 x1 x2
Normed space x , x 0 (with equality x=0) x , y = y , x Inner product of two vectors x and y: x , y . x , x 0 (with equality x=0) x , y = y , x x , y = x , y Norm of a vector x: ||x|| = x , x ½ . Distance between vectors x,y: d(x,y) = || x – y || ||.|| is a metric norm if d(x,y) = || x – y || forms a metric. Example: dot-product x , y = xTy = x1y1+ x2y2+ … + xdyd defines Euclidean norm ||x|| = (|x1|2 + |x2|2 + … + |xd|2)1/2
Unit Ball of Norm: Unit Ball of the norm ||.|| is B = { xd | ||x|| 1} & satisfies: B is symmetric about the origin, i.e., xB -xB. B is convex B is closed, bounded, and has nonempty interior. Conversely, norm can be defined in terms of the unit ball: ||x|| = min { 0 | x B } B = { y | yB } B B x ||x||= -1x O
Minkowski Metric Lp (1 p ) || x ||p = (|x1|p + |x2|p + … + |xd|p)1/p dp(x,y) = || x-y ||p = (|x1 –y1|p + … + |xd –yd|p)1/p Example: L2 : (Ed : Euclidean) ||x||2 = (|x1|2 + |x2|2 + … + |xd|2)1/2 L1 : (Manhattan) ||x||1 = (|x1| + |x2| + … + |xd|) L : ||x|| = max { |x1| , |x2| , … , |xd| }
Unit Ball of Minkowski Metric Lp 2 p=3 p=2 p=1 Minkowski metric is indeed a metric: The triangle inequality is known as the Minkowski inequality [1] It is obtained from the Holder inequality [2]
Linear, affine & convex combinations points q1 , q2 , … , qk d coefficients 1 , 2 , … , k Linear combination: p = i iqi = 1q1+2q2+ … +kqk (this is a vector sum) Affine combination: p = i iqi = 1q1+2q2+ … +kqk s. t. i i =1 Convex combination: p = i iqi = 1q1+2q2+ … +kqk s. t. i i =1 & i0
Example: d=3, k=2 x3 q1 3 q2 Linear combinations: span(q1,q2) = {1q1+2q2 | 1 ,2 } = plane(O,q1,q2) Affine combinations: aff(q1,q2) = { q1+(1-)q2 | } = line q1q2 Convex combinations: conv(q1,q2) = { q1+(1-)q2 | 0 1 } = line segment q1q2 conv(q1,q2,q3) = triangle q1q2q3 O x2 x1 >1 =1 q1 =0 0 1 q2 <0 q1 p q3 q2 r
-test: consider 3 points pi = (xi,yi)2, i=1,2,3 > 0 (p1 p2 p3 ) counter-clockwise (CCW), i.e., left turn < 0 (p1 p2 p3 ) clockwise (CW), i.e., right turn = 0 (p1 p2 p3 ) collinear ½ | | = area of triangle (p1 p2 p3)
-test in higher dimensions: Consider d+1 points pi = (xi1,…,xid) d, i=1..d+1. || /d! = volume of d-simplex (p1 ,p2 …,pd+1). sign() = orientation of d-simplex (p1 ,p2 …,pd+1).
Some applications of -test Polar angle comparison: (0i<) 1 2 (O,p1,p2) 0 [no need to compute trigonometric functions] p1 p2 O 1 2 p r1 r2 q In-sector test: q sector(p,r1,r2) q is left of r1 and right of r2. (assume r2 is CCW from r1 about p.) p1 q1 p2 q2 Open line-segment crossing: p1p2 q1q2 (p1,p2,q1) (p1,p2,q2) < 0 and (q1,q2,p1) (q1,q2,p2) < 0 Cont’d
4. Line equation in 2D (ax+by+c=0) (x,y) collinear points (x2,y2) (x1,y1) (y1 - y2) x – (x1- x2) y + x1 y2 - x2 y1 = 0 a b c Some special cases: non-vertical (b0; divide by b): y = x + vertical (a0, b=0; divide by a): x =
Simple Polygons
Area of a simple polygon P=(p1,p2, …, pn) Algebraic area A(P) A(P) > 0 if P is CCW, A(P) < 0 if P is CW Geometric area Area(P) = |A(P)| FACT: 2A(P) = (O, pi ,pi+1) = (xi yi+1 – xi+1 yi ) = xi(yi+1 – yi-1) O pi pi+1 P x y i=1 n (where O = origin, pn+1 = p1 , p0 = pn )
Jordan Curve Jordan Curve Theorem: A Jordan Curve is any closed non-self-crossing curve in the plane. Jordan Curve Theorem: Any Jordan curve J partitions the plane into two regions, and J is their common boundary. The bounded region is called the interior of J. The unbounded region is called the exterior of J.
Point in Polygon Inclusion Problem Input: Simple n-gon P & query point q. Query: Is q inside P? P q
Point in Polygon Inclusion Problem In O(n) time shoot a ray out of q and count “proper” boundary crossings with P. P q
Point in Polygon Inclusion Problem In O(n) time shoot a ray out of q and count “proper” boundary crossings with P. P q
Point in Polygon Inclusion Problem Degenerate cases: How to count if ray passes through a vertex of the polygon? q q Answer: implicit and slight ray perturbation:
Point in Polygon Inclusion Problem Can we solve the problem in sub-linear time if P is convex? Answer: Yes, in O(log n) time by “binary Search”. p1 p2 pn pn-1 Step 1: Is q in sector p1 pn pn-1? If not, then return “outside” pn p1 pn-1 (O(1) time. Use -test.) Step 2: Binary search. q is in sector pi pn pj, 0<i<j<n. Let m = (i+j)/2. Is q to the left of pnpm? Update i or j to m accordingly. Repeat until j=i+1. (O(log n) time.) pi pj pm pn Step 3: j=i+1. q is inside P qpn does not cross pip i+1 . (O(1) time.) pi pi+1 pn q
Exercises
Show the following relationships hold for Minkowski norms in the plane: In general, how do these Minkowski norms compare in d ? [See the CSE6118: Lecture Slide 6 for a more general result.] We are given a triangle T = t1, t2, t3 by its 3 vertices in counter-clockwise order and a query point q, all in the plane. Give a simple O(1) time test to determine whether T contains q (inside or on its boundary). [Simplify your test “formula” as much as you can.] We are given a sequence P = p1, p2, … , pn of n points in the plane purported to be the vertices of a convex polygon in counter-clockwise order around its boundary. Give an efficient verification algorithm that P indeed represents such a polygon. We are given a convex polygon P with n vertices. Devise efficient algorithms to find (a) the largest circle inside P, (b) the largest axis-parallel square inside P, (c) the largest arbitrarily oriented square inside P. [Revisit this after we study Voronoi Diagrams and Delaunay Triangulations.] For Problem 4 see CACM Vol. 53, No. 5 & 6, 2010.
Let P be a given simple polygon with n vertices and q a given point inside P. For an arbitrary ray r that emanates from q, let CN(r, q, P) denote the crossing number of r, i.e., the number of edges of P crossed by ray r. Define Depth(q, P) to be the minimum CN(r, q, P) over all rays r emanating from q. Devise an efficient algorithm to compute Depth(q,P). Let P be an arbitrary simple polygon. (a) Show that there exists a square S that contains P and all 4 sides of S touch P. (A corner of S belongs to its both incident sides.) [Hint: the smallest bounding box of P at an arbitrary rotational orientation is a rectangle. We want a square. Continuously rotate the bounding box.] (b) Prove or disprove: there exists a square with all 4 corners on P. [This is hard.] For Problem 4 see CACM Vol. 53, No. 5 & 6, 2010.
We are given a set S of n pairwise disjoint line-segments in the plane We are given a set S of n pairwise disjoint line-segments in the plane. A J-walk of S is a Jordan curve that passes through the 2n endpoints of the segments in S, and contains each (open) segment of S either completely on its boundary, or completely in its interior, or completely in its exterior. A J-walk that is a polygon with exactly 2n vertices is called a P-walk of S. (See the figure below.) If a J-walk contains all segments of S on its boundary, then it is called a J-traversal. A P-walk whose (open) exterior is void of any segment of S is called a circumscribing P-walk. (a) Show that S has a J-traversal. [Hint: use induction.] (b) Show that S has a J-traversal that is a polygon with O(n) vertices? [Hint: Extend each segment of S (in some arbitrary order) from both sides until it hits (the extension of) another segment. Now the plane is divided into O(n) convex regions. Navigate through these regions.] (c) Show that S has a P-walk. [Harder. Use the above hint.] (d) Devise an efficient algorithm to construct a P-walk of S. (e) Show that the instance below-left has no circumscribing P-walk.
END