ACM Schedule… 2/23 Geometry problems 3/2 Lab problems (geometry!) 3/30 "Mock" competition and lab session (4:15) 3/9 Final algorithm discussion… 3/16 [Spring.

Slides:



Advertisements
Similar presentations
Jotto! JRsSRsElderly slate 3 This term's first class to guess another's word earns 1 problem... slate 2slate 1 This term's last class to have its word.
Advertisements

Computational Geometry
ADA: 15. Basic Math1 Objective o a reminder about dot product and cross product, and their use for analyzing line segments (e.g. do two segments.
Jotto! JRsSRs other diner 1 This term's first class to guess another's word earns 1 problem... diner 1diner 2 This term's last class to have its word guessed.
Brute-Force Triangulation
Computing Convex Hulls CLRS 33.3
Convex Hull obstacle start end Convex Hull Convex Hull
CS16: Introduction to Data Structures & Algorithms
The N-Queens Problem lab01.
C o m p u t i n g C O N V E X H U L L S by Kok Lim Low 10 Nov 1998 COMP Presentation.
Geometric Algorithms João Comba. Example: Convex Hull convex Non-convex.
The Divide-and-Conquer Strategy
Convex Hulls in Two Dimensions Definitions Basic algorithms Gift Wrapping (algorithm of Jarvis ) Graham scan Divide and conquer Convex Hull for line intersections.
CS4413 Divide-and-Conquer
Convex Hulls May Shmuel Wimer Bar Ilan Univ., Eng. Faculty Technion, EE Faculty.
Convex Sets & Concave Sets A planar region R is called convex if and only if for any pair of points p, q in R, the line segment pq lies completely in R.
1 Convex Hull in Two Dimensions Jyun-Ming Chen Refs: deBerg et al. (Chap. 1) O’Rourke (Chap. 3)
Computational Geometry
Lecture 3: Reduce to known problem Convex Hull (section 33.3 of CLRS). Suppose we have a bunch of points in the plane, given by their x and y coordinates.
Convex Hull Problem Presented By Erion Lin. Outline Convex Hull Problem Voronoi Diagram Fermat Point.
Advanced Algorithm Design and Analysis (Lecture 10) SW5 fall 2004 Simonas Šaltenis E1-215b
Computational Geometry for the Tablet PC
Informal Definition : Let S is set of nails sticking out from a board. the convex hull can be visualized as the shape formed by a tight rubber band that.
1 Today’s Material Computational Geometry Problems –Closest Pair Problem –Convex Hull Jarvis’s March, Graham’s scan –Farthest Point Problem.
Algorithms and Data Structures Lecture 13. Agenda: Plane Geometry: algorithms on polygons - Verification if point belongs to a polygon - Convex hull.
5/17/2015 1:32 AMConvex Hull1 obstacle start end.
November 4, Algorithms and Data Structures Lecture XIV Simonas Šaltenis Nykredit Center for Database Research Aalborg University
Computational Geometry Piyush Kumar (Lecture 3: Convexity and Convex hulls) Welcome to CIS5930.
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2007 Lecture 3 Chapter 3: 2D Convex Hulls Friday,
Computational Geometry Overview from Cormen, et al. Chapter 33
Convex Hull Computation ● Applications of Convex Hull Computation ● Definitions ● Basic Math Functions ● Algorithms Algorithm Speed Discovered By Brute.
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2001 Lecture 2 Chapter 2: Polygon Partitioning.
Brute-Force Triangulation
Computational Geometry
Advanced Algorithm Design and Analysis (Lecture 9) SW5 fall 2004 Simonas Šaltenis E1-215b
Computational Geometry Convex Hulls Robust Geometric Primitives Degeneracy and Stability Nick Pilkington.
ACM Welcome! Sep 11 Welcome! and DP problems ~ 6 problems Sep 18 Lab session ~ 6 problems Sep 25 Discussion session on graph problems ~ 6 problems Oct.
Convex Hull. What is the Convex Hull? Imagine a set of points on a board with a nail hammered into each point. Now stretch a rubber band over all the.
Computational Geometry (35/33) Line Segments and cross-product Segment intersection and Sweep Line Convex Hull and Graham’s Scan, Jarvis’s march Divide-and-Conquer.
Computational Geometry Course Summary (First Half) Spring 2008 Pay special attention to: algorithm details (able to explain correctness and carry out a.
C o m p u t i n g C O N V E X H U L L S. Presentation Outline 2D Convex Hulls –Definitions and Properties –Approaches: Brute Force Gift Wrapping QuickHull.
Fundamental Data Structures and Algorithms Klaus Sutner April 27, 2004 Computational Geometry.
Fundamental Data Structures and Algorithms Margaret Reid-Miller 27 April 2004 Computational Geometry.
Convex Hull. University of Manchester biologists used lasers to measure the minimum amount of skin required to wrap around the skeletons of modern-day.
15. Computational Geometry Topics
Computational Geometry 2D Convex Hulls
A planar region R is called convex if and only if for any pair of points p, q in R, the line segment pq lies completely in R. Otherwise, it is called concave.
COMPUTATIONAL GEOMETRY AND MATRIX MULTIPLICATION Mohammed Zeeshan Farooqui Minhaj Uddin.
Convex Hull 2012/10/23. Convex vs. Concave A polygon P is convex if for every pair of points x and y in P, the line xy is also in P; otherwise, it is.
Lecture 15 Computational Geometry Geometry sweeping Geometric preliminaries Some basics geometry algorithms.
CS6234 Advanced Algorithms - Convex hull. Terminologies – ◦ Convex hull of a set Q of points is the smallest convex polygon P for which each point in.
Robert Pless, CS 546: Computational Geometry Lecture #3 Last time Several convex hull algorithms. Lower bound of O(n log n) –O(n log h) for output sensitive.
Convex Hulls Guo Qi, Chen Zhenghai, Wang Guanhua, Shen Shiqi, Himeshi De Silva.
Convex Hull.
Algorithm design techniques Dr. M. Gavrilova
Convex Hull obstacle start end 11/21/2018 4:05 AM Convex Hull
Computational Geometry (35/33)
Geometry.
Convex Sets & Concave Sets
Computational Geometry for the Tablet PC
Convex Hull 1/1/ :28 AM Convex Hull obstacle start end.
Data Structures and Algorithms (AT70. 02) Comp. Sc. and Inf. Mgmt
CHAPTER 33 Computational Geometry
CMPS 3130/6130: Computational Geometry Spring 2017
Convex Hulls Given a set of points (x1,y1),(x2,y2),…,(xn,yn), the convex hull is the smallest convex polygon containing all the points.
CMPS 3120: Computational Geometry Spring 2013
Convex Hull obstacle start end 4/30/2019 5:21 PM Convex Hull
Computational Geometry Algorithms
Geometry.
Algorithms and Data Structures Lecture XIV
Presentation transcript:

ACM Schedule… 2/23 Geometry problems 3/2 Lab problems (geometry!) 3/30 "Mock" competition and lab session (4:15) 3/9 Final algorithm discussion… 3/16 [Spring break] 3/23 [Extended programming practicum break]

Current Jotto standings… SophsJrsSrsProfs Chalk 1Chalk 0Chalk 1 Quine 1 Quine 2 aught 2aught 1 aught 2 jotto 2 jotto 0jotto 1 ?? 2 ?? 0?? 1

Last time: the Muddy Problem Input Output 4 *.*..*** ***...*. # of rows and columns The environment * 4 The smallest number of boards needed to cover all the muddy patches! represents a muddy patch. represents a grassy patch

Turning direction Python code for CCW turning def turningDirection( pt1, pt2, pt3 ): """ returns 1 if pt1 -> pt2 -> pt3 is a turn returns -1 if pt1 -> pt2 -> pt3 is a turn returns 0 if they are collinear """ x1, y1 = pt1; x2, y2 = pt2; x3, y3 = pt3; # the signed magnitude of the cross product CP = (x2-x1)*(y3-y1)-(y2-y1)*(x3-x1) if CP > 0: return 1 if CP < 0: return -1 return 0 Bertrand Planes' Life Clock (10,10) (20,20) (15,30) 3' (40,20)

Geometric algorithms Line Segment intersection… (x1,y1) (x2,y2) (xB,yB) (xA,yA) rsrs xA - x1 yA - y1 dx1 dxA dy1 dyA = (xi,yi) All points on this line are (x1,y1) + r(x2-x1,y2-y1) (xA,yA) + s(xB-xA,yB-yA) All points on this line are dx1dy1 dxAdyA Solving these equations finds the intersection via r and s.

Geometric algorithms Line Segment intersection… pt1 = (10, 10) pt2 = (20,20) pt3 = (10, 20) pt4 = (20, 10) pt5 = (40, 20) Line segment #1 runs from (10, 10) to (20, 20) Line segment #2 runs from (10, 20) to (20, 10) Intersection result = (15.0, 15.0, 1, 0.5, 0.5) Line segment #1 runs from (10, 10) to (10, 20) Line segment #2 runs from (20, 20) to (20, 10) Intersection result = (0, 0, 0, 0, 0) Line segment #1 runs from (10, 10) to (20, 20) Line segment #2 runs from (20, 10) to (40, 20) Intersection result = (0.0, 0.0, 1, -1.0, -1.0)

Geometric algorithms Java has its advantages! Line2d.linesIntersect(x1, y1, x2, y2, x3, y3, x4, y4); Polygon().contains(x,y); Line2D Polygon

This week's Problems… read over these problems… rank them in "difficulty" order what geometric computation is needed?

The EE Problem Input Output # of test cases Data Set 1: The strength of the signal at each test location == 1.0/(closest visible router ** 2) # of room vertices, # of routers, # of test points vertices of the room Locations of the routers test locations routers example input Locations of the test points A B C C A B

The IE Problem Input Output # of test cases Data Set 1: 2.32 The minimum total cost to supply all stores from some warehouse(s). # of stores and possible warehouse locations (x,y) location of stores (x,y,price) location of warehouses and their cost to build in Mega$ S S S S W W WW $.3 $.5 $.8 delivery cost = Euclidean distance Industrial Engineering

The Superpaint Problem Input Output one side of the square lattice Locations of the cows (row,col) 5 The number of locations that "attack" all occupied squares with a Queen's move Row 1.. C... C... number of occupied squares Row 2 Row 3 Row 4 Col 1 Col 2 Col 3 Col 4 Row 1.. B.. B.. B. Row 2 Row 3 Row 4 Col 1 Col 2 Col 3 Col 4

The Safepens Problem Input Output Number of rectangular fences The fences! (lower left and upper right vertices) 3 1 The deepest nesting level The number of pens at that level (1,1) (16,16) (6,6) (11,13) (7,7) (9,12) (3,3) (10,5)

"Sweepline algorithm"

A B C D Priority Queue Binary Search Tree

The Screens Problem Input Output # of test cases Vertices of the room Data Set 1: 90.00% The total fraction of the presentation you can observe (all screens' contributions!) # of projector screens # of room vertices (x,y) location of "you" Line segments of the screens room oriented screens

Current Jotto standings… SophsJrsSrsProfs Chalk 1Chalk 0Chalk 1 Quine 1 Quine 2 aught 2aught 1 aught 2 jotto 2 jotto 0jotto 1 ?? 2 ?? 0?? 1

Current Jotto standings… SophsJrsSrsOthers icily 0 icily 1 strep 2 strep 1 spork 1spork 3spork 0 spend 2 peeps 2peeps 1peeps 2peeps 1 furls 1 furls 0furls 1 Ghost 2Ghost 1 Ghost 0 Tanks 2Tanks 1Tanks 2Tanks 1 Gecko 2Gecko 1

Convex Hull the segments surrounding the exterior of a point set. First approach: brute force?

The Graham Scan "first algorithm in computational geometry" 1) Find extremal point, P[0] 2) Sort all other points in terms of their angles with P[0] - use atan2 ! 3) the sorted list is P[i] 4) push P[0] and P[1] onto S a stack (e.g., python list) i = 2 while i < N: A = the top of stack S B = the second point on S if (P[i] is to the left of B to A): push P[i] onto stack S i = i+1 else: pop stack S and discard the top 5) run the scan:

Graham Scan: java Stack grahamScan(Coordinate[] c) { Point p; Stack ps = new Stack(); ps.push(c[0]); ps.push(c[1]); ps.push(c[2]); for (int i = 3; i < c.length; i++) { p = ps.pop(); while (computeOrientation(ps.peek(), p, c[i]) > 0)) { ps.pop(); } ps.push(p); ps.push(c[i]); } ps.push(c[0]); return ps; }

Convex Hull #2 convex hull Jarvis’s March - shown here Graham’s Scan - see previous

Jarvis March convex hull start here draw a line to this point (why?) Jarvis’s March - shown here Graham’s Scan - see previous

Jarvis March convex hull start here draw a line to this point draw a line to the point with the LEAST relative angle (  )  Jarvis’s March - shown here Graham’s Scan - see previous

Jarvis March convex hull start here draw a line to the point with the LEAST relative angle (  ) Jarvis’s March - shown here Graham’s Scan - see previous

Jarvis March convex hull draw a line to the point with the LEAST relative angle (  ) but bigger than the previous angle!  Jarvis’s March - shown here Graham’s Scan - see previous

Jarvis March convex hull continue until you return… Jarvis’s March - shown here Graham’s Scan - see previous

"QuickHull"

choose L and R pts draw chord

"QuickHull" choose L and R pts draw chord assign sides find farthest point on each side create triangle recurse!

"QuickHull" choose L and R pts draw chord assign sides find farthest point on each side create triangle recurse! assign sides

Java's Polygon class contains constructors intersects (a rect) getBounds (get a bbox) uses the WIND_EVEN_ODD rule

The Sweepline Algorithm choose L and R pts draw chord assign sides find farthest point on each side create triangle recurse! assign sides

The Safepens Problem Input Output Number of rectangular fences The fences! (lower left and upper right vertices) 3 1 The deepest nesting level The number of pens at that level (1,1) (16,16) (6,6) (11,13) (7,7) (9,12) (3,3) (10,5)

The Superpaint Problem Input Output one side of the square lattice Locations of the cows (row,col) 5 The number of locations that "attack" all occupied squares with a Queen's move Row 1.. C... C... number of occupied squares Row 2 Row 3 Row 4 Col 1 Col 2 Col 3 Col 4 Row 1.. B.. B.. B. Row 2 Row 3 Row 4 Col 1 Col 2 Col 3 Col 4

The Screens Problem Input Output # of test cases Vertices of the room Data Set 1: 90.00% The total fraction of the presentation you can observe (all screens' contributions!) # of projector screens # of room vertices (x,y) location of "you" Line segments of the screens room oriented screens

The EE Problem Input Output # of test cases Data Set 1: The strength of the signal at each test location == 1.0/(closest visible router ** 2) # of room vertices, # of routers, # of test points vertices of the room Locations of the routers test locations routers example input Locations of the test points A B C C A B

The IE Problem Input Output # of test cases Data Set 1: 2.32 The minimum total cost to supply all stores from some warehouse(s). # of stores and possible warehouse locations (x,y) location of stores (x,y,price) location of warehouses and their cost to build in Mega$ S S S S W W WW $.3 $.5 $.8 delivery cost = Euclidean distance Industrial Engineering

Convex Hull Problems… read over these problems… which ones are convex hull? which ones could be convex hull? and the rest?

Current Jotto standings… SophsJrsSrsOthers icily 0 icily 1 strep 2 strep 1 spork 1spork 3spork 0 spend 2 peeps 2peeps 1peeps 2peeps 1 furls 1 furls 0furls 1 Ghost 2Ghost 1 Ghost 0 Tanks 2Tanks 1Tanks 2Tanks 1 Gecko 2Gecko 1 Win! Quine 5

What are these? public int mystery1(Point A, Point B, Point P) { int cp1 = (B.x-A.x)*(P.y-A.y) - (B.y-A.y)*(P.x-A.x); if (cp1>0) return 1; else return -1; } public int mystery2(Point A, Point B, Point C) { int ABx = B.x-A.x; int ABy = B.y-A.y; int num = ABx*(A.y-C.y)-ABy*(A.x-C.x); if (num < 0) num = -num; return num; }

What are these? public int mystery1(Point A, Point B, Point P) { int cp1 = (B.x-A.x)*(P.y-A.y) - (B.y-A.y)*(P.x-A.x); if (cp1>0) return 1; else return -1; } public int mystery2(Point A, Point B, Point C) { int ABx = B.x-A.x; int ABy = B.y-A.y; int num = ABx*(A.y-C.y)-ABy*(A.x-C.x); if (num < 0) num = -num; return num; } Hints: sortOfDistance whichSide