Computational Geometry

Slides:



Advertisements
Similar presentations
Geometry Introduction
Advertisements

Polygon Triangulation
Computational Geometry
CMPE 466 COMPUTER GRAPHICS
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.
Computing Convex Hulls CLRS 33.3
Convex Hull obstacle start end Convex Hull Convex Hull
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.
I. The Problem of Molding Does a given object have a mold from which it can be removed? object not removable mold 1 object removable Assumptions The object.
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.
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
Convex Hull Problem Presented By Erion Lin. Outline Convex Hull Problem Voronoi Diagram Fermat Point.
Computational Geometry for the Tablet PC
THE WORLD OF POLYGONS LESSON 4.
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.
Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 51 Today’s class Geometric objects and transformations.
5/17/2015 1:32 AMConvex Hull1 obstacle start end.

Convex Hulls Computational Geometry, WS 2006/07 Lecture 2 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik Fakultät für.
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2004 O’Rourke Chapter 7 Search & Intersection.
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
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2004 Chapter 4: 3D Convex Hulls Monday, 2/23/04.
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2001 Lecture 2 Chapter 2: Polygon Partitioning.
Lection 1: Introduction Computational Geometry Prof.Dr.Th.Ottmann 1 History: Proof-based, algorithmic, axiomatic geometry, computational geometry today.
Geometric Algorithms1 segment intersection orientation point inclusion simple closed path.
Advanced Algorithm Design and Analysis (Lecture 9) SW5 fall 2004 Simonas Šaltenis E1-215b
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.
Introduction to 3D Graphics Lecture 4: Scenes and Scene Graphs Anthony Steed University College London.
Basics of Rendering Pipeline Based Rendering –Objects in the scene are rendered in a sequence of steps that form the Rendering Pipeline. Ray-Tracing –A.
1 Ray Tracing Polyhedra ©Anthony Steed
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.
Collision handling: detection and response
UNC Chapel Hill M. C. Lin Linear Programming Reading: Chapter 4 of the Textbook Driving Applications –Casting/Metal Molding –Collision Detection Randomized.
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.
L4-Vector Algorithms L4 – Vector Algorithms NGEN06(TEK230) – Algorithms in Geographical Information Systems Abdulghani Hasan.
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.
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 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.
Simplex “walk on the vertices of the feasible region” v = current vertex if  neighbor v’ of v with better objective then move to v’
Convex Hulls Guo Qi, Chen Zhenghai, Wang Guanhua, Shen Shiqi, Himeshi De Silva.
Computer Graphics CC416 Week 14 Filling Algorithms.
Polygon Triangulation
Introduction to Spatial Computing CSE 555
Stroke Geometry CSE 490ra.
Convex Hull.
Grids Geometry Computational Geometry
Grids Geometry Computational Geometry
Convex Hull obstacle start end 11/21/2018 4:05 AM Convex Hull
Grids Geometry Computational Geometry
Polygon Triangulation
Geometry.
Convex Sets & Concave Sets
Computational Geometry for the Tablet PC
I. The Problem of Molding
Convex Hull 1/1/ :28 AM Convex Hull obstacle start end.
Ray Tracing Polyhedra ©Anthony Steed
CHAPTER 33 Computational Geometry
CMPS 3130/6130: Computational Geometry Spring 2017
Convex Hull obstacle start end 4/30/2019 5:21 PM Convex Hull
Computational Geometry Algorithms
Geometry.
Computational Geometry
Presentation transcript:

Computational Geometry Some useful algorithms/formulas for solving geometric problems

Overview Representation Basic geometric problems Other issues

Representation Points Segments Lines Polygon (x, y) Cartesian coordinates (r, Θ) Polar coordinates Segments Position of the end points Lines 2-tuple (m, c) using y = mx + c 3-tuple (a, b, c) using ax + by = c Two points P0, P1 on the line using P(t) = (1-t)P0 + t P1 Polygon Ordered list of points

Basic geometric problems Area of polygon CCW Line segment intersection Distance between a point and a line Closest point Angle between two lines Point in a polygon Convex hull

Area of polygon Given a simple polygon, find its area. Area = 1/2 * [(x1.y2 + x2.y3 +…+ xn.y1) - (y1.x2 + y2.x3 + … + yn, x1)] (x2, y2) … (x1, y1) (xn, yn)

CCW Basic geometric primitive Returns 1 if the points are ccw Returns -1 if the points are cw Returns 0 if the points are collinear Area given in the previous slide is positive when the points are listed in counter-clockwise direction and negative otherwise 3 2 1 ccw(p1, p2, p3) returns 1

Line segment intersection (I) Given two line segments l1 and l2, determine if they intersect ? isIntersect = ccw(l1.p1, l1.p2, l2.p1) * ccw(l1.p1, l1.p2, l2.p2) <= 0 && ccw(l2.p1, l2.p2, l1.p1) * ccw(l2.p1, l2.p2, l1.p2) <= 0 l1.p2 l2.p1 l2.p2 l1.p1

Distance between a point and a line Given a point and a line, determine the shortest distance between them. Select two points A, B on the line ½ * AB * h = area of triangle ABP P h B A

Closest point (I) Given a line L and a point P, find the point on L closest to P Recall that if u is a unit vector and v is any vector. The projection of v on u is given by (u.v)u u.v is the number k which minimized |v – ku|

Closest point (II) The theorem in the previous slide can only be applied to lines which pass through the origin This is sufficient to compute the general case as we can apply a translation if the line does not pass through the origin

Angle between two lines Represent lines as vectors u (a, b) and v (c, d) Definition of dot product: u.v = |u||v|cos Θ = ac + bd |u| = sqrt(u.u) Θ = cos-1(u.v / |u||v|) u Θ v

Point in a polygon (I) Given a point and a closed polygon, determine whether the point lies inside the polygon. Most algorithms extends a ray from the given point and considers the interaction of the polygon with the ray Such algorithms needs to handle the following boundary cases:

Point in a polygon (II) A standard way to resolve this issue is to adopt the following set of rules Edge crossing rules an upward edge includes its starting endpoint and excludes its endpoint a downward edge excludes its starting endpoint and includes its endpoint horizontal edges are excluded the edge-ray intersection point must be strictly right of the point P

Point in a polygon (III) One of the simplest algorithm is to compute the winding number of the point

Point in a polygon (IV) Winding number Point is outside iff WN = 0 number of times the polygon winds around the point Point is outside iff WN = 0 Upward edges => WN++ Downward edges => WN--

Point in a polygon (V) //      Input:   P = a point, //               V[] = vertex points of a polygon with V[n]=V[0] //      Return: wn = the winding number (=0 only if P is outside V[]) int wn_PointInPoly(Point P, Point* V, int n) {     int wn = 0;    // the winding number counter     // loop through all edges of the polygon     for (int i=0; i<n; i++) {   // edge from V[i] to V[i+1]         if (V[i].y <= P.y) {         // start y <= P.y             if (V[i+1].y > P.y)      // an upward crossing                 if (ccw( V[i], V[i+1], P) > 0)  // P left of edge                     ++wn;            // have a valid up intersect         }         else { // V[i].y > P.y             if (V[i+1].y <= P.y)     // a downward crossing                 if (ccw( V[i], V[i+1], P) < 0)  // P right of edge                     --wn;            // have a valid down intersect         }     }     return wn; }

Convex hull (I) Given a set of points, determine the smallest convex set containing all the points A set S is convex if whenever two points P and Q are inside S, then the whole line segment PQ is also in S

Convex hull (II) One simple algorithm is Graham Scan, often cited as the first computational geometry algorithm Pseudocode Select the lowest leftmost point P[0] in S Sort the rest of the points in S according to the angle made with P[0], break ties base on distance to P[0] Let P[0..n-1] be the sorted array of points Create an empty stack ST ST.push(P[n-1]) //P[n-1] must be on the hull ST.push(P[0]) //P[0] must be on the hull For i from 2 to n – 1 Let PT1 denote the topmost point on ST Let PT2 denote the second topmost point on ST while (ccw(PT2, PT1, P[i]) <= 0) ST.pop() ST.push(P[i])

Other issues Case analysis Use of floating point numbers Overflow

References http://softsurfer.com/, Dan Sunday Algorithms, Robert Sedgewick Programming Challenges, Skiena and Revilla