Design of Spatial Information Systems - PowerPoint PPT Presentation

1 / 20
About This Presentation
Title:

Design of Spatial Information Systems

Description:

... force: Main idea. Check each pair ... QuickHull: Main Idea ... Gift Wrapping: Main idea. Start at some extreme point, which is guaranteed to be on the hull. ... – PowerPoint PPT presentation

Number of Views:73
Avg rating:3.0/5.0
Slides: 21
Provided by: Jus6
Category:

less

Transcript and Presenter's Notes

Title: Design of Spatial Information Systems


1
DEPARTMENT OF COMPUTER SCIENCE UNIVERSITY OF
JOENSUU JOENSUU, FINLAND
  • Design of Spatial Information Systems
  • Lecture 8b
  • Convex Hull
  • Alexander Kolesnikov

2
Convexity
Definition A subset S of the plane is called
convex if and only if for any pair of points
P,Q?S the line segment PQ is completely
contained in S.
3
Convex hull
The convex hull CH(P) of a finite point set P is
the smallest convex polygon that contains P.
S
Nails sticking out of the plane and elastic
rubber band
4
Algorithms for Convex Hull problem
Algorithm Speed Discovered by Brute
Force O(n3) Anon, the dark ages Gift
Wrapping O(nh) Chand Kapur,
1970 Graham Scan O(n log n) Graham,
1972 Jarvis March O(nh) Jarvis,
1973 QuickHull O(nh) Eddy, 1977,
Bykat, 1978 Divide-and-Conquer O(n log n)
Preparata Hong, 1977 Monotone Chain O(n log
n) Andrew, 1979 Incremental O(n log n)
Kallay, 1984 Marriage-before- Conquest O(n
log h) Kirkpatrick Seidel, 1986
5
Brute force Main idea
  • Check each pair (p,q) of points
  • if all other points are on the left side of
    the edge (p,q),
  • this edge (p,q) belong to the convex hull.
  • n(n-1) different pairs
  • for one pair check other (n-2) points
  • Check one point O(1) operation
  • Complexity is O(n(n-1))O(n-2)O(1) O(n3)


6
Brute force Algorithm

Brute_Force(Ppoints)points FOR (all ordered
pairs (p,q)?S AND p?q) DO valid ? TRUE
FOR (all points r?S AND r ? p AND r? q)
DO IF (r isRight(p,q) ) THEN
valid ? FALSE ENDIF
END IF (validTRUE) THEN // Good
edge! Add the directed edge (p,q) to
list E. ENDIF ENDFOR Construct
CH(P) from the list E END
7
QuickHull Main Idea

We are given a set of points P, and line segment
AB is a chord of the convex hull CH(P) a chord
goes from the leftmost to the rightmost point in
the set. 1. Among the given points, find the one
which is farthest from AB. Call the point
C. 2. The points inside the triangle ABC cannot
be on the hull. (Why?) Put them in a set
S0. 3. Put the points which lie outside edge AC
in set S1, and points outside edge BC in set
S2. Once the partition is done, we recursively
invoke QuickHull procedure on sets S1 and S2.
8
QuickHull 0

P
9
QuickHull 1

P
10
QuickHull 2

11
QuickHull Cont.

Once the partition is done, we recursively invoke
QuickHull() procedure on sets S1 and S2.
12
QuickHull Final

13
QuickHull Complexity

Complexity is O(nh), where h is the number of
vertices in the Convex Hull.
Demo http//www.cs.princeton.edu/ah/alg_anim/ver
sion1/QuickHull.html
14
Gift Wrapping Main idea
  • Start at some extreme point, which is guaranteed
    to be on the hull.
  • At each step, test each of the point, and find
    the one which makes the largest right-hand turn.
    That point has to be the next on the hull.
  • Another name of the algorithm is Jarvis March.

http//www.cs.princeton.edu/ah/alg_anim/version1/
JarvisMarch.html
15
Gift Wrapping Algorithm
GiftWrapping(P points)points // Vertices A in
counter-clockwise order k1 A1 Rightmost
point of P DO A(k1) point such that all
other points in P are to the
LEFT of the line (A(k), A(k1)) // O(n) k
k 1 WHILE A(k) ! A(1)
// O(h) RETURN A
A(4)
A(3)
A(3)
A(5)
A(2)
A(2)
A(2)
A(1)
A(1)
A(1)
A(6)
16
Gift Wrapping Example

Output dependent complexity is O(nh), where h is
the number of vertices in the Convex Hull. For
each vertex in the CH we have to check O(n)
points to find such a point the the main
condition is satisfied.
http//www.cs.princeton.edu/ah/alg_anim/version1/
JarvisMarch.html
17
Graham Scan Main idea
1. Find an extreme point. This point will be the
pivot, is guaranteed to be on the hull, and
is chosen to be the point with largest x
coordinate. 2. Sort the point in order of
increasing angle about the pivot P0. We end
up with a star shaped polygon. 3. Build the hull,
by marching around the star shaped polygon,
adding edges when we make a left turn, and
backtracking when we make a right turn.
18
Graham Scan Algorithm
GrahamScan(S set of points P (P.x,P.y))
Select the rightmost lowest point P0 in S.
Sort S angularly about P0 as a center.
For ties, discard the closer points. Let
PN be the sorted array of points. Push
P0P0 and P1 onto a stack W. WHILE lt N
DO Let PT1 the top point on W
Let PT2 the second top point on W
IF (Pi is strictly left of the line PT2
to PT1) THEN Push Pi onto W
i // increment i
ELSE Pop the top point PT1 off the
stack ENDIF END RETURN W the
convex hull of S
19
Graham Scan Example
Complexity is O(n log n)O( n) O(n log n)
http//www.cs.princeton.edu/ah/alg_anim/version1/
GrahamScan.html
20
Convex Hull algorithm for simple polygon
Convex Hull algorithm for simple polygon
Melkman, 1987. Complexity O(N).
http//web.mit.edu/drdaniel/www/6.838/ConvexHull/C
H.html
Write a Comment
User Comments (0)
About PowerShow.com