Geometric Algorithms Suman Sourav Paramasiven Appavoo Anuja
Meetoo Appavoo Li Jing Lu Bingxin Suhendry Effendy Dumitrel
Loghin
Slide 2
Introduction & Motivation Suman Sourav
Slide 3
Introduction Computational geometry is a branch of computer
science devoted to the study of algorithms which can be stated in
terms of geometry. Deep connections with classical mathematics and
theoretical computer science on the one hand, and many ties with
applications on the other. Focus is on discrete nature of geometric
problems as opposed to continuous issues.
Slide 4
Introduction Any problem that is to be solved using a digital
computer has to be discrete in form. For CG techniques to be
applied to areas that involves continuous issues, discrete
approximations to continuous curves or surfaces are needed. People
deal more with straight or flat objects or simple curved objects,
than with high degree algebraic curves.
Slide 5
Introduction Programming in CG is a little difficult. Libraries
like LEDA and CGAL implement various data structures and geometric
algorithms. CG algorithms suffer from the curse of degeneracies.
So, certain simplifying assumptions at times like no three points
are collinear, no four points are cocircular, etc are needed to be
made.
Slide 6
Motivation & Application There are many areas that give
rise to geometric problems. Computer graphics Computer vision and
image processing Robotics Computer-aided designing (CAD) Geographic
information systems (GIS) Telecommunication VLSI design (chip
layout)
Slide 7
Example To find the nearest phone booth on campus
Slide 8
Example The motion planning problem
Slide 9
Example To build a model of the terrain surface, we can start
with a number of sample points where we know the height.
Slide 10
How do we interpolate the height at other points? Nearest
neighbor interpolation Piecewise linear interpolation by a
triangulation Moving windows interpolation Natural neighbor
interpolation
Slide 11
For interpolation, it is good if triangles are not long and
skinny.
Slide 12
Example Each time you click inside the editing area of a
diagram or inside a web page, the application must know inside
which object the mouse pointer is. Given the high frequency of such
a query, a fast algorithm must be used.
Slide 13
Facility location Given a set of houses and farms in an
isolated area. Can we place a helicopter ambulance post so that
each house and farm can be reached within 15 minutes? Where should
we place an antenna so that a number of locations have maximum
Reception?
Slide 14
Art gallery problem How many cameras are needed to guard a
given art gallery so that every point is seen?
Slide 15
A Real Life Application
Slide 16
Voronoi Voronoi diagram - Properties - Construction methods
Fortunes Algorithm - How does it work? - Implementation aspects -
Data structures - Pseudocode - Complexity (time & space)
Paramasiven Appavoo & Anuja Meetoo Appavoo
Slide 17
Voronoi edges: Each point on an edge of the Voronoi diagram is
equidistant from its two nearest neighbors p i and p j. Voronoi
vertices: It is the center of the circle passing through these
sites, and this circle contains no other sites in its interior.
Degree: If we assume that no four points are cocircular, then the
vertices of the Voronoi diagram all have degree three. Voronoi
diagram Properties
Slide 18
Convex hull: A cell of the Voronoi diagram is unbounded if and
only if the corresponding site lies on the convex hull. Size: If n
denotes the number of sites, then the Voronoi diagram is a planar
graph (if we imagine all the unbounded edges as going to a common
vertex infinity) with exactly n faces. Voronoi diagram
Properties
Slide 19
Voronoi Construction methods Perpendicular bisector Divide and
conquer Fortunes algo
Slide 20
Voronoi Fortunes algo Time complexity of perpendicular bisector
Extra computation at the merge of divide and conquer Steven Fortune
developed a plane sweep algorithm called the fortunes algorithm
that uses: o a sweep line, o a beach line, o site event, and o
circle event to generate the diagrams Steven Fortune, Bell
Laboratories
Slide 21
Fortunes Algo
Slide 22
Fortunes algo - Concepts Sweep line The idea behind algorithms
of this type is to imagine that a line is swept or moved across the
plane, stopping at some points. A sweep line splits the problem
domain into two regions, an explored region and an unexplored
region Operations are restricted to objects that are either
intersecting or are in the immediate vicinity of the sweep line
whenever it stops The complete solution is available once the line
has passed over all objects. It also applies an ordering to the
problem
Slide 23
Fortunes algo - Concepts Site events A site event happens when
the sweep line hits a site Property of the line perpendicular to
the sweep line at the site event o All points are equidistant to:
The site The closest point on the sweep line (the site itself, at
this stage) site event What happens when the sweep line moves
further away?
Slide 24
Fortunes algo - Concepts What happens The set of points that
are equidistant to both the site and the closest point on the sweep
line degenerate from a line to form a parabola... The parabola
defines the set of points... Set of points that belong to this
sites voronoi cell Important property implying that the cross
section of such parabolas, from a number of sites will define the
edges of a voronoi cell.. Why are we doing this?
Slide 25
Fortunes algo - Concepts 2 sites - Crossing parabolas p 1 and p
2 are two sites At the site event of p 2, point q is equidistant
from p 1 and p 2 As the sweep line goes down, the intersection of
the parabolas, breakpoints, are the endpoints for a partial edge...
P1P1 P2P2 P1P1 P 2 site event q P1P1 breakpoints part of voronoi
diagrams edge
Slide 26
Fortunes algo - Concepts More sites & beach line This
dividing line is termed the beach line The algorithm for computing
the Voronoi diagram of a set of points depends entirely on how this
beach line changes as the sweep moves through the space. The beach
lines topology changes when a new arc is added or another is
absorbed. breakpoints parts of the edges of the voronoi diagrams...
What is the stopping condition for an edges growth?
Slide 27
One endpoint is formed with a circle event o a vertex in the
voronoi diagram. Each relating site is equidistant from the vertex.
Vertex is the centre of a circle on which the three points lie
Either by cross sections of parabolas or simply by using the
intersection of each or the perpendicular bisector of the inner
triangle Fortunes algo - Concepts Circle event... vertex circle
event
Slide 28
Fortunes algo - Concepts From the vertex... vertex q If a
circumcircle is empty in its interior then, in a Voronoi diagram:
a, b, c would be Voronoi sites q would be a Voronoi vertex The
perpendicular bisectors of abc would be Voronoi edges. a b c Now
from the vertex...
Slide 29
Fortunes algo Implementation Aspects... Parabolas defining
beach line not computed as sweep line moves through the problem
space o Computationally expensive and unnecessary o Calculations
required only when the beach line changes topology Site events
Circle events Sweep line makes discrete steps, rather than a
continuous sweep
Slide 30
Fortunes algo Data Structures Priority queue o State of sweep
line o Indicates when topology of beach line can change Site events
Circle events Doubly connected edge list (DCEL) o State of Voronoi
diagram o Stores Vertex records Edge records Face records Balanced
binary search tree ( AVL or red-black tree) o State of beach
line
Slide 31
Fortunes algo Priority Queue of Events Priority based on their
y-coordinates Site events are represented by their coordinates
Circle events o Computed on the fly o Represented by coordinates of
lowest point of empty circle touching 3 sites o Anticipated and may
be false s1 (x1, y1) s2 (x2, y2) s3 (x3, y3) s5 (x5, y5) s4 (x4,
y4) c1 (x, y) circle event added to queue
Slide 32
Fortunes algo DCEL VertexCoordinatesIncident edge v1(x 1, y 1
)e12 v2(x 2, y 2 )e23... v8(x 8, y 8 )e87 Vertex records Half edge
Source vertex TwinIncident face Prev edge Next edge
e23v2e32s3e52e37..... Edge records FaceIncident edge s1e32 s2e56...
Face records
Slide 33
Fortunes algo Balanced Binary Search Tree Internal nodes o
Represent breakpoints between two arcs (tuple) o Contains pointer
to record of edge being traced Leaf nodes o Stores site defining
arc on beach line o Contains a pointer to a potential circle
event
Slide 34
Fortunes algo Pseudocode 1. Initialise data structures Event
queue, Q all site events Binary search tree, T DCEL, D 1.
while(queue not empty) 2. event = pop first event from queue 3.
process(event, T, D) 4. finish all edges in binary search tree How
to process site event? - Add the event and breakpoints to BST - Add
new edge in DCEL - Delete false alarms for circle events - Add
potential circle event(s) to queue How to process circle event? -
Update breakpoints and leaf in BST - Record new vertex - Delete
false alarms - Add possible circle event to queue
Slide 35
Fortunes algo Processing Site Event Locate existing arc (if
any) that is above the new site o x-coordinate of new site is used
for binary search o x-coordinate of each breakpoint along root to
leaf path is computed on the fly s5 s4 Q
Slide 36
Fortunes algo Processing Site Event Break the arc o Replace the
leaf node with a sub tree representing the new arc and its
breakpoints Different arcs can be identified by the same site!!! s4
Q
Slide 37
Fortunes algo Processing Site Event Add new edge record in DCEL
Create new face record with pointer to new edge New half-edge
record s4 Q
Slide 38
Fortunes algo Processing Site Event Check for potential circle
events o Scan for triple of consecutive arcs and determine if
breakpoints converge Potential circle event Add potential circle
event to to priority queue!!! Store a pointer to circle event in
leaf node for s1!!! c1 s4 Q
Slide 39
Fortunes algo Processing Site Event Converging breakpoints may
not always yield a circle event o Appearance of a new site before
the circle event makes the potential circle non-empty Original
circle event becomes a false alarm!
Slide 40
Fortunes algo Processing Circle Event Create new vertex record
Add vertex to corresponding edge record Delete disappearing arc s4
Q
Slide 41
Fortunes algo Processing Circle Event Delete disappearing arc
s4 Q
Slide 42
Fortunes algo Processing Circle Event s4 Q
Slide 43
Fortunes algo Processing Circle Event New edge being traced by
new breakpoint New half-edge record Create new edge record Check
new triple edges for potential circle events
Slide 44
Fortunes algo Algorithm Termination When Q is empty, beach line
and its breakpoints continue to trace edges o Terminate
half-infinite edges via a bounding box
Slide 45
Fortunes algo Complexity Locate leaf representing existing arc
above new site o Delete potential circle event from queue Break arc
by replacing leaf node with a sub tree representing new arc and
break points Add new edge and face records to DCEL Check for
potential circle event(s) o Add event to queue if they exist o
Store pointer to event in proper leaf Running Time O(log n) O(1)
Steps in handling site events O(1) O(log n)
Slide 46
Fortunes algo Complexity Delete disappearing BST leaf node and
its associated circle events from event queue Add vertex record in
DCEL Create new edge record in DCEL Check for potential circle
event(s) Running TimeSteps in handling circle events O(log n)
O(1)
Slide 47
Fortunes algo Complexity Time complexity for each event: O(log
n) How many events are there? o Number of site events + Number of
circle events o How many site events? n o How many circle events?
Each circle event corresponds to a vertex 2n - 5 (Eulers formula)
False alarms deleted before they are processed Total number of
events = 3n - 5 Overall running time: O(n log n) Storage
complexity: O(n)
Slide 48
Delaunay Triangulation Li Jing & Lu Bingxin Delaunay and
Voronoi Delaunay properties Randomized Algorithm - Idea -
Implementation aspects - Pseudocode - Data structure - Complexity
(time & space)
Slide 49
Delaunay and Voronoi An intuitive conception General position
assumption: no 4 points are co-circular (a) Voronoi diagram (b)
Delaunay triangulation
Slide 50
Delaunay and Voronoi Delaunay and Voronoi complexes are dual to
each other Dual correspondence Voronoi complexes Delaunay
triangulation cells (regions) vertices edges edges vertices
faces
Slide 51
Delaunay Triangulation (DT) Whats the difference?
Slide 52
Properties Circumcircle property The circumcircle of any
triangle in DT{S) is empty. (It contains no points of S in its
interior.) Proof By general position assumption, the degree of all
Voronoi vertex is 3, edge vu exists Consider S 4, S 1 S 4 is
perpendicular to l and divided half by l. S 4 is outside the circle
In fact, one definition of Delaunay Triangulation is: Delaunay
Triangulation is a triangulation that circumcircle of each triangle
is empty.
Slide 53
Properties Empty circle property Two points are connected by an
edge in the Delanuay triangulation. There is an empty circle
passing through these two points. Proof Trivial from the
circumcircle property. There are a series of circumcircles that
pass through S i and S j Note down the centres of these
circumcircles until they pass through another point The track is
the bound for both cell(S i ) and cell(S j ) S i S j is an edge in
the DT(S)
Slide 54
Locally Delaunay edge An edge ab is locally Delaunay if it
belongs to only one triangle, or it belongs to two triangles, abc
and abd, and d lies outside the circumcircle of abc. If an edge is
locally Delaunay,we also call it legal, otherwise illegal.
Slide 55
Delaunay Lemma If every edge in T s is locally Delaunay, then T
s is the Delaunay triangulation of S. Proof Let x be an arbitrary
point in abc Let abc= 0, A 1, A 2, A k be the sequence of triangles
that intersect xp Let d i (p) = |p a i | 2 r i 2 Because the edges
along xp are locally delaunay, d 0 (p)> d 1 (p)> > d k (p)
d k (p) = 0, so d 0 (p)>0
Slide 56
Edge Flipping Flip all edges in a triangulation until they are
all locally Delaunay edges
Slide 57
Randomized Incremental Algorithm Randomized the points as p 1,
p 2 , p n Find a sufficiently large triangle that contains P Insert
p 1, then p 2... and finally p n suppose we have computed DT(P i-1
) insert p i which splits a triangle into three perform edge flips
until no illegal edge remains we have just computed DT(P i ) Repeat
the process until i = n Discard the initial large triangle
Slide 58
First step Find a sufficiently large triangle that contains
P
Slide 59
First step
Slide 60
Slide 61
Example insert p
Slide 62
Example split abc into abp, bcp, and acp
Slide 63
Example check edges ab, bc, and ac
Slide 64
Example edge ab is illegal flip it
Slide 65
Example edge ab is flipped into pd edge ad and bd are to be
checked edge ad is legal, keep it
Slide 66
Example edge bd is illegal flip it
Slide 67
Example edge bd is flipped into pe edge ed and be are legal,
keep them
Slide 68
Example edge bc is illegal flip it
Slide 69
Example edge bc is flipped into fp edge bf and cf are legal,
keep them
Slide 70
Example edge ac is illegal flip it
Slide 71
Example edge ac is flipped into pg no more edge to flip: we are
done
Slide 72
Pseudocode Algorithm DelaunayTriangulation(P) Input: a suitably
shuffled (permuted uniformly at random) set of points P = (p 1, p
2, p 3,. , p n ) Output: DT(P) (* use a global DCEL to store DT(P)
*) 1. Find a sufficiently large triangle T(p -3 p -2 p -1 )
containing P 2. for i = 1 to n do 3. Insert(p i ) 4. Endfor 5.
Discard the triangle T(p -3 p -2 p -1 ) Algorithm Insert(p) Input:
a point p, a set of point P and T = DT(P) Output: DT(P u {p}) 1.
Find the triangle T(abc) of DT(P) containing p (* use conflict
lists *) 2. Insert edges pa,pb and pc (* update conflict lists *)
3. SwapTest(ab) 4. SwapTest(bc) 5. SwapTest(ca) Algorithm
SwapTest(ab) 1. if ab is an edge of the exterior face of DT(P) 2.
do return 3. d
Time to update triangulation Consider the i th step of the
algorithm P i : the set of the first i points (p 1, p 2, p 3,. , p
i ) in the whole point set P, i >3, or the set of points in DT(P
i ) Run the i th step backward (deleting a random point p in P i )
Note that each new edge added in DT(P i ) due to the insertion of p
is incident to p The total number of edge changes made in the
triangulation for the insertion of p is proportional to the degree
of p after the insertion is complete.
Slide 79
Time to update triangulation The total degree of the vertices
in P i is less than 6i There are at most 3i edges in DT(P i )
(planar graph) The sum of vertex degrees is twice the number of
edges in a graph The expected degree of a random point in P i is at
most 6 The expected number of edge changes for inserting a random
point p is O(1) Summing over all the n steps, the time for updating
the triangulation is O(n)
Slide 80
Update conflict lists Each non-inserted point is assigned to a
triangle/bucket For a non-inserted point, if the triangle which it
lies within is destroyed, we have to find another new triangle
containing this non-inserted point The expected time to update
conflict lists is the expected time to rebucket non-inserted points
is proportional to the expected number of non- inserted points
required to be rebucketed
Slide 81
Consider the i th step of the algorithm P i : the set of the
first i points (p 1, p 2, p 3, , p i ) in the whole point set P, i
>3, or the set of points in DT(P i ) P\P i : the set of
non-inserted points (p i+1, p i+2, p i+3, , p n ) Run the i th step
backward (deleting a random point in P i ) some triangles in DT(P i
) are destroyed some points in P\P i are required to be rebucketed
Rebucket points
Slide 82
Time to rebucket points Assume a random point p in P i is
deleted For a random point q in P\P i, suppose that q is bucketed
in the triangle T(abc) of DT(P i ) If p is one of the three
vertices of T(abc), T(abc) will be destroyed and q will be
rebucketed Pr (p is deleted) = 1/i Pr (T(abc) is destroyed) = 3/i
Pr (q needs to be rebucketed) = 3/i The expected number of points
in P\P i required to be rebucketed is 3(n-i)/i
Slide 83
Time to rebucket points Summing over all the n steps The total
expected number of non-inserted points required to be rebucketed is
O(nlogn) The expected time to update conflict lists is
O(nlogn)
Slide 84
Time complexity Major steps in the algorithm Running time o
Find a sufficiently large triangleO(1) o Find the triangle
containing a pointO(n) o Update the triangulationO(n) o Update
conflict lists O(nlogn)
Slide 85
Complexity Expected time complexity: O(nlogn) Expected space
complexity: O(n) DCEL, Conflict list
Defining the problem Given a set S of n segments in the plane,
with no two distinct end-points having the same x coordinate
(general position) These segments intersect in k points There is a
bounding rectangle R containing all n segments If we draw vertical
lines through each end-point or intersection point, till they
intersect a segment or R, we obtain a set of trapezoids T(S) which
is the trapezoidal decomposition of S
Slide 88
Example p1p1 p2p2 p3p3 q1q1 q2q2 q3q3 R k1k1 k2k2 k3k3
Slide 89
Details
Slide 90
Construction Example
Slide 91
Randomized Algorithm Start with a random permutation S = { s 1,
, s n }, with a bounding rectangle R and with T(S)= FOR i = 1 TO n
DO # add segment s i and update T(S) Get the trapezoid which
contains left end-point of s i and draw a vertical line. Move to
the right on the planar graph and get all the intersected
trapezoids: If the segment intersect the bottom or top segment of
the trapezoid, the point is one of the k intersection points,
hence, draw a vertical line. Draw a vertical line at the right
end-point. Rescan the intersected vertical lines and trim them
based on their starting point; merge the trapezoids which share the
deleted line.
Slide 92
Point Location Given a query point q, find in which trapezoid
it lies Data structure DAG internal nodes are end-points,
intersection points or segments leaves are trapezoids and they may
be shared (in-degree of a leaf may be more than one) Can be
constructed simultaneously with trapezoidal decomposition Algorithm
key idea: At step i, some of the leaves (trapezoids) become
internal nodes (end-points of the segment s i or intersection
points) and new trapezoids are added.
Complexity Analysis Assumption: points (end of segment) are in
general position = no two points lies in a same vertical line. =
all x-coordinate are different. Later we will see how to lift this
assumption.
Slide 96
Complexity Analysis What is the complexity of adding one
segment s? find the left end point of segment s. trace (and update)
all trapezoids intersected by s.
Slide 97
Adding 1 Segment
Slide 98
How to find this trapezoid?
Slide 99
Finding Trapezoid How to find trapezoid which contain the left
end-point of segment s? TrapezoidSegment T1T1 s 5, s 7,... T2T2 s
8,... T3T3 s 6, s 9, s 10,...... Segment Trapezoid s5s5 T1T1 s6s6
T3T3 s7s7 T1T1 s8s8 T2T2 s9s9 T3T3 s 10 T3T3 bi-directional pointer
couple of ways
Slide 100
Bi-directional pointer bi-directional pointer query find in
O(1) need to update the pointer for each changed trapezoid (only
update trapezoids which are intersected by new segment s).
Slide 101
Adding 1 Segment
Slide 102
Slide 103
Slide 104
Complexity Analysis For each segment s, we need to: 1.find the
left end-point of s. 2.trace intersected trapezoids. 3.update the
trapezoids. 4.update the bi-directional pointers. For each
trapezoid:Overall: t(f) : the complexity of trapezoid f. p(f) :
update the bi-directional pointer for trapezoid f.
Slide 105
Backward Analysis Imagine the algorithm run backwards, deleting
segment one at a time. When we delete a segment s from H i, only
trapezoids in H i which adjacent to s will be affected.
Slide 106
Complexity Analysis Since we insert (or delete in backward
analysis) segment s in random order, then every remaining segment
is equally likely to be chosen. E(i): the expected complexity of
deleting the i th segment. (in backward analysis)
Slide 107
Observation Each trapezoid is adjacent to at most 4 segments.
(using general position assumption)
Slide 108
Observation Trapezoid can have an arbitrary number of adjacent
segments in non general position. We will deal with this case
later.
Slide 109
Complexity Analysis Each trapezoid is adjacent to at most 4
segments. = Each trapezoid appears in at most 4 segments adjacency
list
Slide 110
Complexity Analysis = all the left endpoints of segment that
have yet to be added (or have been deleted in backward
analysis).
Slide 111
Complexity Analysis =proportional to the number of vertices in
all decomposition k = the number of intersection
Slide 112
Complexity Analysis
Slide 113
Slide 114
Randomized vs. Deterministic
Slide 115
Non General Position How to handle non general position?
Rotation or Transformation Shear Transformation x = x + y
Slide 116
Summary Voronoi Diagrams -- Use Fortune Algorithm Delaunay
Triangulation -- Randomized Incremental Construction Dual of
Voronoi Trapezoidal Decomposition -- Randomized Incremental
Construction
Slide 117
Conclusion Widely used in various other areas. We use it
sometimes without even realising it. Lot of potential of further
development. Numerous interesting open problems.
http://compgeom.cs.uiuc.edu/~jeffe/open/
Slide 118
Slide 119
References Voronoi Derek Johns, "An Optimal Algorithm for
Computing 2D Voronoi Diagrams Fortune's Sweep Algorithm", Available
at
http://cgm.cs.mcgill.ca/~mcleish/644/Projects/DerekJohns/Sweep.htm
[Accessed February 2014] Dheeraj Kumar Singh, "Lecture 20: Voronoi
Diagrams and Fortunes Algorithm", Available at
http://intinno.iitkgp.ernet.in/courses/91/wfiles/37906 [Accessed
February 2014] Voronoi Diagrams, Available at
http://ima.udg.edu/~sellares/ComGeo/Vor2D_1.ppt [Accessed February
2014] Delaunay Triangulation
http://www.cs.umd.edu/~mount/754/Lects/754lects.pdf
http://www.cs.uu.nl/geobook/interpolation.pdf
http://www.comp.nus.edu.sg/~hcheng/academic/courses/cs5237/notes/04.pdf
http://www.comp.nus.edu.sg/~hcheng/academic/courses/cs5237/notes/05.pdf
http://www.comp.nus.edu.sg/~tantc/ioi_training/CG/l9cs4235.pdf
http://www.comp.nus.edu.sg/~tantc/ioi_training/CG/l10cs4235.pdf
http://groups.csail.mit.edu/graphics/classes/6.838/F01/lectures/Delaunay/Delaunay2D.ppt
Trapezoidal Decomposition Rajeev Motwani, Prabhakar Raghavan,
Randomized Algorithms, 1995 Subhash Suri, Point Location, Available
at http://www.cs.ucsb.edu/~suri/cs235/Location.pdf