740 likes | 965 Views
Fundamentals of computational geometry. M. Ramanathan. The Art Gallery Problem. camera. How many cameras are needed to guard a gallery and How should they be placed?. Definitions. Simple Polygon Model. Model the art gallery as a region bounded by some simple
E N D
Fundamentals of computational geometry M. Ramanathan Fundamentals of computational geometry
The Art Gallery Problem camera How many cameras are needed to guard a gallery and How should they be placed? Fundamentals of computational geometry
Definitions Fundamentals of computational geometry
Simple Polygon Model Model the art gallery as a region bounded by some simple polygon (no self-crossing). Regions with holes are not allowed. convex polygon one camera an arbitrary n-gon (n vertices) Bad news: finding the minimum number of cameras for a given polygon is NP-hard (exponential time). Fundamentals of computational geometry
Simple polygon Nonsimple polygons There are no holes in a simple polygon. Fundamentals of computational geometry
The Art Gallery Problem How many stationary guards are needed to guard a room? Guards are located at fixed points and have 2π range of visibility. A guard cannot see through walls. A set of guards covers a polygon if every point of the polygon is visible to some guard. Problem: Find the max over all n-vertex polygons of the min number of guards needed to cover the polygons. Fundamentals of computational geometry
This 12-vertex polygon needs 3 guards to cover it. This 12-vertex polygon needs 4 guards to cover it Fundamentals of computational geometry
Necessity follows from the prong’s example. First Proof of sufficiency is due to Chvátal in 1975 (very complex). We’ll present a simple, four-step proof by Fisk from 1978. • Triangulation of polygon. • 3-coloring of triangulation graph. • Placing guards at a single color guarantees cover. • “Pigeon-hole principle”: placing n objects in k holes, one at least contains no more than └n/k┘ objects. Fundamentals of computational geometry
Diagonals and Triangulation A diagonal of a polygon is a line segment connecting two visible vertices. Triangulation: the partition of a polygon by maximal non crossing diagonals into triangles (not unique!). Fundamentals of computational geometry
n=14 Interesting, both triangulations have same number of diagonals! Notice that number of diagonals equals n-3. Fundamentals of computational geometry
3-Coloring G(V,E) is a graph defined on a triangulated polygon P. E consists of P’s edges and the triangulation diagonals, while V consists of P’s vertices. k-coloring is an assignment of k colors to the vertices of V such that no adjacent vertices have same color. We’ll show later that a triangulation graph is 3-colorable. Fundamentals of computational geometry
5 4 5 6 Assigning color to first vertex enforces the rest color assignments. 3 5 The coloring of a triangulation graph is unique! Fundamentals of computational geometry
Guards Placement It is sufficient to place guards at one color only (say red). This follows since every triangle must have 3 distinct colors at its corners, hence one must be red. Therefore every triangle is covered. But the triangles cover the entire polygon P. Pigeon-hole principle: There must be one color whose number of assigned vertices doesn’t exceed └n/3┘. Fundamentals of computational geometry
Art-gallery Problem in 3D An example of a polyhedron with interior points not visible from any vertex. Fundamentals of computational geometry
Schönhardt Polyhedron • Schönhardt polyhedron is the smallest non-convexpolyhedron which cannot be triangulated into tetrahedra without adding new vertices. Fundamentals of computational geometry
Area of Polygons Fundamentals of computational geometry
Area of polygons can be found by triangulation and calculation of triangles areas. We’d like to obtain a closed-form formula, independent of triangulation. Fundamentals of computational geometry
A(P) expression depends on triangulation. We’ll consider first quadrilaterals and show its area is independent of triangulation. Fundamentals of computational geometry
Diagonal related terms are canceled out! Fundamentals of computational geometry
v2 What happens for non-convex quadrilateral ? v3 v1 v0 Fundamentals of computational geometry
We’d like to obtain the area of a general simple polygon in terms of its vertices only. Fundamentals of computational geometry
Convex Hulls in Two Dimensions Definitions Basic algorithms Gift Wrapping (algorithm of Jarvis) Graham scan Divide and conquer Fundamentals of computational geometry
Convexity • A set S is convex if x S and y S implies the segment xy S x y Fundamentals of computational geometry
Definitions of Convex Hull • Convex Hull of a finite set of points S in the plane is the smallest convex polygon P that encloses S which means that there is no other polygon P’ such that S P’ P • Intersection of all convex sets containing the points in S Fundamentals of computational geometry
The convex hull of a set of points S in the plane is the union of all the triangles determined by points in S • Informal definition: Convex hull of a set of points in plane is the shape taken by a rubber band stretched around the nails pounded into the plane at each point • Now we define the convex hull problem: - The problem is to construct the boundary of a convex hull in two dimensions given a finite set S of n points - Four outputs can be distinguished for the above problem: 1. all the points on the hull, in arbitrary order; 2. the extreme points, in arbitrary order; 3. all the points on the hull, in boundary traversal order; 4. the extreme points, in boundary traversal order; Fundamentals of computational geometry
Extreme Points • The extreme points of a set S of points in the plane are the vertices of the convex hull at which the interior angle is less than π • Also a point is extreme iff there exists a line through that point that other wise does not touch the convex hull Fundamentals of computational geometry
Algorithms to find Extreme Points A] Using Non Extreme Points • Identifying non extreme points implies identifying extreme points • A point is non extreme iff it is inside some (closed) triangle whose vertices are the points of the set and is not itself a corner of that triangle. Thus given a triangle: • If a point is interior to triangle it is non extreme • Corners of the triangle might be extreme Thus as the output we will get the extreme points in some arbitrary order. Fundamentals of computational geometry
Algorithm: Interior Points for each i do for each j ≠ i do for each k ≠ i ≠ j do for each l ≠ k ≠ i ≠ j do if pl Δ(pi ,pj ,pk) then pl is nonextreme • There are four nested loops in this algorithm • Hence the order is O(n4) • For each of the n3 triangles, the test for extremeness costs n • It is important to find a faster algorithm Fundamentals of computational geometry
B] Extreme Edges • An edge is extreme if every point of S is on or to one side of the line determined by the edge • If we treat the edge as directed and let the left side of edge be inside then – the directed edge is not extreme if there is some point that is not left of it or on it • The output of this algorithm will be all the points on the convex hull in arbitrary order Fundamentals of computational geometry
Algorithm: Extreme Edges for each i do for each j ≠ i do for each k ≠ i ≠ j do if pk is not left or on (pi ,pj) then (pi ,pj)isnot extreme • There are three nested loops in this algorithm • Hence the order is O(n3) • For each of the n2 pair of points, the test for extremeness costs n • The vertices that are extreme can now be found Fundamentals of computational geometry
C] Gift Wrapping (a more realistic hull algorithm) • A minor variation of Extreme Edge algorithm can accelerate it by factor n as well as output the points in order • The idea is to use one extreme edge as an anchor for finding the next • Suppose the algorithm found an extreme edge whose unlinked endpoint is x • For each y of set S we compute the angle θ • The point that yields the smallest θ must determine an extreme edge • The output of this algorithm is all the points on the hull in boundary traversal order y e θ x Fundamentals of computational geometry
Idea: Think of wrapping a gift. Put the paper in contact with the gift and continue to wrap around from one surface to the next until you get all the way around. Fundamentals of computational geometry
Algorithm: Gift Wrapping Find the lowest point (smallest y coordinate) Let i0 be its index, and set i ← i0 repeat for each j ≠ i do compute counterclockwise angle θfrom previous hull edge Let k be the index of the point with the smallest θ Output (pi ,pk)as a hull edge i ← k until i =i0 • We use the lowest point as the anchor • The order is O(n2) • The cost is O(n) for each hull edge • The point set is wrapped by a string that bends the that bends with • minimum angle from previous to next hull edge Fundamentals of computational geometry
Jarvis March - Example p10 p9 p6 p5 p12 p7 p3 p4 p11 p1 p8 p2 p0 Fundamentals of computational geometry
Jarvis March - Example p10 p9 p6 p5 p12 p7 p3 p4 p11 p1 p8 p2 p0 Fundamentals of computational geometry
Jarvis March - Example p10 p9 p6 p5 p12 p7 p3 p4 p11 p1 p8 p2 p0 Fundamentals of computational geometry
Jarvis March - Example p10 p9 p6 p5 p12 p7 p3 p4 p11 p1 p8 p2 p0 Fundamentals of computational geometry
Jarvis March - Example p10 p9 p6 p5 p12 p7 p3 p4 p11 p1 p8 p2 p0 Fundamentals of computational geometry
Jarvis March - Example p10 p9 p6 p5 p12 p7 p3 p4 p11 p1 p8 p2 p0 Fundamentals of computational geometry
Jarvis March - Example p10 p9 p6 p5 p12 p7 p3 p4 p11 p1 p8 p2 p0 Fundamentals of computational geometry
Graham Scan - Example p10 p9 p6 p5 p12 p7 p3 p4 p11 p1 p8 p2 p0 Fundamentals of computational geometry
Graham Scan - Example p10 p9 p6 p5 p12 p7 p3 p4 p11 p1 p8 p2 p0 Fundamentals of computational geometry
Graham Scan - Example p10 p9 p6 p5 p12 p7 p3 p4 p11 p1 p8 p2 p0 Fundamentals of computational geometry
Graham Scan - Example p10 p9 p6 p5 p12 p7 p3 p4 p11 p1 p8 p2 p0 Fundamentals of computational geometry
Graham Scan - Example p10 p9 p6 p5 p12 p7 p3 p4 p11 p1 p8 p2 p0 Fundamentals of computational geometry
Graham Scan - Example p10 p9 p6 p5 p12 p7 p3 p4 p11 p1 p8 p2 p0 Fundamentals of computational geometry
Graham Scan - Example p10 p9 p6 p5 p12 p7 p3 p4 p11 p1 p8 p2 p0 Fundamentals of computational geometry