Dokumen - Tips - Computational Geometry Csci3250
Dokumen - Tips - Computational Geometry Csci3250
csci3250
Laura Toma
Bowdoin College
Today
• Introduction
• Warmup
• finding collinear points
• finding closest pair of points
Introduction
points
Introduction
polygons
Introduction
polygons
Introduction
polygons
Introduction
polygons
Introduction
2D, 3D..
Introduction
2D, 3D..
Computational geometry
• Questions
• Come up with an algorithm to e.g. find the convex hull of a set of
points
• What is the complexity of the convex hull of a set of n points n the
plane?
• What is the worst-case running time (tight bound) for an
algorithm?
• Can we do better? What is a lower bound for the problem?
• Is the algorithm practical? Can we speed it up by exploiting
special cases of data (that arise in practice)?
• …
Applications
• Computer graphics
• find what objects intersect others for rendering
• hidden surface removal
• lighting
Applications
• Robotics
• path planning involves finding paths that avoid obstacles; this
involves finding intersections
• does this route intersect this obstacle?
Applications
• Computational geosciences
• geographical data has coordinates (geometry)
• overlay county maps with vegetation types
• meshes of triangles are used to model surfaces
Applications
• Convex hull
Class overview
• Convex hull
• comes up in a lot of applications
• objects are approximated by their CH shape
Class overview
• Intersections
• orthogonal line segment intersection
Class overview
• Intersections
• general line segment intersection
Class overview
• Intersections
• general line segment intersection
Class overview
• Visibility
• art gallery problem
• Visibility
• art gallery problem
• Range searching
• fundamental problem
• searching in 2D
Class overview
• Range searching
• fundamental problem
• searching in 2D
• Range searching
• fundamental problem
• searching in 2D
• Range searching
• range tree
• kd-tree
Class overview
• Proximity problems
• Voronoi diagram
• applications: nearest neighbor
Class overview
• Proximity problems
• Voronoi diagram
• Delaunay triangulations
DT Applications
Class overview
• Motion planning
• robots moving among obstacles, find (shortest) paths
Logistics
• Work
• in-class group work
• programming assignments
• no exams
Today: warmup
Brute force:
• for all distinct triplets of points pi, pj, pk
• check if they are collinear
• Analysis:
• n chose 3 = O(n3) triplets
• checking if three points are collinear can be done in constant time
==> O(n3) algorithm
Finding collinear points
Improved idea 1:
• initialize array L = empty
• for all distinct pairs of points pi, pj
• compute their line equation (slope, intercept) and store in an array L
• sort array L //note: primarily by slope, secondarily by intercept
• //invariant: identical lines will be consecutive in the sorted array
• scan array L, if find any identical lines ==> there exist 3 collinear points
• Analysis:
• n chose 2 = O(n2) pairs
• time: O(n2 lg n)
• space: O(n2)
Finding collinear points
Improved idea 2:
• initialize BBST = empty
• for all distinct pairs of points pi, pj
• compute their line equation (slope, intercept)
• insert (slope, intercept) in BBST; if when inserting you find that (slope,
intercept) is already in the tree, you got 3 collinear points
Note: for this to work, you need to make sure that the key for the BBST is both the
slope and the intercept
• Analysis:
• n chose 2 = O(n2) pairs
• time: O(n2 lg n)
• space: O(n2)
Finding collinear points
Can you find a solution that runs in O(n2 lg n) time with only linear
space?
Finding collinear points
Improved idea 4:
• initialize HT = empty
• for all distinct pairs of points pi, pj
• compute their line equation (slope, intercept)
• check HT to see if already there => if yes, you got 3 collinear
points