/
Convex Sets & Concave Sets Convex Sets & Concave Sets

Convex Sets & Concave Sets - PowerPoint Presentation

bety
bety . @bety
Follow
342 views
Uploaded On 2022-05-15

Convex Sets & Concave Sets - PPT Presentation

A planar region is called convex if and only if for any pair of points in the line segment lies completely in   Otherwise it is called concave Convex   ID: 911237

polar convex points angle convex polar angle points point hull vertices smallest scan time order vertex push stack graham

Share:

Link:

Embed:

Download Presentation from below link

Download Presentation The PPT/PDF document "Convex Sets & Concave Sets" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

Slide1

Convex Sets & Concave Sets

A planar region is called convex if and only if for any pair of points , in , the line segment lies completely in .

 

Otherwise, it is called

concave.

Convex

 

 

 

 

 

 

Concave

Slide2

An Example

1

2

3

4

Regions 1 & 2: convex

Regions 3 & 4: concave

Slide3

Convex Hull

The convex hull CH() of a set is the smallest convex regionthat contains .

 

Rubber band

When

is finite, its convex hull is the unique

convex polygon

whose vertices

are from

and that contains all points of

.

 

Slide4

Degenerate Cases

The convex hull of a single point is itself. ♦ The convex hull of several collinear points is the line segment

joining the two extreme points.

Slide5

The Convex Hull Problem

Input: a set

of points

 

Output: a list of vertices of CH() in counterclockwise

order.

 

Example

Output:

,

,

, ,

, .  

 

 

 

 

 

 

 

 

 

 

(direction of traversal about the

outward axis with the interior

on the left)

Slide6

Edges of a Convex Hull

For every edge with endpoints

.

 

p

q

All other points in

lie

 

to the same side of the line passing through

and

 

Slide7

A Slow Convex Hull Algorithm

Slow-Convex-Hull() // set of directed edges of CH() that bounds the // points of

P on the right. for every ordered pair

, where

and //

pairs

do valid  true for every point or

//

such points do if lies to the right of

or

collinear with and but not on then valid  false

if valid then //

and cannot be both in From construct a list of vertices of CH(), sorted in counterclockwise order.

//

improvable to return L

 

Running time

 

 

 

 

 

 

 

Slide8

Floating Arithmetic is not Exact!

p

r

q

Nearly colinear points

p

,

q

,

r

.

p

to the left of

qr

.

q

to the left of

rp

.

r

to the left of

qp

.

All three accepted as edges!

Not

robust

– the algorithm could fail with small numerical error.

Slide9

Polar Angle

p

polar angle

 

 

 

 

Slide10

Graham Scan

1) Select the node with the smallest

coordinate.

 

 

This node will be a vertex of the convex hull.

Slide11

Tie Breaking (1)

When more than one point has the smallest

coordinate, pick

the

leftmost

(or rightmost) one.

 

 

Slide12

Sorting by Polar Angle

Labels are in the polar angle order.

2) Sort by polar angle with respect to

.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Slide13

No Polar Angle Evaluation

 

is the lowest (and leftmost)

 

a

ll polar angles

 

 

 

 

 

if

 

Slide14

Tie Breaking (2)

 

 

 

What if

 

Order them by distance from

.

 

 

if and

 

 

 

No square roots.

Use dot product!

Slide15

Point Elimination

When multiple points have the same polar angle, keep the onefurthest from .

 

Remove

the rest since they cannot possibly be the hull vertices.

 

furtherest

remove

 

 

Slide16

Stack Initialization

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

3)

S

maintaining a stack.

 

Slide17

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Slide18

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Slide19

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Slide20

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Slide21

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Slide22

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Slide23

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Slide24

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Slide25

Finish

 

 

 

S

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Slide26

Graham’s Scan

 

 

 

 

 

 

 

Every point

in

is

pushed onto

once

 

Non-vertices

of

CH(

)

determined

so far are

popped

 

vertices of

CH(

)

in the

counter-

clockwise

order.

 

candidates

for vertices

of

CH(

)

 

 

 

 

start

 

 

finish

 

 

 

Slide27

The Graham Scan Algorithm

Graham-Scan() let be the point in with minimum

-coordinate let 

be the remaining points in sorted in counterclockwise order by polar angle around

.

Top[]  0 Push(, )

Push(

, ) Push(

,

) for to do while

makes a nonleft turn from the line segment determined by Top() and Next-to-Top(

) do Pop() Push(, )

return

 

Slide28

Running time

The running time of Graham’s Scan is

 

#operations time / operation total

Push

 

Pop

 

Sorting

1 O(

)

 

Why?

Finding

 

1

 

Slide29

Proof of Correctness

Claim 1 Each point popped from stack S is not a vertex of CH(P).

 

 

 

 

 

 

 

 

Two cases when

is popped:

 

In neither case can

become a vertex of CH(

P

).

 

Proof

Slide30

Claim 2 Graham-Scan maintains the invariant that the points on stack S always form the vertices of a convex polygon in counterclockwise order.

Popping a point from

preserves the invariant.

 

The region

containing

 

The invariant still holds.

Proof

The claim holds right after initialization of

when

form a triangle (which is obviously convex).

 

Consider a point

being pushed onto

.

 

 

 

 

Slide31

Correctness of Graham’s Scan

Theorem If Graham-Scan is run on a set of at least three points, then a point of is on the stack S at termination if and only if it is a vertex of CH(P).

 

Slide32

Jarvis’ March

A “package wrapping” technique

 

 

(lowest point)

 

(smallest polar

angle

w.r.t.

)

 

 

(smallest polar

angle

w.r.t.

)

 

Right

chain

 

(smallest polar

angle

w.r.t.

)

 

 

(smallest polar

angle

w.r.t.

)

 

 

(smallest polar

angle

w.r.t.

)

 

Left

chain

Slide33

Running Time of Jarvis’s March

Let

be the number of vertices of the convex hull.

 

For each vertex, finding the point with the minimum

Polar angle, that is, the next vertex, takes time

.  

Comparison between two polar angles can be done

using cross product.

Thus

time in total.