Polygon Partitioning - Department of Computer Sciencemisha/Spring16/05.pdfย ยท boundary can be split...

Post on 03-Jul-2018

219 views 0 download

Transcript of Polygon Partitioning - Department of Computer Sciencemisha/Spring16/05.pdfย ยท boundary can be split...

Polygon Partitioning

Oโ€™Rourke, Chapter 2

Outline

โ€ข Triangle Partitions

โ€ข Convex Partitions

Monotonicity

A polygonal ๐‘ƒ is monotone w.r.t. a line ๐ฟ if its

boundary can be split into two polygon

chains, ๐ด and ๐ต, such that each chain is

monotonic w.r.t. ๐ฟ.

๐ฟโ€ฒ

๐‘ƒ๐ด ๐ต

๐ฟ

Monotonicity

A polygonal ๐‘ƒ is monotone w.r.t. a line ๐ฟ if its

boundary can be split into two polygon

chains, ๐ด and ๐ต, such that each chain is

monotonic w.r.t. ๐ฟ.

A polygon ๐‘ƒ is a monotone

mountain w.r.t. ๐ฟ if it is

monotone w.r.t. ๐ฟ and one

of the two chains (the base)

is a single segment.

๐ฟโ€ฒ

๐ฟ

๐‘ƒ

Note: Both endpoints of the base have to be convex

Claim

Every strictly convex vertex of a monotone

mountain that is not on the base is an ear tip.

WLOG, we will assume that

๐ฟ is vertical and that the base

is to the left.

We will first show that the

diagonal has to be interior

and then that it cannot

intersect the polygon.

๐ฟโ€ฒ

๐ฟ

๐‘ƒ

Proofs

Assume โˆƒ ๐‘ฃโˆ’, ๐‘ฃ, ๐‘ฃ+ โŠ‚ ๐‘ƒ, with ๐‘ฃ strictly

convex, s.t. ๐‘ฃโˆ’๐‘ฃ+ is not an interior diagonal.

๐‘ฃ+๐‘ฃโˆ’ cannot be locally

exterior because: If ๐‘ฃ+ is not on the base, then

๐‘ฃ+๐‘ฃ++ must be below ๐‘ฃ+.

Since ๐‘ฃ is strictly convex,

๐‘ฃ+๐‘ฃโˆ’ is to the left of ๐‘ฃ+๐‘ฃ.

๐ฟ

๐‘ฃ

๐‘ฃ+

๐‘ฃโˆ’

๐‘ฃ++

Proofs

Assume โˆƒ ๐‘ฃโˆ’, ๐‘ฃ, ๐‘ฃ+ โŠ‚ ๐‘ƒ, with ๐‘ฃ strictly

convex, s.t. ๐‘ฃโˆ’๐‘ฃ+ is not an interior diagonal.

๐‘ฃ+๐‘ฃโˆ’ cannot be locally

exterior because: If ๐‘ฃ+ is on the base, then

๐‘ฃ+๐‘ฃโˆ’ is to the left of ๐‘ฃ+๐‘ฃ.

But it must also be to the right

of the base since ๐‘ฃโˆ’ is to the

right of the base.

๐ฟ

๐‘ฃโˆ’

๐‘ฃ

๐‘ฃ+

Proofs

Assume โˆƒ ๐‘ฃโˆ’, ๐‘ฃ, ๐‘ฃ+ โŠ‚ ๐‘ƒ, with ๐‘ฃ strictly

convex, s.t. ๐‘ฃโˆ’๐‘ฃ+ is not an interior diagonal.

โ‡’ If ๐‘ฃโˆ’๐‘ฃ+ is not an interior

diagonal then โˆƒ๐‘ฅ โˆˆ ๐‘ƒ, reflex,

with ๐‘ฅ interior to ฮ”๐‘ฃ+๐‘ฃ๐‘ฃโˆ’. Interior โ‡’ it cannot lie on the

chain ๐‘ฃ+๐‘ฃ๐‘ฃโˆ’.

Reflex โ‡’ it is not on the base.

โ‡’ The horizontal through ๐‘ฅintersects ๐‘ƒ in three points.

๐‘ฅ

๐ฟ

๐‘ฃ

๐‘ฃ+

๐‘ฃโˆ’

Monotone Mountain Triangulation

Approach:

1. Find a convex vertex not on the base.

2. Remove it.

3. Go to step 1.

Note:

We can induct because when we remove an ear,

we do not violate the monotonicity of the chain.

Monotone Mountain Triangulation

Approach:

1. Find a convex vertex not on the base.

2. Remove it.

3. Go to step 1.

Monotone Mountain Triangulation

Approach:

1. Find a convex vertex not on the base.

2. Remove it.

3. Go to step 1.

Monotone Mountain Triangulation

Approach:

1. Find a convex vertex not on the base.

2. Remove it.

3. Go to step 1.

Monotone Mountain Triangulation

Approach:

1. Find a convex vertex not on the base.

2. Remove it.

3. Go to step 1.

Monotone Mountain Triangulation

Approach:

1. Find a convex vertex not on the base.

2. Remove it.

3. Go to step 1.

Monotone Mountain Triangulation

Approach:

1. Find a convex vertex not on the base.

2. Remove it.

3. Go to step 1.

Monotone Mountain Triangulation

Approach:

1. Find a convex vertex not on the base.

2. Remove it.

3. Go to step 1.

Monotone Mountain Triangulation

Approach:

1. Find a convex vertex not on the base.

2. Remove it.

3. Go to step 1.

Monotone Mountain Triangulation

Approach:

1. Find a convex vertex not on the base.

2. Remove it.

3. Go to step 1.

Monotone Mountain Triangulation

Approach:

1. Find a convex vertex not on the base.

2. Remove it.

3. Go to step 1.

Monotone Mountain Triangulation

Approach:

1. Find a convex vertex not on the base.

2. Remove it.

3. Go to step 1.

To do this, we need to be able

to quickly identify the next

convex vertex.

Recall:

Strictly convex โ‡” interior angle < ๐œ‹.

Monotone Mountain Triangulation

MonotoneMountainTriangulation( ๐‘ƒ ):โ€“ ๐ต โ†FindBase( ๐‘ƒ )โ€“ ๐ถ โ† LinkConvexVertices( ๐‘ƒ โˆ’ ๐ต )โ€“ while ๐ถ โ‰  โˆ…:

โ€ข ๐‘ฃ โ† First( ๐ถ )โ€ข output( ฮ”๐‘ฃโˆ’๐‘ฃ๐‘ฃ+ )โ€ข ๐‘ƒ โ† ๐‘ƒ โˆ’ {๐‘ฃ}

โ€ข if(๐‘ฃ+ โˆ‰ ๐ถ AND ๐‘ฃ+ โˆ‰ ๐ต )โ€ข if( โˆ ๐‘ฃ+ < ๐œ‹ ) ๐‘ฃ.addAfter( ๐‘ฃ+ )

โ€ข if( ๐‘ฃโˆ’ โˆ‰ ๐ถ AND ๐‘ฃโˆ’ โˆ‰ ๐ต )โ€ข if( โˆ ๐‘ฃโˆ’ < ๐œ‹ ) ๐‘ฃ.addBefore( ๐‘ฃโˆ’ )

โ€ข ๐ถ โ† ๐ถ โˆ’ {๐‘ฃ}

Generating Monotone Mountains

Approach:

โ€ข Compute a trapezoidalization of ๐‘ƒ.

โ€ข Connect supporting vertices

that donโ€™t come from

the same side.

Generating Monotone Mountains

Claim:

Such a partition generates pieces that are

monotone mountains.

Generating Monotone Mountains

Proof:

This algorithm removes all interior cusps,

so the partition pieces are monotone.

Proof:

Given a piece, we can find its topmost

vertex ๐‘ฃ, with neighbors ๐‘ฃโˆ’ and ๐‘ฃ+.

Assume ๐‘ฃ+ is lower than ๐‘ฃโˆ’.

Generating Monotone Mountains

๐‘ฃ

๐‘ฃ+

๐‘ฃโˆ’

Generating Monotone Mountains

Proof:

Following the chain down ๐‘ฃโˆ’, we get to the

last vertex, ๐‘ค โˆˆ ๐‘ƒ, above ๐‘ฃ+.

There is a trapezoid

supported by ๐‘ค and ๐‘ฃ+.

Since ๐‘ค and ๐‘ฃ+ are on different

sides of the trapezoid, the diagonal

to ๐‘ฃ+ must be added.

โ‡’ ๐‘ฃ+ is a partition endpoint

๐‘ฃ

๐‘ฃ+

๐‘ฃโˆ’

๐‘ค

Triangulation

Triangulate( ๐‘ƒ ):โ€“ Construct a trapezoidalization

Triangulation

Triangulate( ๐‘ƒ ):โ€“ Construct a trapezoidalizationโ€“ Connect supporting vertices from different sides.

Triangulation

Triangulate( ๐‘ƒ ):โ€“ Construct a trapezoidalizationโ€“ Connect supporting vertices from different sides.โ€“ Triangulate the mountains

Triangulation

Note:

The algorithms for triangulating via monotone

polygons and monotone mountains works for

polygons with disconnected boundaries.

Outline

โ€ข Triangle Partitions

โ€ข Convex Partitions

Convex Partitions

Definition:A convex partition by segments of a polygon ๐‘ƒ is

a decomposition of ๐‘ƒ into convex polygons

obtained by introducing arbitrary segments.

Convex Partitions

Definition:A convex partition by segments of a polygon ๐‘ƒ is

a decomposition of ๐‘ƒ into convex polygons

obtained by introducing arbitrary segments.

A convex partition by diagonals

of a polygon ๐‘ƒ is a decomposition

of ๐‘ƒ into convex polygons obtained

by only introducing diagonals.

Convex Partitions

Definition:A convex partition by segments of a polygon ๐‘ƒ is

a decomposition of ๐‘ƒ into convex polygons

obtained by introducing arbitrary segments.

A convex partition by diagonals

of a polygon ๐‘ƒ is a decomposition

of ๐‘ƒ into convex polygons obtained

by only introducing diagonals.

Challenge:

Compute a convex partition with

the smallest number of pieces.

Challenge2:

Compute it efficiently

Convex Partitions (by Segments)

Claim (Chazelle):

Assume the polygon ๐‘ƒ has ๐‘Ÿ reflex vertices.

If ฮฆ is the fewest number of polygons required

for a convex partition by segments of ๐‘ƒ then:

๐‘Ÿ/2 + 1 โ‰ค ฮฆ โ‰ค ๐‘Ÿ + 1

Convex Partitions (by Segments)

Proof (ฮฆ โ‰ค ๐‘Ÿ + 1):

For each reflex vertex, add the bisector.

Because the segment bisects, the reflex

angle splits into two convex angles.

(Angles at the new vertices have to be < ๐œ‹.)

Doing this for each reflex

vertices, gives a convex

partition with ๐‘Ÿ + 1 pieces.

Convex Partitions (by Segments)

Proof ( ๐‘Ÿ/2 โ‰ค ฮฆ):

Each reflex vertex needs to be split and each

introduced segment can split at most two

reflex vertices.

Convex Partitions (by Diagonals)

Definition:

A diagonal in a convex partition is essential

for vertex ๐‘ฃ โˆˆ ๐‘ƒ if removing the diagonal

creates a piece that is not convex at ๐‘ฃ.

Convex Partitions (by Diagonals)

Claim:

If ๐‘ฃ is a reflex vertex, it can have at most two

essential diagonals.

Proof:

Given a reflex vertex ๐‘ฃ, let ๐‘ฃโˆ’ and ๐‘ฃ+ be the

vertices immediately before and after ๐‘ฃ in ๐‘ƒ.

There can be at most one essential segment in

the half-space to the right of ๐‘ฃ๐‘ฃ+.

(If there were two, we could

remove the one closer to ๐‘ฃ๐‘ฃ+.)

Convex Partitions (by Diagonals)

๐‘ฃโˆ’

๐‘ฃ+

๐‘ฃ

Proof:

Given a reflex vertex ๐‘ฃ, let ๐‘ฃโˆ’ and ๐‘ฃ+ be the

vertices immediately before and after ๐‘ฃ in ๐‘ƒ.

Similarly, there can be at most one essential

segment in the half-space to the right of ๐‘ฃ๐‘ฃโˆ’.

Convex Partitions (by Diagonals)

๐‘ฃโˆ’

๐‘ฃ+

Proof:

Given a reflex vertex ๐‘ฃ, let ๐‘ฃโˆ’ and ๐‘ฃ+ be the

vertices immediately before and after ๐‘ฃ in ๐‘ƒ.

Similarly, there can be at most one essential

segment in the half-space to the right of ๐‘ฃ๐‘ฃโˆ’.

Since the two half-spaces

cover the interior of the vertex

there are at most two essential

vertices at ๐‘ฃ.

Convex Partitions (by Diagonals)

๐‘ฃโˆ’

๐‘ฃ+

Convex Partitions (by Diagonals)

Algorithm (Hertl & Mehlhorn):

Start with a triangulation and remove inessential

diagonals.

Claim:

This algorithm is never worse

than 4 ร— optimal in the number

of convex pieces.

Convex Partitions (by Diagonals)

Proof:

When the algorithm terminates, every remaining

diagonal is essential for some (reflex) vertex.

Each reflex vertex can have at most two

essential diagonals.

โ‡’ There can be at most 2๐‘Ÿ + 1pieces in the partition.

Since at least ๐‘Ÿ/2 + 1 are

required, the result is within

4 ร— optimal.

Convex Partitions

Why do we care?

Convex polygons are easier to intersect against.

For a polygon with ๐‘› vertices:

โ€ข Testing if a point is inside is ๐‘‚(log ๐‘›).

โ€ข Testing if a line intersects is ๐‘‚(log ๐‘›).

โ€ข Testing if two polygons intersect is ๐‘‚(log ๐‘›).

Point/Convex-Polygon Intersection

Algorithm:

Recursively split the polygon in half and test the

half the point could be in.

๐‘ฃ2 ๐‘ฃ3

๐‘ฃ5

๐‘ฃ6

๐‘ฃ8

๐‘ฃ7

๐‘ฃ1 ๐‘ฃ4๐‘ž

Point/Convex-Polygon Intersection

Algorithm:

Recursively split the polygon in half and test the

half the point could be in.

๐‘ž

๐‘ฃ2 ๐‘ฃ3

๐‘ฃ1 ๐‘ฃ4

Point/Convex-Polygon Intersection

Algorithm:

Recursively split the polygon in half and test the

half the point could be in.

๐‘ž

๐‘ฃ3

๐‘ฃ1 ๐‘ฃ4

Point/Convex-Polygon Intersection

InConvexPolygon( ๐‘ž , {๐‘ฃ1, โ€ฆ , ๐‘ฃ๐‘›} ) if( ๐‘› == 3 )

ยปreturn InTriangle( ๐‘ž , {๐‘ฃ1, ๐‘ฃ2, ๐‘ฃ3} ); if( Left( ๐‘ฃ1, ๐‘ฃ ๐‘› 2 , ๐‘ ) )

ยปreturn InConvexPolygon( ๐‘ž , {๐‘ฃ ๐‘› 2, โ€ฆ , ๐‘ฃ1} );

elseยปreturn InConvexPolygon( ๐‘ž , {๐‘ฃ1, โ€ฆ , ๐‘ฃ ๐‘› 2} );

Line/Convex-Polygon Intersection

Note:

Given a convex polygon ๐‘ƒ, a line segment ๐ฟ, and

vertices ๐‘ฃ๐‘– , ๐‘ฃ๐‘— โˆˆ ๐‘ƒ on the same side of ๐ฟ.*

If the vector ๐‘ฃ๐‘–๐‘ฃ๐‘–+1 points

away from ๐ฟ, then ๐ฟ can

only intersect ๐‘ƒ along the

chain {๐‘ฃ๐‘— , ๐‘ฃ๐‘—+1, โ€ฆ , ๐‘ฃ๐‘–}.

Otherwise, ๐ฟ can only intersect

๐‘ƒ along the chain {๐‘ฃ๐‘– , ๐‘ฃ๐‘–+1, โ€ฆ , ๐‘ฃ๐‘—}.

๐‘ฃ๐‘—

๐ฟ

๐‘ฃ๐‘–

๐‘ฃ๐‘–+1

*Assume, WLOG that ๐‘ฃ๐‘– is closer to ๐ฟ than ๐‘ฃ๐‘— .

Line/Convex-Polygon Intersection

Algorithm:

Recursively split the polygon in half.

If the split points are on the same side, test the

half of the polygon that

could intersect.

Otherwise there

is an intersection.

๐‘ฃ2 ๐‘ฃ3

๐‘ฃ5

๐‘ฃ6

๐‘ฃ8

๐‘ฃ7

๐ฟ

๐‘ฃ1 ๐‘ฃ4

Line/Convex-Polygon Intersection

Algorithm:

Recursively split the polygon in half.

If the split points are on the same side, test the

half of the polygon that

could intersect.

Otherwise there

is an intersection.

๐‘ฃ2

๐ฟ

๐‘ฃ4

๐‘ฃ3

๐‘ฃ1

Line/Convex-Polygon Intersection

IsectConvexPolygon( {๐‘™1, ๐‘™2} , {๐‘ฃ1, โ€ฆ , ๐‘ฃ๐‘›} ) if( ๐‘› == 3 )

ยปreturn IsectTriangle( {๐‘™1, ๐‘™2} , {๐‘ฃ1, ๐‘ฃ2, ๐‘ฃ3 ); if( Left( ๐‘™1 , ๐‘™2 , ๐‘ฃ1 )!=Left( ๐‘™1 , ๐‘™2 , ๐‘ฃ ๐‘› 2 ) )

ยปreturn true; else

ยปif( Dist( {๐‘™1, ๐‘™2} , ๐‘ฃ1 )<Dist( {๐‘™1, ๐‘™2} , ๐‘ฃ ๐‘› 2 )โ€“ if( Dist( {๐‘™1, ๐‘™2} , ๐‘ฃ1 )<Dist( {๐‘™1, ๐‘™2} , ๐‘ฃ2 )

โ€ข return IsectConvexPolygon( {๐‘™1, ๐‘™2} , {๐‘ฃ ๐‘› 2, โ€ฆ , ๐‘ฃ1} );

โ€“ else

โ€ข return IsectConvexPolygon( {๐‘™1, ๐‘™2} , {๐‘ฃ1, โ€ฆ , ๐‘ฃ ๐‘› 2} );

ยปelse...