Computational Geometry for the Tablet PC

Slides:



Advertisements
Similar presentations
Introduction to Algorithms
Advertisements

Geometry Introduction
Computational Geometry
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.
2/9/06CS 3343 Analysis of Algorithms1 Convex Hull  Given a set of pins on a pinboard  And a rubber band around them  How does the rubber band look when.
Polygon overlay in double precision arithmetic One example of why robust geometric code is hard to write Jack Snoeyink & Andrea Mantler Computer Science,
1/13/15CMPS 3130/6130: Computational Geometry1 CMPS 3130/6130: Computational Geometry Spring 2015 Convex Hulls Carola Wenk.
Brute-Force Triangulation
Computing Convex Hulls CLRS 33.3
Convex Hull obstacle start end Convex Hull Convex Hull
CS16: Introduction to Data Structures & Algorithms
What is Computational Geometry? Study of Data Structures and Algorithms for Geometric Problems 1970 ’ s: Need for Computational Geometry Recognized; Progress.
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.
Convex Hulls in Two Dimensions Definitions Basic algorithms Gift Wrapping (algorithm of Jarvis ) Graham scan Divide and conquer Convex Hull for line intersections.
Convex Hulls May Shmuel Wimer Bar Ilan Univ., Eng. Faculty Technion, EE Faculty.
Advanced Topics in Algorithms and Data Structures Lecture 7.1, page 1 An overview of lecture 7 An optimal parallel algorithm for the 2D convex hull problem,
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.
Computational Geometry
Advanced Algorithm Design and Analysis (Lecture 10) SW5 fall 2004 Simonas Šaltenis E1-215b
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.
ADA: 16. CG Topics1 Objective o an examination of four important CG topics o just a taster of a very large research area Algorithm Design and Analysis.
Intersections. Intersection Problem 3 Intersection Detection: Given two geometric objects, do they intersect? Intersection detection (test) is frequently.
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.
Query Processing in Databases Dr. M. Gavrilova.  Introduction  I/O algorithms for large databases  Complex geometric operations in graphical querying.
Classroom Presenter Crystal Hoyer Craig Prince Jonathan Su Richard Anderson.
Computational Geometry Overview from Cormen, et al. Chapter 33
Brute-Force Triangulation
Computational Geometry
Advanced Algorithm Design and Analysis (Lecture 9) SW5 fall 2004 Simonas Šaltenis E1-215b
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.
CSE53111 Computational Geometry TOPICS q Preliminaries q Point in a Polygon q Polygon Construction q Convex Hulls Further Reading.
Computational Geometry Convex Hulls Robust Geometric Primitives Degeneracy and Stability Nick Pilkington.
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.
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.
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.
Convex Hulls Guo Qi, Chen Zhenghai, Wang Guanhua, Shen Shiqi, Himeshi De Silva.
Data Structure & Algorithm 13 – Computational Geometry JJCAO.
Introduction to Spatial Computing CSE 555
Stroke Geometry CSE 490ra.
Convex Hull.
Query Processing in Databases Dr. M. Gavrilova
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.
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
Computational Geometry
Presentation transcript:

Computational Geometry for the Tablet PC CSE 490ra

Overview Computational Geometry on the Tablet PC Geometric primitives SUB: Ask for submission of a picture Computational Geometry on the Tablet PC Geometric primitives Intersections Polygons Convexity

Tablet Geometry Basic structure – Stroke: sequence of points SUB: What is Points[6.4]? Basic structure – Stroke: sequence of points Himetric coordinates Sampled 150 times per second Coordinates stored in an array Points

Computational Geometry Algorithms for geometric computation Numerical issues with coordinates Importance of degenerate cases Examples of degenerate cases Three lines intersecting at a point Segments overlapping Three points co-linear

Basic geometry Point Line segment Distance Basic Test p (p1, p2) Dist(p1, p2) Basic Test LeftOf(p1, p2, p3) CCW(p1, p2, p3) p p1 p3 p2 p1

Distance computation Avoid computing square root when possible Example: find closest point to q closestSoFar = p1; d = Dist(p1, q); for k = 2 to n { d1 = Dist(pk, q) if (d1 < d){ closestSoFar = pk; d = d1; }

Counter Clockwise Test CCW(p1, p2, p3) public static bool CcwTest(Point p1, Point p2, Point p3){ int q1 = (p1.Y - p2.Y)*(p3.X - p1.X); int q2 = (p2.X - p1.X)*(p3.Y - p1.Y); return q1 + q2 < 0; } ASIDE: Give derivation based on the determinant

Segment intersection Find intersection of (p1,p2) and (p3,p4) Q = ap1 + (1-a)p2 Q = bp3 + (1-b)p4 Solve for a, b Two equations, two unknowns Intersect if 0 < a < 1 and 0 < b < 1 Derived points In general, try to avoid computing derived points in geometric algorithms

Problem SUB Tell students segments are not co-linear Determine if two line segments (p1, p2) and (p3,p4) intersect just using CCW Tests

Making intersection test more efficient Take care of easy cases using coordinate comparisons Only use CCW tests if bounding boxes intersect

Computing intersections SUB Ignore degenerate cases Given k strokes, find all intersections Given a stroke, find self intersections Break into segments, and find all pairwise intersections How many self intersections can a single stroke with n points have?

Segment intersection algorithm Run time O(nlog n + Klog n) for finding K intersections Sweepline Algorithm 3 6 5 1 2 7 4

Sweepline Algorithm Event queue Move sweepline to next event Start Segment (S2) End Segment (E2) Intersection (I2,4) Move sweepline to next event Maintain vertical order of segments as line sweeps across Start Segment Insert in list Check above and below for intersection End Segment Remove from list Check newly adjacent segments for intersection Intersection Reorder segments

Sweepline example 3 6 5 1 2 7 4

Activity: Identify when each of the intersections is detected B

Polygons Sequence of points representing a closed path Simple polygon – closed path with no self intersections

Polygon inclusion test Is the point q inside the Polygon P?

Convexity Defn: Set S is convex if whenever p1, and p2 are in S, the segment (p1, p2) is contained in S

Convex polygons P = {p0, p1, . . . pn-1} P is convex if CCW(pi, pi+1, pi+2) for all I Interpret subscripts mod n Also holds for CW (depending on how points are ordered)

Problem: Test if a point is inside a convex polygon using CCW Tests SUB: Describe an algorithm using CCW Tests

Convex hull Smallest enclosing convex figure Rubber band “algorithm”

Compute the Convex Hull SUB: Students draw the hull Compute the Convex Hull

Algorithms Convex hull algorithms: O(nlog n) Insertion algorithm Illustrate insertion with diagram on right Algorithms Convex hull algorithms: O(nlog n) Related to sorting Insertion algorithm Gift Wrapping (Jarvis’s march) Divide and Conquer Graham Scan

Convex Hull Algorithms Gift wrapping

Divide and Conquer

Graham Scan Polar sort the points around a point inside the hull Scan points in CCW order Discard any point that causes a CW turn If CCW advance If !CCW, discard current point and back up

Polar sort the red points around q (Start with p, CCW order) SUB: Students draw the hull Polar sort the red points around q (Start with p, CCW order) p q SUB: Use the result for a first illustration of the algorithm

Graham Scan Algorithm Stack of vertices If CCW(x, y, z) Possible hull vertices z – next vertex y – top of stack x – next on stack If CCW(x, y, z) Push(x) If (! CCW(x, y, z)) Pop stack x y z x z y

GS Example to walk through

Student submission: Give order vertices are discard in the scan p

Application of Convex Hull Construct a Convex Hull Selection Lasoo Maintain convex hull of pen stroke for selection Operations on packet event in RTS New packet is outside of the hull Update the hull Packet is inside the hull Computation to make it more efficient when pen leaves the hull

New Packet outside the hull SUB: Describe what to do New Packet outside the hull

New Packet inside the hull SUB: Give ideas what to do – emphasize that I don’t have an answer in mind SUB: Describe what to do New Packet inside the hull