Presentation is loading. Please wait.

Presentation is loading. Please wait.

UMass Lowell Computer Science 91.504 Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2010 O’Rourke Chapter 4: 3D Convex Hulls Thursday,

Similar presentations


Presentation on theme: "UMass Lowell Computer Science 91.504 Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2010 O’Rourke Chapter 4: 3D Convex Hulls Thursday,"— Presentation transcript:

1 UMass Lowell Computer Science 91.504 Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2010 O’Rourke Chapter 4: 3D Convex Hulls Thursday, 2/18/10

2 Chapter 4 3D Convex Hulls PolyhedraAlgorithmsImplementation Polyhedral Boundary Representations Randomized Incremental Algorithm Higher Dimensions

3 Polyhedra: What are they? ä Polyhedron generalizes 2D polygon to 3D ä Consists of flat polygonal faces ä Boundary/surface contains ä 0D vertices1D edges2D faces ä Components intersect “properly.” Each face pair: ä disjoint or have vertex in common or have vertex/edge/vertex in common ä Local topology is “proper” ä at every point neighborhood is homeomorphic to disk ä Global topology is “proper” ä connected, closed, bounded ä may have holes (by default no holes in our work) not polyhedra! polyhedra for more examples, see http://www.ScienceU.com/geometry/facts/solids/handson.html source: O’Rourke, Computational Geometry in C

4 Polyhedra: A Flawed Definition ä Definition of Polyhedron 1 ä A polyhedron 1 is a region of space bounded by a finite set of polygons such that: ä every polygon shares at least one edge with some other polygon ä every edge is shared by exactly two polygons. - What is wrong with this definition? - Find an example of an object that is a polyhedron 1 but is not a polyhedron. polyhedra and polyhedra 1 ? not polyhedra and not polyhedra 1 ? source: O’Rourke, Computational Geometry in C

5 Polyhedra: Regular Polytopes ä Convex polyhedra are polytopes ä Regular polyhedra are polytopes that have: ä regular faces, = faces, = solid (dihedral) angles ä There are exactly 5 regular polytopes Excellent math references by H.S.M. Coxeter: - Introduction to Geometry (2nd edition), Wiley &Sons, 1969 - Regular Polytopes, Dover Publications, 1973 source: O’Rourke, Computational Geometry in C dodecahedron icosahedron

6 Polyhedra: Euler’s Formula Proof has 3 parts: 1) Convert polyhedron surface to planar graph 2) Tree theorem 3) Proof by induction V - E + F = 2 for genus 0 (no holes) sources: O’Rourke, Computational Geometry in C & Figure from de Berg et al. Ch 11.

7 Polyhedra: Euler’s Formula Euler’s formula implies V, E, F are related. Euler’s formula implies V, E, F are related. Relationship is LINEAR! Relationship is LINEAR! If V = n, then If V = n, then Proof Sketch: Proof Sketch: Assume polytope is simplicial: all faces triangles Assume polytope is simplicial: all faces triangles Each face has 3 edges (E = 3F) Each face has 3 edges (E = 3F) But double-counted shared edges, so E = 3F/2 implying F = 2E/3 But double-counted shared edges, so E = 3F/2 implying F = 2E/3 Substitute F = 2E/3 into Euler’s formula Substitute F = 2E/3 into Euler’s formula V – 2 = E/3 implies E = 3V – 6 < 3V = 3n in O(n) V – 2 = E/3 implies E = 3V – 6 < 3V = 3n in O(n) F = 2E/3 = 2V – 4 < 2V = 2n in O(n) F = 2E/3 = 2V – 4 < 2V = 2n in O(n) V - E + F = 2 for genus 0 (no holes) sources: O’Rourke, Computational Geometry in C

8 Polyhedral Boundary Representations winged edge f0f0f0f0 f1f1f1f1 e e1+e1+e1+e1+ e1-e1-e1-e1- e0+e0+e0+e0+ e0-e0-e0-e0- v1v1v1v1 v0v0v0v0 twin edge [ DCEL: doubly connected edge list* ] f0f0f0f0 f1f1f1f1 e e 4,0 v1v1v1v1 v0v0v0v0 - focus is on edge - edge orientation is arbitrary - represent edge as 2 halves - lists: vertex, face, edge/twin - more storage space - facilitates face traversal - can represent holes with face inner/outer edge pointer e’s twin v2v2v2v2 v7v7v7v7 v6v6v6v6 v5v5v5v5 v3v3v3v3 v4v4v4v4 e 0,1 source: O’Rourke, Computational Geometry in C * see also deBerg et al. for DCEL description

9 Polyhedral Boundary Representations: Quad-Edge - general: subdivision of oriented 2D manifold - edge record is part of: - endpoint 1 list - endpoint 2 list - face A list - face B list e 0,1 f0f0f0f0 f1f1f1f1 e 4,0 v1v1v1v1 v0v0v0v0 v2v2v2v2 v7v7v7v7 v6v6v6v6 v5v5v5v5 v3v3v3v3 v4v4v4v4 e 0,1 twin edge [DCEL: doubly connected edge list] e 0,0 e 1,0 e 2,0 e 3,0 e 5,1 e 6,1 e 7,1 e 1,1 e 5,1 e 6,1 e 7,1 e 1,0 e 0,0 e 2,0 e 3,0 e 4,0 e 1,1 source: O’Rourke, Computational Geometry in C unbounded face f1f1 f0f0 v0v0 v5v5 v6v6 v7v7 v1v1 v2v2 v3v3 v4v4

10 Algorithms: 2D Gift Wrapping ä Use one extreme edge as an anchor for finding the next  O(n 2 ) Algorithm: GIFT WRAPPING i 0 index of the lowest point i i 0 repeat for each j = i for each j = i Compute counterclockwise angle  from previous hull edge Compute counterclockwise angle  from previous hull edge k index of point with smallest  k index of point with smallest  Output (p i, p k ) as a hull edge Output (p i, p k ) as a hull edge i k i k until i = i 0 source: O’Rourke, Computational Geometry in C

11 Algorithms: 3D Gift Wrapping CxHull Animations: http://www.cse.unsw.edu.au/~lambert/java/3d/hull.html O(n 2 ) time [output sensitive: O(nF) for F faces on hull]

12 Algorithms: 2D Divide-and-Conquer ä Divide-and-Conquer in a geometric setting ä O(n) merge step is the challenge ä Find upper and lower tangents ä Lower tangent: find rightmost pt of A & leftmost pt of B; then “walk it downwards” ä Idea is extended to 3D in Chapter 4. Algorithm: 2D DIVIDE-and-CONQUER Sort points by x coordinate Divide points into 2 sets A and B: A contains left n/2 points B contains right n/2 points Compute ConvexHull(A) and ConvexHull(B) recursively Merge ConvexHull(A) and ConvexHull(B) O(nlgn) A B source: O’Rourke, Computational Geometry in C

13 Algorithms: 3D Divide and Conquer CxHull Animations: http://www.cse.unsw.edu.au/~lambert/java/3d/hull.html O(n log n) time !

14 Algorithms: 3D Divide and Conquer source: O’Rourke, Computational Geometry in C Hard work is in MERGE of A with B: O( n ) -Add single “band” of faces with topology of cylinder without caps -Each face uses at least 1 edge from A or B - # faces <= # edges so O( n ) faces -Each face added in O(1) amortized time: -Lemma: When plane p is rotated about line through ab, first point c to be hit is a vertex adjacent to either a or b. -Point c can be found in O(1) amortized time using aggregate analysis. -Finding it might require examining  ( n ) neighbors, but monotonicity of counterclockwise search helps. -Each edge is “charged”/examined at most twice (once from each endpoint). -Discarding Hidden Faces: -Wrapping discovers “shadow boundary” edges, but don’t necessarily form simple cycle (see example on p. 113 Fig. 4.7). -Hidden faces do form a connected cap: use e.g. DFS from shadow boundary.

15 Algorithms: 2D QuickHull ä Concentrate on points close to hull boundary ä Named for similarity to Quicksort a b O(n 2 ) Algorithm: 2D QUICK HULL function QuickHull(a,b,S) if S = 0 return() if S = 0 return() else else c index of point with max distance from ab c index of point with max distance from ab A points strictly right of (a,c) A points strictly right of (a,c) B points strictly right of (c,b) B points strictly right of (c,b) return QuickHull(a,c,A) + (c) + QuickHull(c,b,B) return QuickHull(a,c,A) + (c) + QuickHull(c,b,B) source: O’Rourke, Computational Geometry in C

16 Algorithms: 3D QuickHull CxHull Animations: http://www.cse.unsw.edu.au/~lambert/java/3d/hull.html

17 Algorithms: 2D Incremental ä Add points, one at a time ä update hull for each new point ä Key step becomes adding a single point to an existing hull. ä Idea is extended to 3D in Chapter 4. O(n 2 ) Algorithm: 2D INCREMENTAL ALGORITHM Let H 2 ConvexHull{p 0, p 1, p 2 } for k 3 to n - 1 do H k ConvexHull{ H k-1 U p k } H k ConvexHull{ H k-1 U p k } can be improved to O(nlgn) source: O’Rourke, Computational Geometry in C

18 Algorithms: 3D Incremental ä Add points, one at a time ä Update hull Q for each new point p ä Case 1: p is in existing hull Q ä Must be on positive side of every plane determined by a face of Q. ä Left-of test uses volume of tetrahedron (board work) ä # faces in O(n) due to Euler, so test takes only O(n) time. ä Discard p if it is inside existing hull. ä Case 2: p is not in existing hull Q ä Compute cone tangent to Q whose apex is p. ä Cone consists of triangular tangent faces. ä Base of each is an edge of Q. ä Construct new hull using cone ä Discard faces that are not visible. p Q source: O’Rourke, Computational Geometry in C

19 Algorithms: 3D Incremental O(n 2 ) Algorithm: 3D INCREMENTAL ALGORITHM Let H 3 ConvexHull{ p 0, p 1, p 2, p 3 } = tetrahedron for i 4 to n - 1 do for each face f of H i-1 do for each face f of H i-1 do compute signed volume of tetrahedron* determined by f and p i compute signed volume of tetrahedron* determined by f and p i mark f visible iff signed volume < 0 mark f visible iff signed volume < 0 if no faces are visible then Discard p i (it is inside H i-1 ) else for each border edge e of H i-1 do for each border edge e of H i-1 do Construct cone face determined by e and p i for each visible face f do for each visible face f do Delete f Update H i Update H i Randomized incremental has expected O(nlgn) time. source: O’Rourke, Computational Geometry in C *Use determinant of a matrix.

20 Algorithms: 3D Incremental Main AddOne ReadVertices DoubleTriangle Print MakeNullVertex Collinear MakeFace VolumeSign ConstructHull MakeConeFace MakeCcw Cleanup CleanEdges CleanFaces CleanVertices MakeNullEdge MakeNullFace Calling Diagram for O’Rourke’s C Implementation of 3D Incremental Algorithm source: O’Rourke, Computational Geometry in C

21 Algorithms: 3D Incremental CxHull Animations: http://www.cse.unsw.edu.au/~lambert/java/3d/hull.html O(n 2 ) time

22 ä Clarkson, Shor (1989) ä O(nlgn) expected time ä Variant of 3D incremental algorithm ä Avoid brute-force visible face test ä Maintain CONFLICT GRAPH ä For each face of H i-1 record which not-yet-added points can see it ä For each not-yet-added point, record which faces it can see (those it is “in conflict” with) ä Key observation allowing fast adding of face = CH(e,p i ), where e is a polytope edge on border between faces visible and invisible from p i : ä If point sees a face, it must have been able to see one or both faces adjacent to e on H i-1 Algorithms: 3D Randomized Incremental Complementary sets of information: source: O’Rourke, Computational Geometry in C

23 Algorithms: 3D Randomized Incremental ä More detail is found in de Berg et al. Ch 11: Section 11.2-11.3 ä Bipartite conflict graph ä When point and face cannot coexist in the convex hull. ä Once point p in P conflict ( f ) is added to convex hull, facet f must be removed; they conflict. ä Initialize in linear time for convex hull of first tetrahedron. ä Conflict list of a new facet f: test points in conflict lists of two facets f 1 and f 2 incident to “horizon” (“shadow”) edge e in pre- existing convex hull. ä Need to bound cardinality of conflict lists to analyze this…see subtle analysis of Section 11.3, which uses elegant notion of configuration space* framework for a generic randomized incremental algorithm from Section 9.5. points not yet inserted facets of current hull *Not the same as motion planning configuration space! Conflict graph G

24 Algorithms: 3D Randomized Incremental ä Pseudocode from de Berg et al. Ch 11: Conflict graph G

25 Combinatorial Size of Convex Hull Qhull: http://www.qhull.org Convex Hull boundary is intersection of hyperplanes, so worst-case combinatorial size (number of features) (not necessarily running time) complexity is in:

26 3D Visibility ä To build our 3D visibility intuition (homework): ä T = planar triangle in 3D ä C = closed region bounded by a 3D cube frequent problem in graphics What is the largest number of vertices P can have for any triangle? T C source: O’Rourke, Computational Geometry in C


Download ppt "UMass Lowell Computer Science 91.504 Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2010 O’Rourke Chapter 4: 3D Convex Hulls Thursday,"

Similar presentations


Ads by Google