1 / 54

UMass Lowell Computer Science 91.504 Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2001

UMass Lowell Computer Science 91.504 Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2001. Lecture 1 Course Introduction Start of Part I Material Makeup for 2/5/01. Course Introduction. What is Computational Geometry?. Manufacturing.

iain
Télécharger la présentation

UMass Lowell Computer Science 91.504 Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2001

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. UMass Lowell Computer Science 91.504Advanced AlgorithmsComputational GeometryProf. Karen DanielsSpring, 2001 Lecture 1 Course Introduction Start of Part I Material Makeup for 2/5/01

  2. Course Introduction What is Computational Geometry?

  3. Manufacturing Advanced AlgorithmsComputational Geometry 91.504 Computer Graphics Visualization Design Analyze Core Geometric Algorithms Application-Based Algorithms Apply Telecommunications

  4. Typical Problems • maintaining line arrangements • polygon partitioning • nearest neighbor search • kd-trees • bin packing • Voronoi diagram • simplifying polygons • shape similarity • convex hull SOURCE: Steve Skiena’s Algorithm Design Manual (for problem descriptions, see graphics gallery at http://www.cs.sunysb.edu/~algorith)

  5. Convex Hull Voronoi Diagram New Point Delaunay Triangulation Common Computational Geometry Structures

  6. How are They Related? • Project each point upwards onto paraboloid z= x2 + y2 • Construct 3D Convex Hull • Discard “top” faces • Project Convex Hull down to form Delaunay Triangulation • Form dual of the Delaunay Triangulation to obtain Voronoi Diagram

  7. Sample Tools of the Trade Algorithm Design Patterns/Techniques: binary search divide-and-conquer duality randomization sweep-line derandomizationparallelism Algorithm Analysis Techniques: asymptotic analysis Data Structures: winged-edge, quad-edge, range tree, kd-tree Theoretical Computer Scienceprinciples: NP-completeness, hardness MATH Sets Proofs Geometry Summations Linear Algebra Probability Growth of Functions Recurrences Graph Theory Combinatorics

  8. Geometry Theoretical Computer Science Applied Math Computational Geometry Efficient Geometric Algorithms Design Analyze Applied Computer Science Apply Computational Geometryin Context

  9. Course Introduction My Computational Geometry Research

  10. Distance-Based Subdivision Maximum Rectangle Geometric Restriction Ordered Containment Limited Gaps Containment Minimal Enclosure Core Algorithms Maximal Cover Application-Based Algorithms Lattice Packing Two-Phase Layout Column-Based Layout Survey of My Previous Computational Geometry ResearchSupporting Manufacturing Applications

  11. Design Analyze + Core Algorithms Covering/Assignment Application-Based Algorithms Apply Bioinformatics & Visualization Telecommunications Computational GeometryMy Current Research

  12. Course Introduction Course Description

  13. Web Page http://www.cs.uml.edu/~kdaniels/courses/cg2001spring.html

  14. Nature of the Course • Elective graduate Computer Science course • Theory and Practice • Theory: “Pencil-and-paper” exercises • design an algorithm • analyze its complexity • modify an existing algorithm • Practice • Programs • Real-world examples

  15. Part 1 Part 2 Course Structure: 2 Parts Advanced Topics Applications Manufacturing Modeling/Graphics Wireless Networks Visualization Techniques (de)Randomization Approximation Robustness Representations Epsilon-net Decomposition tree Basics Polygon Triangulation Partitioning (2D and 3D) Convex Hulls Voronoi Diagrams Arrangements Search/Intersection Motion Planning

  16. Textbook • Required: • Computational Geometry in C • second edition • by Joseph O’Rourke • Cambridge University Press • 1998 • see course web site for ISBN number(s) & errata list ordered for UML bookstore Web Site: http://cs.smith.edu/~orourke/books/compgeom.html

  17. Textbook Java Demo Applet Code function Chapter pointer directory ----------------------------------------------------- Triangulate Chapter 1, Code 1.14 /tri Convex Hull(2D) Chapter 3,Code 3.8 /graham Convex Hull(3D) Chapter 4, Code 4.8 /chull sphere.c Chapter 4, Fig. 4.15 /sphere Delaunay Triang Chapter 5, Code 5.2 /dt SegSegInt Chapter 7, Code 7.2 /segseg Point-in-poly Chapter 7, Code 7.13 /inpoly Point-in-hedron Chapter 7, Code 7.15 /inhedron Int Conv Poly Chapter 7, Code 7.17 /convconv Mink Convolve Chapter 8, Code 8.5 /mink Arm Move Chapter 8, Code 8.7 /arm http://cs.smith.edu/~orourke/books/CompGeom/CompGeom.html

  18. MATH Geometry Summations Sets Proofs Growth of Functions Probability Recurrences Prerequisites • Graduate Algorithms (91.503) • Coding experience in C, C++ or Java • Standard CS graduate-level math prerequisites + high school Euclidean geometry • additional helpful math background: • linear algebra, topology

  19. Syllabus (current plan) Part 1 Part 2

  20. Literature for Part II (current plan)

  21. Literature for Part II (current plan)(continued)

  22. Important Dates • Midterm Exam: Monday, 3/12 • Final Exam: TBA If you have conflicts with exam dates, please notify me as soon as possible.

  23. Grading • Homework 30% • Project 25% • Midterm (O’Rourke) 20% (open book, notes ) • Final Exam 25% (open book, notes )

  24. Part I O’Rourke Chapter 1 Polygon Triangulation: Art Gallery Theorems Triangulation: Theory Area of Polygon Implementation Issues Segment Intersection Triangulation: Implementation

  25. Art Gallery Theorems • Polygons • The Art Gallery Theorem • Fiske’s Proof of Sufficiency

  26. e1 v1 v2 e0 e2 v0 v3 e3 e4 v4 Art Gallery Theorems: Polygons • What is a polygon? • “region of a plane bounded by a finite collection of line segments forming a simple closed curve” n=5 P nonconvex convex simple nonsimple

  27. Art Gallery Theorems: The Theorem • How many stationary guards are needed to guard the room? • Visibility: 2p range • Empirically: • n is sufficient (2D) • n necessary for small n? 3? 4? 5? • Guess: in general n/3 necessary Find G(n) = the maximum (over all n-vertex polygons) of the minimum number of guards needed to cover the polygon.

  28. Art Gallery Theorems: Fiske’s Proof • Given arbitrary n-vertex P: • Triangulate P using diagonals • Form triangulation graph G • G can be 3-colored (proof later...) • Place a guard at each same-colored vertex of G • This covers all of P • By pigeon-hole principle: n/3 guards Diagonal: line segment between 2 vertices that are clearly visible to each other (no grazing contact)

  29. Triangulation Theory • Existence of a Diagonal • Properties of Triangulations • Triangulation Dual • 3-Coloring Proof

  30. Triangulation Theory: Existence of a Diagonal • Step 1: Every polygon must have >= 1 strictly convex vertex (no collinearity) • Step 2: Every polygon of n >= 4 vertices has a diagonal • Conclusion: Every n-vertex polygon P may be partitioned into triangles by adding (>=0) diagonals [proof by induction using diagonals]

  31. Triangulation Theory: Properties • Every triangulation of an n-vertex polygon P uses n-3 diagonals and consists of n-2 triangles. • The sum of the internal angles of an n-vertex polygon is (n-2)p. 9 vertices 7 triangles 6 diagonals

  32. Triangulation Theory: Duality • The dual of a triangulation is a tree with each node of degree at most 3. • “2-Ears” Theorem: every polygon of n >= 4 vertices has at least 2 nonoverlapping ears. ear ear

  33. Triangulation Theory: 3-Coloring • “2-Ears” Theorem can be used to easily prove 3-colorability of triangulation graphs • Induction on n • Base case: n = 3 • For n >= 4: • 2-ears theorem guarantees that an ear abc exists • apply inductive hypothesis to polygon P’ without ear • “reattaching” ear adds back in one vertex (w.l.o.g. b) • color b whatever color a and c don’t use • result is a 3-coloring of P a b c

  34. Area of Polygon • Cross Product • Determinant Form • Area of a Convex Polygon • Area of a Convex Quadrilateral • Area of a Nonconvex Quadrilateral • Area from an Arbitrary Center • Volume in >= 3 Dimensions

  35. c T B a b A or... Area of Polygon: Cross Product or Determinant 0 for 2D

  36. v1 v2 v0 v3 v4 d d c a a c b b Area of Polygon: Convex Quadrilateral • Could find area of polygon via triangulation...but we want to avoid this! • To see how, first consider triangulation for 2 easy polygon cases: Convex Convex Quadrilateral

  37. c d b a c b T p2 a p1 Area of Polygon: (continued) • Nonconvex Quadrilateral • Arbitrary Center negative area more efficient

  38. z c=(0,0,1) d=(0,0,0) b=(0,1,0) a=(1,0,0) x Area of Polygon: Volume • Determinant area formulation extends to higher dimensions. • In 3D: y

  39. Implementation Issues • Representation of a Point • Representation of a Polygon • Code for Area Text describes C code. C or Java code available from text’s Web site

  40. Implementation Issues: Point C code uppercase constants X is 0th element of point; Y is 1st #define X 0 #define Y 1 typedef enum { FALSE, TRUE } bool; #define DIM 2 /* Dimension of points */ typedef int tPointi[DIM]; /* Type integer point */ i for integer integers to minimize roundoff errors (but overflow is possible…) lowercase type identifier

  41. Implementation Issues: Polygon typedef struct tVertexStructure tsVertex; /* Used only in NEW(). */ typedef tsVertex *tVertex; struct tVertexStructure { int vnum; /* Index */ tPointi v; /* Coordinates */ bool ear; /* TRUE iff an ear */ tVertex next,prev; }; /* Global variable definitions */ tVertex vertices = NULL; /* "Head" of circular list. */ int nvertices = 0; /* Total number of polygon vertices. */ doubly linked circular list for easy vertex deletion/insertion

  42. Implementation Issues: Area Code /*--------------------------------------------------------------------- Returns twice the signed area of the triangle determined by a,b,c. The area is positive if a,b,c are oriented ccw, negative if cw,and zero if the points are collinear. ---------------------------------------------------------------------*/ int Area2( tPointi a, tPointi b, tPointi c ) { return (b[X] - a[X]) * (c[Y] - a[Y]) - (c[X] - a[X]) * (b[Y] - a[Y]); } minimizes number of multiplications to help avoid overflow

  43. Segment Intersection • Diagonals: key triangulation step • Left • Boolean Intersection • Segment Intersection Code Infinite slopes are problematic, so avoid slopes!

  44. Segment Intersection: Diagonals Diagonal: line segment between 2 vertices that are clearly visible to each other (no grazing contact) which one is a legal diagonal?

  45. c b a Segment Intersection: Left /*--------------------------------------------------------------------- Returns true iff c is strictly to the left of the directed line through a to b. ---------------------------------------------------------------------*/ bool Left( tPointi a, tPointi b, tPointi c ) { return AreaSign( a, b, c ) > 0; } returns sign (+,0,-) of area instead of area value itself

  46. c c b b b c d d d a a a Segment Intersection: Boolean Intersection /*--------------------------------------------------------------------- Returns true iff ab properly intersects cd: they share a point interior to both segments. The properness of the intersection is ensured by using strict leftness. ---------------------------------------------------------------------*/ bool IntersectProp( tPointi a, tPointi b, tPointi c, tPointi d ) { /* Eliminate improper cases. */ if ( Collinear(a,b,c) || Collinear(a,b,d) || Collinear(c,d,a) || Collinear(c,d,b)) return FALSE; return Xor( Left(a,b,c), Left(a,b,d) ) && Xor( Left(c,d,a), Left(c,d,b) ); } which are “proper” intersections?

  47. Segment Intersection: Intersection Code /*--------------------------------------------------------------------- Returns TRUE iff segments ab and cd intersect, properly or improperly. ---------------------------------------------------------------------*/ bool Intersect( tPointi a, tPointi b, tPointi c, tPointi d ) { if ( IntersectProp( a, b, c, d ) ) return TRUE; else if (Between( a, b, c ) || Between( a, b, d ) || Between( c, d, a ) || Between( c, d, b )) return TRUE; else return FALSE; }

  48. Triangulation: Implementation Algorithm: TRIANGULATION Initialize the ear tip status of each vertex. while n > 3 do Locate an ear tip v2. Output diagonal v1 v3. Delete v2. Update the ear tip status of v1 and v3. • Diagonals (Internal or External) • InCone (distinguish Internal from External) • Triangulation by Ear Removal • Analysis

  49. Triangulation: ImplementationDiagonals (Internal or External) /*--------------------------------------------------------------------- Returns TRUE iff (a,b) is a proper internal *or* external diagonal of P, *ignoring edges incident to a and b*. ---------------------------------------------------------------------*/ bool Diagonalie( tVertex a, tVertex b ) { tVertex c, c1; /* For each edge (c,c1) of P */ c = vertices; do { c1 = c->next; /* Skip edges incident to a or b */ if ( ( c != a ) && ( c1 != a ) && ( c != b ) && ( c1 != b ) && Intersect( a->v, b->v, c->v, c1->v ) ) return FALSE; c = c->next; } while ( c != vertices ); return TRUE; }

  50. Triangulation: Implementation InCone /*--------------------------------------------------------------------- Returns TRUE iff the diagonal (a,b) is strictly internal to the polygon in the neighborhood of the a endpoint. ---------------------------------------------------------------------*/ bool InCone( tVertex a, tVertex b ) { tVertex a0,a1; /* a0,a,a1 are consecutive vertices. */ a1 = a->next; a0 = a->prev; /* If a is a convex vertex ... */ if( LeftOn( a->v, a1->v, a0->v ) ) return Left( a->v, b->v, a0->v ) && Left( b->v, a->v, a1->v ); /* Else a is reflex: */ return !( LeftOn( a->v, b->v, a1->v ) && LeftOn( b->v, a->v, a0->v ) ); }

More Related