9
Andrew's Monotone Chain Convex Hull Algorithm

Andrew's Monotone Chain Convex Hull Algorithm. Andrew's Monotone Chain Scan A left-to-right variant of Graham's scan Discovered by Andrew in 1979 Using

Embed Size (px)

Citation preview

Page 1: Andrew's Monotone Chain Convex Hull Algorithm. Andrew's Monotone Chain Scan A left-to-right variant of Graham's scan Discovered by Andrew in 1979 Using

Andrew's Monotone Chain Convex Hull Algorithm

Page 2: Andrew's Monotone Chain Convex Hull Algorithm. Andrew's Monotone Chain Scan A left-to-right variant of Graham's scan Discovered by Andrew in 1979 Using

Andrew's Monotone Chain Scan

• A left-to-right variant of Graham's scan

• Discovered by Andrew in 1979

• Using a linear lexigraphic sort of the point set by the x- and y-coordinates

• This may be an advantage if this order is already known for a set which is often the case.

Page 3: Andrew's Monotone Chain Convex Hull Algorithm. Andrew's Monotone Chain Scan A left-to-right variant of Graham's scan Discovered by Andrew in 1979 Using

[Andrew's Monotone Chain Algorithm

In 1979, Andrew, discovered an alternative to

the Graham scan that uses a linear lexographic

sort of the point set by the x- and

y-coordinates. This may be an advantage if this

order is already known for a set which is often the

case. Even if sorting is required, this is a faster

sort than the angular Graham-scan sort with a

more complicated comparison function. The

"Monotone Chain" algorithm computes the upper

and lower hulls of a monotone chain of points,

and so we refer to it as the "Monotone Chain"

algorithm. Like the Graham scan, it runs in O(n

log n) time due to the sort time. After that, it

only takes O(n) time to compute the hull. This

algorithm also uses a stack in a manner very

similar to Graham's algorithm.

Page 4: Andrew's Monotone Chain Convex Hull Algorithm. Andrew's Monotone Chain Scan A left-to-right variant of Graham's scan Discovered by Andrew in 1979 Using

The Chain Method

• Definition :

A chain C = ( u1, … , up ) is a planar straight-line graph with vertex set { u1, … , up } and edge set { (ui, ui+1) : i = 1, …, p-1 }

Page 5: Andrew's Monotone Chain Convex Hull Algorithm. Andrew's Monotone Chain Scan A left-to-right variant of Graham's scan Discovered by Andrew in 1979 Using

The Monotone Chain

• Definition :

A chain C = ( u1, …, up ) is said to be monotone with respect to a straight line L if a line orthogonal to L intersects C in exactly one point.

Page 6: Andrew's Monotone Chain Convex Hull Algorithm. Andrew's Monotone Chain Scan A left-to-right variant of Graham's scan Discovered by Andrew in 1979 Using
Page 7: Andrew's Monotone Chain Convex Hull Algorithm. Andrew's Monotone Chain Scan A left-to-right variant of Graham's scan Discovered by Andrew in 1979 Using

First the algorithm sorts the point set S = {P0,

P1, ..., Pn 1} by increasing x and then y coordinate

values. Let the minimum and maximum

x-coordinates be xmin and xmax. Clearly, P0.x =

xmin, but there may be other points with this

minimum x-coordinate. Let P-- be the point in S

with P.x = xmin first and then min y among all such

points. Also, let P-+ be the point with P.x = xmin

first and then max y second. Note that P-- = P-+

when there is a unique x-minimum

point. Similarly define P+- and P++ as the points

with P.x = xmax first, and then y min or max

second. Again note that P+- = P++ when there is a

unique x-maximum point. Next, join the lower

two points, P-- and P+- to define a lower line

Lmin. Also, join the upper two points, P-+ and

P++ to define an upper line Lmax. These points

and lines are shown in the following example

diagram.

Page 8: Andrew's Monotone Chain Convex Hull Algorithm. Andrew's Monotone Chain Scan A left-to-right variant of Graham's scan Discovered by Andrew in 1979 Using

The algorithm now proceeds to construct a lower

convex vertex chain min below Lmin and joining

the two lower points P-- and P+-; and also an

upper convex vertex chain max above Lmax and

joining the two upper points P++ and P-+ . Then

the convex hull of S is constructed by joining

min and max together.

Page 9: Andrew's Monotone Chain Convex Hull Algorithm. Andrew's Monotone Chain Scan A left-to-right variant of Graham's scan Discovered by Andrew in 1979 Using

The lower or upper convex chain is constructed using a

stack algorithm almost identical to the one used for the

Graham scan. For the lower chain, start with P-- on

the stack. Then process the points of S in

sequence. Only consider points strictly below the

lower line Lmin . Suppose that at any stage, the points

on the stack are the convex hull of points below Lmin

that have already been processed. Now consider the

next point Pk that is below Lmin . If the stack contains

only the one point P-- then put Pk onto the stack and

proceed to the next stage. Otherwise, determine

whether Pk is strictly left of the line between the top

two points on the stack. If it is, put Pk onto the stack

and proceed. If it is not, pop the top point off the

stack, and test Pk against the stack again. Continue

until Pk gets pushed onto the stack. After this stage,

the stack again contains the vertices of the lower hull

for the points already considered.