Presentation is loading. Please wait.

Presentation is loading. Please wait.

UMass Lowell Computer Science 91.504 Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2001 Lecture 1 Course Introduction Start of.

Similar presentations


Presentation on theme: "UMass Lowell Computer Science 91.504 Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2001 Lecture 1 Course Introduction Start of."— Presentation transcript:

1 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

2 Course Introduction What is Computational Geometry?

3 Advanced Algorithms Computational Geometry Telecommunications Visualization 91.504 Manufacturing ComputerGraphics Design Analyze Apply

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

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

6 How are They Related? ä Project each point upwards onto paraboloid z= x 2 + y 2 ä 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 searchdivide-and-conquerduality randomizationsweep-line derandomizationparallelism Algorithm Analysis Techniques: asymptotic analysis Data Structures: winged-edge, quad-edge, range tree, kd-tree Theoretical Computer Science principles: NP-completeness, hardness Growth of Functions Summations Recurrences Sets Probability MATH Proofs Geometry Graph Theory Combinatorics Linear Algebra

8 Computational Geometry in Context TheoreticalComputerScience Applied Computer Science AppliedMath Geometry ComputationalGeometryEfficient Geometric Algorithms Design Analyze Apply

9 Course Introduction My Computational Geometry Research

10 Survey of My Previous Computational Geometry Research Supporting Manufacturing Applications OrderedContainment Geometric Restriction Distance-BasedSubdivision MaximumRectangle Limited Gaps MinimalEnclosure Column-Based Layout Two-Phase Layout LatticePacking Containment Maximal Cover

11 Computational Geometry My Current Research Telecommunications Bioinformatics & Visualization Design Analyze Apply Covering/Assignment +

12 Course Introduction Course Description

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

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 Course Structure: 2 Parts Advanced Topics ApplicationsManufacturingModeling/Graphics Wireless Networks VisualizationTechniques(de)RandomizationApproximationRobustnessRepresentationsEpsilon-net Decomposition tree Basics Polygon Triangulation Partitioning (2D and 3D) Convex Hulls (2D and 3D) Convex Hulls Voronoi Diagrams ArrangementsSearch/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 functionChapter pointerdirectory ----------------------------------------------------- TriangulateChapter 1, Code 1.14/tri Convex Hull(2D)Chapter 3, Code 3.8/graham Convex Hull(3D)Chapter 4, Code 4.8/chull sphere.cChapter 4, Fig. 4.15/sphere Delaunay Triang Chapter 5, Code 5.2/dt SegSegIntChapter 7, Code 7.2/segseg Point-in-polyChapter 7, Code 7.13/inpoly Point-in-hedronChapter 7, Code 7.15/inhedron Int Conv PolyChapter 7, Code 7.17/convconv Mink ConvolveChapter 8, Code 8.5/mink Arm Move Chapter 8, Code 8.7/arm http://cs.smith.edu/~orourke/books/CompGeom/CompGeom.html

18 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 Growth of Functions Summations Recurrences Sets Probability MATH Proofs Geometry

19 Syllabus (current plan)

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 ä ä Homework30% ä ä Project25% ä ä Midterm (O’Rourke) 20% (open book, notes ) ä ä Final Exam25% (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 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” v0v0v0v0 v1v1v1v1 v2v2v2v2 v3v3v3v3 v4v4v4v4 e0e0e0e0 e1e1e1e1 e2e2e2e2 e3e3e3e3 e4e4e4e4 n=5 convex nonconvex simplenonsimple P

27 Art Gallery Theorems: The Theorem ä How many stationary guards are needed to guard the room?  Visibility: 2  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) . 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 Area of Polygon: Cross Product or Determinant 0 for 2D a bcA B T or...

36 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 v0v0v0v0 v1v1v1v1 v2v2v2v2 v3v3v3v3 v4v4v4v4 c a b d a c d b

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

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

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 #defineX 0 #defineY 1 typedefenum { FALSE, TRUE } bool; #defineDIM 2 /* Dimension of points */ typedefint tPointi[DIM]; /* Type integer point */ X is 0 th element of point; Y is 1st integers to minimize roundoff errors (but overflow is possible…) uppercase constants lowercase type identifier i for integer

41 Implementation Issues: Polygon doubly linked circular list for easy vertex deletion/insertion typedefstruct tVertexStructure tsVertex; /* Used only in NEW(). */ typedeftsVertex *tVertex; structtVertexStructure { intvnum;/* Index */ tPointiv;/* Coordinates */ bool ear;/* TRUE iff an ear */ tVertex next,prev; }; /* Global variable definitions */ tVertexvertices = NULL;/* "Head" of circular list. */ intnvertices = 0;/* Total number of polygon vertices. */

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]) - 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 that are clearly visible to each other (no grazing contact) (no grazing contact) which one is a legal diagonal?

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

46 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. ---------------------------------------------------------------------*/ boolIntersectProp( tPointi a, tPointi b, tPointi c, tPointi d ) { /* Eliminate improper cases. */ /* Eliminate improper cases. */ if ( Collinear(a,b,c) || Collinear(a,b,d) || Collinear(c,d,a) || Collinear(c,d,b)) if ( Collinear(a,b,c) || Collinear(a,b,d) || Collinear(c,d,a) || Collinear(c,d,b)) return FALSE; return FALSE; return Xor( Left(a,b,c), Left(a,b,d) ) && Xor( Left(c,d,a), Left(c,d,b) ); return Xor( Left(a,b,c), Left(a,b,d) ) && Xor( Left(c,d,a), Left(c,d,b) );} a bcd a b c d acd b which are “proper” intersections?

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

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

49 Triangulation: Implementation Diagonals (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; tVertex c, c1; /* For each edge (c,c1) of P */ /* For each edge (c,c1) of P */ c = vertices; c = vertices; do { c1 = c->next; /* Skip edges incident to a or b */ 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 ) ) && Intersect( a->v, b->v, c->v, c1->v ) ) return FALSE; return FALSE; c = c->next; } while ( c != vertices ); } while ( c != vertices ); return TRUE; 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. */ tVertex a0,a1;/* a0,a,a1 are consecutive vertices. */ a1 = a->next; a1 = a->next; a0 = a->prev; a0 = a->prev; /* If a is a convex vertex... */ /* If a is a convex vertex... */ if( LeftOn( a->v, a1->v, a0->v ) ) 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: */ /* Else a is reflex: */ return !( LeftOn( a->v, b->v, a1->v ) && LeftOn( b->v, a->v, a0->v ) ); return !( LeftOn( a->v, b->v, a1->v ) && LeftOn( b->v, a->v, a0->v ) );}

51 Triangulation: Implementation /* Prints out n-3 diagonals (as pairs of integer indices) which form a triangulation of P*/ void Triangulate( void ){ tVertex v0, v1, v2, v3, v4;/* five consecutive vertices */ tVertex v0, v1, v2, v3, v4;/* five consecutive vertices */ int n = nvertices;/* number of vertices; shrinks to 3. */ int n = nvertices;/* number of vertices; shrinks to 3. */ EarInit(); EarInit(); while ( n > 3 ) { /* Inner loop searches for an ear and removes it. */ while ( n > 3 ) { /* Inner loop searches for an ear and removes it. */ v2 = vertices; do { if (v2->ear) { /* Ear found. */ v3 = v2->next; v4 = v3->next; v1 = v2->prev; v0 = v1->prev; PrintDiagonal( v1, v3 ); v1->ear = Diagonal( v0, v3 ); v3->ear = Diagonal( v1, v4 ); v1->next = v3; v3->prev = v1; /* Update earity. */ vertices = v3;/* In case the head was v2. */ n--; n--; break; /* out of inner loop; resume outer loop */ break; /* out of inner loop; resume outer loop */ } /* end if ear found */ } /* end if ear found */ v2 = v2->next; v2 = v2->next; } while ( v2 != vertices ); } while ( v2 != vertices ); } /* end outer while loop */ } /* end outer while loop */ } /* end Triangulate */

52 Triangulation: Implementation Analysis O(n 2 ) + + Naïve Analysis Tighter Analysis O(n)iterations Algorithm: TRIANGULATION Initialize the ear tip status of each vertex. while n > 3 do Locate an ear tip v 2. Locate an ear tip v 2. Output diagonal v 1 v 3. Delete v 2. Update the ear tip status of v 1 and v 3. O(n) O(n)iterations O(n)iterations O(n) Total: O(n 3 ) Total: O(n 2 )

53 Homework 1 Fri, 2/9 Wed, 2/14 Chapter 1 (O’Rourke) problems 1 & 2 problems 1 & 2 Extra credit may be turned in any time during week of 2/12 HW# Assigned Due Content

54 Machine Accounts ä Each student has an account on my machine: minkowski.cs.uml.edu ä Username is the same as your username on CS ä Password is your initials followed by the last 5 digits on the bottom right hand corner of the back of your student id card (1 exception) ä To remotely log in, use a secure shell (e.g. ssh) ä To transfer files, use a secure FTP (e.g. sftpc) ä Saturn has an sftpc client ä Code to use with assignments will be there.


Download ppt "UMass Lowell Computer Science 91.504 Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2001 Lecture 1 Course Introduction Start of."

Similar presentations


Ads by Google