Upload
others
View
5
Download
0
Embed Size (px)
Citation preview
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
Smallest enclosing circles and more
Computational Geometry
Lecture 4: Smallest enclosing circles and more
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
Facility locationProperties of the smallest enclosing circle
Facility location
Given a set of houses and farmsin an isolated area. Can we placea helicopter ambulance post sothat each house and farm can bereached within 15 minutes?
Where should we place anantenna so that a number oflocations have maximumreception?
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
Facility locationProperties of the smallest enclosing circle
Facility location in geometric terms
Given a set of points in the plane.Is there any point that is within acertain distance of these points?
Where do we place a point thatminimizes the maximum distanceto a set of points?
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
Facility locationProperties of the smallest enclosing circle
Facility location in geometric terms
Given a set of points in theplane, compute the smallestenclosing circle
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
Facility locationProperties of the smallest enclosing circle
Smallest enclosing circle
Observation: It must pass throughsome points, or else it cannot besmallest
Take any circle that encloses thepoints, and reduce its radiusuntil it contains a point p
Move center towards p whilereducing the radius further, untilthe circle contains anotherpoint q
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
Facility locationProperties of the smallest enclosing circle
Smallest enclosing circle
Move center on the bisector of pand q towards their midpoint,until:(i) the circle contains a thirdpoint, or(ii) the center reaches themidpoint of p and q
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
Facility locationProperties of the smallest enclosing circle
Smallest enclosing circle
Question: Does the “algorithm” ofthe previous slide work?
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
Facility locationProperties of the smallest enclosing circle
Smallest enclosing circle
Observe: A smallest enclosing circlehas (at least) three points on itsboundary, or only two in which casethey are diametrally opposite
Question: What is the extraproperty when there are three pointson the boundary?
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
Randomized incremental constructionA more restricted problemA yet more restricted problemEfficiency analysis
Randomized incremental construction
Construction by randomized incremental construction
incremental construction: Add points one by one andmaintain the solution so far
randomized: Use a random order to add the points
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
Randomized incremental constructionA more restricted problemA yet more restricted problemEfficiency analysis
Putting in random order
The points may be given in any order, the algorithm will justreorder them
Let j be a random integer in [1,n]Swap pj and pn
Recursively shuffle p1, . . . ,pn−1
Putting in random order takes O(n) time
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
Randomized incremental constructionA more restricted problemA yet more restricted problemEfficiency analysis
Expected running time
Every one of the n! orders is equally likely
The expected time taken by the algorithm is the average timeover all orders
1n!· ∑
Π permutationtime if the random order is Π
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
Randomized incremental constructionA more restricted problemA yet more restricted problemEfficiency analysis
Adding a point
Let p1, . . . ,pn be the points in random order
Let Ci be the smallest enclosing circle for p1, . . . ,pi
Suppose we know Ci−1 and we want to add pi
If pi is inside Ci−1, then Ci = Ci−1
If pi is outside Ci−1, then Ci will have pi on its boundary
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
Randomized incremental constructionA more restricted problemA yet more restricted problemEfficiency analysis
Adding a point
Ci−1
pi
Ci−1
pi
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
Randomized incremental constructionA more restricted problemA yet more restricted problemEfficiency analysis
Adding a point
Question: Suppose we remembered not only Ci−1, but alsothe two or three points defining it. It looks like if pi is outsideCi−1, the new circle Ci is defined by pi and some points thatdefined Ci−1. Why is this false?
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
Randomized incremental constructionA more restricted problemA yet more restricted problemEfficiency analysis
Adding a point
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
Randomized incremental constructionA more restricted problemA yet more restricted problemEfficiency analysis
Adding a point
How do we find the smallestenclosing circle of p1 . . . ,pi−1 with pi
on the boundary?
We study the new(!) geometricproblem of computing the smallestenclosing circle with a given point pon its boundary
p
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
Randomized incremental constructionA more restricted problemA yet more restricted problemEfficiency analysis
Smallest enclosing circle with point
Given a set P of points and onespecial point p, determine thesmallest enclosing circle of P thatmust have p on the boundary
Question: How do we solve it? p
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
Randomized incremental constructionA more restricted problemA yet more restricted problemEfficiency analysis
Randomized incremental construction
Construction by randomized incremental construction
incremental construction: Add points one by one andmaintain the solution so far
randomized: Use a random order to add the points
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
Randomized incremental constructionA more restricted problemA yet more restricted problemEfficiency analysis
Adding a point
Let p1, . . . ,pi−1 be the points in random order
Let C′j be the smallest enclosing circle for p1, . . . ,pj (j≤ i−1)and with p on the boundary
Suppose we know C′j−1 and we want to add pj
If pj is inside C′j−1, then C′j = C′j−1
If pj is outside C′j−1, then C′j will have pj on its boundary(and also p of course!)
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
Randomized incremental constructionA more restricted problemA yet more restricted problemEfficiency analysis
Adding a point
C ′j−1
pj
C ′j−1
pj
p p
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
Randomized incremental constructionA more restricted problemA yet more restricted problemEfficiency analysis
Adding a point
How do we find the smallestenclosing circle of p1 . . . ,pj−1 with pand pj on the boundary?
We study the new(!) geometricproblem of computing the smallestenclosing circle with two given pointson its boundary
pq
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
Randomized incremental constructionA more restricted problemA yet more restricted problemEfficiency analysis
Smallest enclosing circle with two points
Given a set P of points and twospecial points p and q, determine thesmallest enclosing circle of P thatmust have p and q on the boundary
Question: How do we solve it? pq
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
Randomized incremental constructionA more restricted problemA yet more restricted problemEfficiency analysis
Two points known
p
q q
p
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
Randomized incremental constructionA more restricted problemA yet more restricted problemEfficiency analysis
Two points known
p
q q
p
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
Randomized incremental constructionA more restricted problemA yet more restricted problemEfficiency analysis
Algorithm: two points known
Assume w.lo.g. that p and q lie on a vertical line. Let ` be theline through p and q and let `′ be their bisector
For all points left of `, find the one that, together with p andq, defines a circle whose center is leftmost → pl
For all points right of `, find the one that, together with pand q, defines a circle whose center is rightmost → pr
Decide if C(p,q,pl) or C(p,q,pr) or C(p,q) is the smallestenclosing circle
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
Randomized incremental constructionA more restricted problemA yet more restricted problemEfficiency analysis
Two points known
p
q q
p p
p
pl pr
C(p, q, pr)
C(p, q, pl)
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
Randomized incremental constructionA more restricted problemA yet more restricted problemEfficiency analysis
Analysis: two points known
Smallest enclosing circle for n pointswith two points already known takesO(n) time, worst case
pq
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
Randomized incremental constructionA more restricted problemA yet more restricted problemEfficiency analysis
Algorithm: one point known
Use a random order for p1, . . . ,pn; start withC1 = C(p,p1)for j← 2 to n doIf pj in or on Cj−1 then Cj = Cj−1; otherwise, solvesmallest enclosing circle for p1, . . . ,pj−1 with two pointsknown (p and pj)
C ′j−1
pj
C ′j−1
pj
p p
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
Randomized incremental constructionA more restricted problemA yet more restricted problemEfficiency analysis
Analysis: one point known
If only one point is known, we used randomized incrementalconstruction, so we need an expected time analysis
C ′j−1
pj
C ′j−1
pj
p p
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
Randomized incremental constructionA more restricted problemA yet more restricted problemEfficiency analysis
Analysis: one point known
Backwards analysis: Consider the situation after adding pj,so we have computed Cj
p Cjp Cj
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
Randomized incremental constructionA more restricted problemA yet more restricted problemEfficiency analysis
Analysis: one point known
The probability that the j-th addition was expensive is thesame as the probability that the smallest enclosing circlechanges (decreases in size) if we remove a random point fromthe j points
p Cjp Cj
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
Randomized incremental constructionA more restricted problemA yet more restricted problemEfficiency analysis
Analysis: one point known
This probability is 2/j in the left situation and 1/j in the rightsituation
p Cjp Cj
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
Randomized incremental constructionA more restricted problemA yet more restricted problemEfficiency analysis
Analysis: one point known
The expected time for the j-th addition of a point is
j−2j·Θ(1)+
2j·Θ(j) = O(1)
or
j−1j·Θ(1)+
1j·Θ(j) = O(1)
The expected running time of the algorithm for n points is:
Θ(n)+n
∑j=2
Θ(1) = Θ(n)
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
Randomized incremental constructionA more restricted problemA yet more restricted problemEfficiency analysis
Analysis: one point known
Smallest enclosing circle for n pointswith one point already known takesΘ(n) time, expected
p
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
Randomized incremental constructionA more restricted problemA yet more restricted problemEfficiency analysis
Algorithm: smallest enclosing circle
Use a random order for p1, . . . ,pn; start withC2 = C(p1,p2)for i← 3 to n doIf pi in or on Ci−1 then Ci = Ci−1; otherwise, solvesmallest enclosing circle for p1, . . . ,pi−1 with one pointknown (pi)
Ci−1
pi
Ci−1
pi
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
Randomized incremental constructionA more restricted problemA yet more restricted problemEfficiency analysis
Analysis: smallest enclosing circle
For smallest enclosing circle, we used randomized incrementalconstruction, so we need an expected time analysis
Ci−1
pi
Ci−1
pi
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
Randomized incremental constructionA more restricted problemA yet more restricted problemEfficiency analysis
Analysis: smallest enclosing circle
Backwards analysis: Consider the situation after adding pi,so we have computed Ci
Ci Ci
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
Randomized incremental constructionA more restricted problemA yet more restricted problemEfficiency analysis
Analysis: smallest enclosing circle
The probability that the i-th addition was expensive is thesame as the probability that the smallest enclosing circlechanges (decreases in size) if we remove a random point fromthe i points
Ci Ci
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
Randomized incremental constructionA more restricted problemA yet more restricted problemEfficiency analysis
Analysis: smallest enclosing circle
This probability is 3/i in the left situation and 2/i in the rightsituation
Ci Ci
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
Randomized incremental constructionA more restricted problemA yet more restricted problemEfficiency analysis
Analysis: smallest enclosing circle
The expected time for the i-th addition of a point is
i−3i·Θ(1)+
3i·Θ(i) = O(1)
or
i−2i·Θ(1)+
2i·Θ(i) = O(1)
The expected running time of the algorithm for n points is:
Θ(n)+n
∑i=3
Θ(1) = Θ(n)
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
Randomized incremental constructionA more restricted problemA yet more restricted problemEfficiency analysis
Result: smallest enclosing circle
Theorem The smallest enclosingcircle for n points in plane can becomputed in O(n) expected time
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
ConditionsDiameter and closest pairWidthMore examples
When does it work?
Randomized incremental construction algorithms of this sort(compute an ‘optimal’ thing) work if:
1.) The test whether the next input object violates thecurrent optimum must be possible and fast
2.) If the next input object violates the current optimum,finding the new optimum must be an easier problem thanthe general problem
3.) The thing must already be defined by O(1) of the inputobjects
4.) Ultimately: the analysis must work out
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
ConditionsDiameter and closest pairWidthMore examples
Diameter, closest pair
Diameter: Given a set of n points inthe plane, compute the two pointsfurthest apart
Closest pair: Given a set of n pointsin the plane, compute the two pointsclosest together
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
ConditionsDiameter and closest pairWidthMore examples
Width
Width: Given a set of n points in theplane, compute the smallest distancebetween two parallel lines thatcontain the points (narrowest strip)
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
ConditionsDiameter and closest pairWidthMore examples
Rotating callipers
The width can be computed using the rotating callipers algorithm
Compute the convex hull
Find the highest and lowest point on it; theydefine two horizontal lines that enclose thepoints
Rotate the lines together while proceedingalong the convex hull
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
ConditionsDiameter and closest pairWidthMore examples
Rotating callipers
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
ConditionsDiameter and closest pairWidthMore examples
Rotating callipers
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
ConditionsDiameter and closest pairWidthMore examples
Rotating callipers
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
ConditionsDiameter and closest pairWidthMore examples
Rotating callipers
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
ConditionsDiameter and closest pairWidthMore examples
Rotating callipers
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
ConditionsDiameter and closest pairWidthMore examples
Rotating callipers
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
ConditionsDiameter and closest pairWidthMore examples
Width
Property: The width is alwaysdetermined by three points of the set
Theorem: The rotating callipersalgorithm determines the width (andthe diameter) in O(n logn) time
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
ConditionsDiameter and closest pairWidthMore examples
Width by RIC?
Property: The width is alwaysdetermined by three points of the set
We can maintain the two linesdefining the width to have a fast testfor violation
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
ConditionsDiameter and closest pairWidthMore examples
Adding a point
Question: How about adding apoint? If the new point lies insidethe narrowest strip we are fine, butwhat if it lies outside?
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
ConditionsDiameter and closest pairWidthMore examples
Adding a point
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
ConditionsDiameter and closest pairWidthMore examples
Adding a point
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
ConditionsDiameter and closest pairWidthMore examples
Width
A good reason to be very suspiciousof randomized incrementalconstruction as a working approachis non-uniqueness of a solution
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
ConditionsDiameter and closest pairWidthMore examples
Minimum bounding box
Question: Can we compute theminimum axis-parallel bounding boxby randomized incrementalconstruction?
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
ConditionsDiameter and closest pairWidthMore examples
Minimum bounding box
Yes, in O(n) expected time
. . . but a normal incrementalalgorithm does it in O(n) worst casetime
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
ConditionsDiameter and closest pairWidthMore examples
Lowest point in circles
Problem 1: Given n disks in theplane, can we compute the lowestpoint in their common intersectionefficiently by randomized incrementalconstruction?
Problem 2: Given n disks in theplane, can we compute the lowestpoint in their union efficiently byrandomized incrementalconstruction?
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
ConditionsDiameter and closest pairWidthMore examples
Half-plane intersection
Problem: Given a set of nhalf-planes, can we decideefficiently if theirintersection is empty?
Computational Geometry Lecture 4: Smallest enclosing circles and more
IntroductionSmallest enclosing circle algorithm
Randomized incremental construction
ConditionsDiameter and closest pairWidthMore examples
Red-blue separation
Problem: Given a set of n red andblue points in the plane, can wedecide efficiently if they have aseparating line?
Computational Geometry Lecture 4: Smallest enclosing circles and more