72
FUNDAMENTALS OF COMPUTATIONAL GEOMETRY Fundamentals of computational geometry M. Ramanathan STTP CAD 2011

Fundamentals of computational geometry

  • Upload
    baba

  • View
    151

  • Download
    11

Embed Size (px)

DESCRIPTION

Fundamentals of computational geometry. M. Ramanathan. The Art Gallery Problem. camera. How many cameras are needed to guard a gallery and How should they be placed?. Definitions. Simple Polygon Model. Model the art gallery as a region bounded by some simple - PowerPoint PPT Presentation

Citation preview

Page 1: Fundamentals of computational geometry

Fundamentals of computational geometry

FUNDAMENTALS OF COMPUTATIONAL GEOMETRY

M. Ramanathan

STTP CAD 2011

Page 2: Fundamentals of computational geometry

Fundamentals of computational geometry

The Art Gallery Problem

camera

How many cameras are needed to guard a gallery and How should they be placed?

STTP CAD 2011

Page 3: Fundamentals of computational geometry

Fundamentals of computational geometry

Definitions

0 1 1 1, , , , vertices of an -vertex polygon.n nv v v v n

0 0 1 1 1 1 0

1 1

Edges , , , , are

bounding a polygon by a simple closed curve iff:

, 0, , 1, and , 1.

i i i n n

i i i i j

e v v e v v e v v

e e v i n e e j i

Every simple closed plane

curve divides the plane into two components.

Jordan Curve theorem :

STTP CAD 2011

Page 4: Fundamentals of computational geometry

Fundamentals of computational geometry

Simple Polygon ModelModel the art gallery as a region bounded by some simple polygon (no self-crossing).

Regions with holes are not allowed.

convex polygonone camera an arbitrary n-gon (n vertices)

Bad news: finding the minimum number of cameras for a given polygon is NP-hard (exponential time).STTP CAD 2011

Page 5: Fundamentals of computational geometry

Fundamentals of computational geometry

There are no holes in a simple polygon.

Simple polygon

Nonsimple polygons

STTP CAD 2011

Page 6: Fundamentals of computational geometry

Fundamentals of computational geometry

The Art Gallery ProblemHow many stationary guards are needed to guard a room?

Guards are located at fixed points and have 2π range of visibility. A guard cannot see through walls.

Given a polygon , a point can see a point ( is visiblefrom ) iff [ , ] .

P x y yx x y P

A set of guards covers a polygon if every point of the polygon is visible to some guard.

Problem: Find the max over all n-vertex polygons of the min number of guards needed to cover the polygons.

STTP CAD 2011

Page 7: Fundamentals of computational geometry

Fundamentals of computational geometry

This 12-vertex polygon needs 4 guards to cover it

This 12-vertex polygon needs 3 guards to cover it.

STTP CAD 2011

Page 8: Fundamentals of computational geometry

Fundamentals of computational geometry

- smallest number of guards needed to cover .

min | : covers | .S

g P P

g P S S P

- maximum of over all -vertex polygons.

max .n

n

nP

G n g P n

G n g P

G nWhat is ?

A trivial lower bound:

A trivial upper bound:

1G n

.

Put a guard at each vertex.

G n n

STTP CAD 2011

Page 9: Fundamentals of computational geometry

Fundamentals of computational geometry

What is 3 ?G 3 1.G

What is 4 ?G

4 1. Put a guard on internal diagonal.G

5 1. Put a guard at overlap of triangles.G

STTP CAD 2011

Page 10: Fundamentals of computational geometry

Fundamentals of computational geometry

Hexagons may require two guards, 6 2.G

3 ?G n n Is the conjecture true

A shape with prongs, 3 , is covered by guards.k n k k

12, 4

4n kg P

STTP CAD 2011

Page 11: Fundamentals of computational geometry

Fundamentals of computational geometry

3G n n Proving

First Proof of sufficiency is due to Chvátal in 1975 (very complex). We’ll present a simple, four-step proof by Fisk from 1978.

Necessity follows from the prong’s example.

1. Triangulation of polygon.2. 3-coloring of triangulation graph.3. Placing guards at a single color guarantees cover.4. “Pigeon-hole principle”: placing n objects in k holes, one at

least contains no more than └n/k┘ objects.

STTP CAD 2011

Page 12: Fundamentals of computational geometry

Fundamentals of computational geometry

Diagonals and Triangulation

A diagonal of a polygon is a line segment connecting two visible vertices.

[ , ] is a diagonal of iff:[ , ] , and ( , ) \ .a b Pa b P a b a b P P

Diagonals [ , ] and [ , ] are called noncrossing if ( , ) ( , ) .

a b c da b c d

Triangulation: the partition of a polygon by maximal non crossing diagonals into triangles (not unique!).

STTP CAD 2011

Page 13: Fundamentals of computational geometry

Fundamentals of computational geometry

n=14

Interesting, both triangulations have same number of diagonals!

Notice that number of diagonals equals n-3.

STTP CAD 2011

Page 14: Fundamentals of computational geometry

Fundamentals of computational geometry

3-ColoringG(V,E) is a graph defined on a triangulated polygon P.E consists of P’s edges and the triangulation diagonals, while V consists of P’s vertices.

k-coloring is an assignment of k colors to the vertices of V such that no adjacent vertices have same color.

We’ll show later that a triangulation graph is 3-colorable.

STTP CAD 2011

Page 15: Fundamentals of computational geometry

Fundamentals of computational geometry

545

635

The coloring of a triangulation graph is unique!

Assigning color to first vertex enforces the rest color assignments.

STTP CAD 2011

Page 16: Fundamentals of computational geometry

Fundamentals of computational geometry

Guards Placement

It is sufficient to place guards at one color only (say red).This follows since every triangle must have 3 distinct colors at its corners, hence one must be red. Therefore every triangle is covered.But the triangles cover the entire polygon P.

Pigeon-hole principle: There must be one color whose number

of assigned vertices doesn’t exceed └n/3┘.

3n Conclusion : guards are sufficient.

STTP CAD 2011

Page 17: Fundamentals of computational geometry

Fundamentals of computational geometry

Art-gallery Problem in 3DAn example of a polyhedron with interior points not visible from any vertex.

STTP CAD 2011

Page 18: Fundamentals of computational geometry

Fundamentals of computational geometry

Schönhardt Polyhedron

Schönhardt polyhedron is the smallest non-convex polyhedron which cannot be triangulated into tetrahedra without adding new vertices.

STTP CAD 2011

Page 19: Fundamentals of computational geometry

Fundamentals of computational geometry

Area of Polygons

3Let , , , and ,

, be two vectors. Thearea of the parrallelogramdefined by and is .

a b c b a

c a

Α

B

Α B Α B

R

a b

c

A

B

Determinant

notation:.

y z z y xx y z

x y z z x x z y

x y z x y y x z

A B A B

A A A A B A BB B B A B A B

uu u uu

u

STTP CAD 2011

Page 20: Fundamentals of computational geometry

Fundamentals of computational geometry

2In 0, so the area of a triangle is:12

121 .2

z z

x y y x

x x y y y y x x

x y y x y x x y x y y x

A B T

T A B A B

b a c a b a c a

a b a b a c a c b c b c

R

A

Area of polygons can be found by triangulation and calculation of triangles areas.We’d like to obtain a closed-form formula, independent of triangulation.

STTP CAD 2011

Page 21: Fundamentals of computational geometry

Fundamentals of computational geometry

0 1 2 0 2 3 0 2 1, , , , , ,n nP v v v v v v v v v A A A A

A(P) expression depends on triangulation.We’ll consider first quadrilaterals and show its area is independent of triangulation.

0v 6v

5v

4v3v

2v

1v

7v

P

STTP CAD 2011

Page 22: Fundamentals of computational geometry

Fundamentals of computational geometry

d

ba

c

Q

d

ba

c

Q

, , , , , , , ,Q a b c a c d d a b d b c A A A A A

x y y x y x x y x y y x

x y y x y x x y x y y x

Q a b a b a c a c b c b c

a c a c a d a d c d c d

2A

Diagonal related terms are canceled out!

11 10

For any convex polygon: ni i i ii

P x y x y

2A

STTP CAD 2011

Page 23: Fundamentals of computational geometry

Fundamentals of computational geometry

What happens for non-convex quadrilateral ?

v2

0 1 2 0 3 2

31 10

0

, , , ,

.

The terms involving cancel out.i i i ii

A Q A v v v A v v v

x y x y

v v

v3

v1

v0

Let be a triangle whose vertices arecounterclockwise oriented, and a point in the plane,then , , , , , , .

T abcp

T p a b p b c p c a

Lemma :

A A A A

Q

STTP CAD 2011

Page 24: Fundamentals of computational geometry

Fundamentals of computational geometry

We’d like to obtain the area of a general simple polygon in terms of its vertices only.

0 1 1

1 11 1 10 0

11 10

Let the vertices , , , , ,

be labled counterclockwise, defining a polygon ,and let be an arbitrary point. Then

, ,

n i i i

n ni i i i i ii i

ni i ii

v v v v x y

Pp

P p v v x y x y

x x y y

Theorem :

A A

.i

T

a

b

c

p

STTP CAD 2011

Page 25: Fundamentals of computational geometry

Fundamentals of computational geometry

CONVEX HULLS IN TWO DIMENSIONS

Definitions Basic algorithms

Gift Wrapping (algorithm of Jarvis)Graham scan

Divide and conquer

STTP CAD 2011

Page 26: Fundamentals of computational geometry

Fundamentals of computational geometry

Convexity

A set S is convex if x S and y S implies the segment xy S

x y

STTP CAD 2011

Page 27: Fundamentals of computational geometry

Fundamentals of computational geometry

Definitions of Convex Hull

Convex Hull of a finite set of points S in the plane is the smallest convex polygon P that encloses S which means that there is no other polygon P’ such that S P’ P

Intersection of all convex sets containing the points in S

STTP CAD 2011

Page 28: Fundamentals of computational geometry

Fundamentals of computational geometry

The convex hull of a set of points S in the plane is the union of all the triangles determined by points in S

Informal definition: Convex hull of a set of points in plane is the shape taken by a rubber band stretched around the nails pounded into the plane at each point

Now we define the convex hull problem:- The problem is to construct the boundary of a convex hull in two dimensions given a finite set S of n points- Four outputs can be distinguished for the above problem:

1. all the points on the hull, in arbitrary order;

2. the extreme points, in arbitrary order;3. all the points on the hull, in boundary

traversal order;4. the extreme points, in boundary

traversal order;

STTP CAD 2011

Page 29: Fundamentals of computational geometry

Fundamentals of computational geometry

Extreme Points

The extreme points of a set S of points in the plane are the vertices of the convex hull at which the interior angle is less than π

Also a point is extreme iff there exists a line through that point that other wise does not touch the convex hull

STTP CAD 2011

Page 30: Fundamentals of computational geometry

Fundamentals of computational geometry

Algorithms to find Extreme Points

A] Using Non Extreme Points Identifying non extreme points implies

identifying extreme points A point is non extreme iff it is inside some

(closed) triangle whose vertices are the points of the set and is not itself a corner of that triangle. Thus given a triangle:

If a point is interior to triangle it is non extreme Corners of the triangle might be extreme Thus as the output we will get the extreme points in some arbitrary order.

STTP CAD 2011

Page 31: Fundamentals of computational geometry

Fundamentals of computational geometry

Algorithm: Interior Points

for each i do for each j ≠ i do for each k ≠ i ≠ j do

for each l ≠ k ≠ i ≠ j do if pl Δ(pi ,pj , pk)then pl is nonextreme

• There are four nested loops in this algorithm• Hence the order is O(n4)• For each of the n3 triangles, the test for extremeness

costs n• It is important to find a faster algorithm

STTP CAD 2011

Page 32: Fundamentals of computational geometry

Fundamentals of computational geometry

B] Extreme Edges

An edge is extreme if every point of S is on or to one side of the line determined by the edge

If we treat the edge as directed and let the left side of edge be inside then – the directed edge is not extreme if there is some point that is not left of it or on it

The output of this algorithm will be all the points on the convex hull in arbitrary order

STTP CAD 2011

Page 33: Fundamentals of computational geometry

Fundamentals of computational geometry

Algorithm: Extreme Edges

for each i do for each j ≠ i do

for each k ≠ i ≠ j do if pk is not left or on (pi ,pj)then (pi ,pj) is not extreme

• There are three nested loops in this algorithm• Hence the order is O(n3)• For each of the n2 pair of points, the test for extremeness

costs n• The vertices that are extreme can now be found

STTP CAD 2011

Page 34: Fundamentals of computational geometry

Fundamentals of computational geometry

C] Gift Wrapping (a more realistic hull algorithm)

A minor variation of Extreme Edge algorithm can accelerate it by factor n as well as output the points in order

The idea is to use one extreme edge as an anchor for finding the next

Suppose the algorithm found an extreme edge whose unlinked endpoint is x

θ

y

x

e

• For each y of set S we compute the angle θ

• The point that yields the smallest θ must determine an extreme edge

• The output of this algorithm is all the points on the hull in boundary traversal order

STTP CAD 2011

Page 35: Fundamentals of computational geometry

Fundamentals of computational geometry

Idea: Think of wrapping a gift. Put the paper in contact with the gift and continue to wrap around from one surface to the next until you get all the way around.

STTP CAD 2011

Page 36: Fundamentals of computational geometry

Fundamentals of computational geometry

Algorithm: Gift Wrapping

Find the lowest point (smallest y coordinate)Let i0 be its index, and set i ← i0repeat for each j ≠ i do

compute counterclockwise angle θ from previous hull edgeLet k be the index of the point with the smallest θOutput (pi ,pk) as a hull edgei ← k

until i = i0

• We use the lowest point as the anchor• The order is O(n2)• The cost is O(n) for each hull edge• The point set is wrapped by a string that bends the that bends with

minimum angle from previous to next hull edge

STTP CAD 2011

Page 37: Fundamentals of computational geometry

Fundamentals of computational geometry

Jarvis March - Example

p0

p1

p3

p2

p4

p5

p6

p7

p8

p9

p11

p12

p10

STTP CAD 2011

Page 38: Fundamentals of computational geometry

Fundamentals of computational geometry

Jarvis March - Example

p0

p1

p3

p2

p4

p5

p6

p7

p8

p9

p11

p12

p10

STTP CAD 2011

Page 39: Fundamentals of computational geometry

Fundamentals of computational geometry

Jarvis March - Example

p0

p1

p3

p2

p4

p5

p6

p7

p8

p9

p11

p12

p10

STTP CAD 2011

Page 40: Fundamentals of computational geometry

Fundamentals of computational geometry

Jarvis March - Example

p0

p1

p3

p2

p4

p5

p6

p7

p8

p9

p11

p12

p10

STTP CAD 2011

Page 41: Fundamentals of computational geometry

Fundamentals of computational geometry

Jarvis March - Example

p0

p1

p3

p2

p4

p5

p6

p7

p8

p9

p11

p12

p10

STTP CAD 2011

Page 42: Fundamentals of computational geometry

Fundamentals of computational geometry

Jarvis March - Example

p0

p1

p3

p2

p4

p5

p6

p7

p8

p9

p11

p12

p10

STTP CAD 2011

Page 43: Fundamentals of computational geometry

Fundamentals of computational geometry

Jarvis March - Example

p0

p1

p3

p2

p4

p5

p6

p7

p8

p9

p11

p12

p10

STTP CAD 2011

Page 44: Fundamentals of computational geometry

Fundamentals of computational geometry

Graham Scan - Example

p0

p1

p3

p2

p4

p5

p6

p7

p8

p11

p12

p10

p9

STTP CAD 2011

Page 45: Fundamentals of computational geometry

Fundamentals of computational geometry

Graham Scan - Example

p0

p1

p3

p2

p4

p5

p6

p7

p8

p11

p12

p10

p9

STTP CAD 2011

Page 46: Fundamentals of computational geometry

Fundamentals of computational geometry

Graham Scan - Example

p0

p1

p3

p2

p4

p5

p6

p7

p8

p11

p12

p10

p9

STTP CAD 2011

Page 47: Fundamentals of computational geometry

Fundamentals of computational geometry

Graham Scan - Example

p0

p1

p3

p2

p4

p5

p6

p7

p8

p11

p12

p10

p9

STTP CAD 2011

Page 48: Fundamentals of computational geometry

Fundamentals of computational geometry

Graham Scan - Example

p0

p1

p3

p2

p4

p5

p6

p7

p8

p11

p12

p10

p9

STTP CAD 2011

Page 49: Fundamentals of computational geometry

Fundamentals of computational geometry

Graham Scan - Example

p0

p1

p3

p2

p4

p5

p6

p7

p8

p11

p12

p10

p9

STTP CAD 2011

Page 50: Fundamentals of computational geometry

Fundamentals of computational geometry

Graham Scan - Example

p0

p1

p3

p2

p4

p5

p6

p7

p8

p11

p12

p10

p9

STTP CAD 2011

Page 51: Fundamentals of computational geometry

Fundamentals of computational geometry

Graham Scan - Example

p0

p1

p3

p2

p4

p5

p6

p7

p8

p9

p11

p12

p10

STTP CAD 2011

Page 52: Fundamentals of computational geometry

Fundamentals of computational geometry

Graham Scan - Example

p0

p1

p3

p2

p4

p5

p6

p7

p8

p9

p11

p12

p10

STTP CAD 2011

Page 53: Fundamentals of computational geometry

Fundamentals of computational geometry

Graham Scan - Example

p0

p1

p3

p2

p4

p5

p6

p7

p8

p9

p11

p12

p10

STTP CAD 2011

Page 54: Fundamentals of computational geometry

Fundamentals of computational geometry

Graham Scan - Example

p0

p1

p3

p2

p4

p5

p6

p7

p8

p9

p11

p12

p10

STTP CAD 2011

Page 55: Fundamentals of computational geometry

Fundamentals of computational geometry

Graham Scan - Example

p0

p1

p3

p2

p4

p5

p6

p7

p8

p9

p11

p12

p10

STTP CAD 2011

Page 56: Fundamentals of computational geometry

Fundamentals of computational geometry

Graham Scan - Example

p0

p1

p3

p2

p4

p5

p6

p7

p8

p9

p11

p12

p10

STTP CAD 2011

Page 57: Fundamentals of computational geometry

Fundamentals of computational geometry

Convex Hull - Divide and Conquer

Algorithm: Find a point with a median x

coordinate (time: O(n)) Compute the convex hull of

each half (recursive execution) Combine the two convex hulls

by finding common tangents.Can be done in O(n)

)(2

2)( nOnTnT

Complexity: O(nlogn)

STTP CAD 2011

Page 58: Fundamentals of computational geometry

Fundamentals of computational geometry

Voronoi Diagram

STTP CAD 2011

Page 59: Fundamentals of computational geometry

Fundamentals of computational geometry

Formal Definition

P A set of n distinct points in the plane.

VD(P) a subdivision of the plane into n cells such that

each cell contains exactly one site, if a point q lies in a cell containing pi then d(q, pi ) < d(q, pj ) for all pi P, j i.

In other words, given a set P of points in 2D, VD(P) is a partition of the plane into n convex regions {R1, R2, …, Rn}, each (Ri) containing exactly one member (pi) in P such that for each point in Ri, its nearest member in P is pi

STTP CAD 2011

Page 60: Fundamentals of computational geometry

Fundamentals of computational geometry

Voronoi diagram (illustration)

P1 P2

B(P

1,P 2

)

P1P2

P3B(P1,P3)

B(P1,P2)

B(P2,P

3)

Remember that VD is notdefined for just points but for any set e.g. curves, surfaces etc. Moreover, the definition is applicable for any dimension.

STTP CAD 2011

Page 61: Fundamentals of computational geometry

Fundamentals of computational geometry

Characteristics of the Voronoi Diagram

Each vertex (corner) of VD(P) has degree 3

The circle through the three points defines a vertex of the Voronoi diagram, and it does not contain any other point

The locus of the center of a largest empty circles passing through only a pair of points pi, pj P defines an edge

The locus of the center of largest empty circles passing through only one points in P defines a cell

The Voronoi region of a point is unbounded if and only if the point is a vertex of the convex hull of the point set.

Assumption: No 4 points are co-circular.

STTP CAD 2011

Page 62: Fundamentals of computational geometry

Fundamentals of computational geometry

Use of Voronoi Diagram

Search for nearest neighbourInput: A fixed (static) set P of

n points in the plane, and a query point p

Output: Nearest neighbour of p in P

Solution• Construct the Voronoi diagram

for P in time O(n log n)

• Solve the point location problem in O(log n) time.

STTP CAD 2011

Page 63: Fundamentals of computational geometry

Fundamentals of computational geometry

Use of Voronoi Diagram (contd.)

Closest pair of points: Inspect all the edges list of Vor(P) and determine the minimally separated pair

Largest empty circle: Each Voronoi vertex represents the center of a maximal emptycircle. Find one having maximum radius.

Computing Euclidian Minimum Spanning Tree: Compute dual of the Voronoi diagram, and applyKruskal’s algorithm for computing the minimum Spanning tree.

STTP CAD 2011

Page 64: Fundamentals of computational geometry

Fundamentals of computational geometry

Furthest Point Voronoi Diagram

V-1(pi) : the set of point of the plane farther from pi than from any other site

Vor-1(P) : the partition of the plane formed by the farthest point Voronoi regions, their edges, and vertices

STTP CAD 2011

Page 65: Fundamentals of computational geometry

Fundamentals of computational geometry

Order-2 Voronoi diagram

V(pi,pj) : the set of points of the plane closer to each of pi and pj

than to any other site

Property The order-2 Voronoi regions are convex

STTP CAD 2011

Page 66: Fundamentals of computational geometry

Fundamentals of computational geometry

Voronoi diagram of weighted points

S Set of points in 2D

w(p) weight attached with the point p S

dw(x,p) = de(x,p)/w(p) weighted distance of a point x from p S

Weighted Voronoi diagram WVD(S) the subdivision of the plane such that

region(p) = {x : dw(x,p) < dw(x,q) q S

Thus, a point having large weight will cover bigger space

STTP CAD 2011

Page 67: Fundamentals of computational geometry

Fundamentals of computational geometry

Voronoi diagram for line segments

Voronoi edges: These are formed with line segments and/or parabolic arcs.

Straight line edges are part of either the perpendicular bisector of two segment end-points or the angular bisector or two segments.

Curve edges consist of points equidistant from a segment end-point and a segment’s interior.

STTP CAD 2011

Page 68: Fundamentals of computational geometry

Fundamentals of computational geometry

Nearest site proximity partitioning of the plane

Voronoi Diagram & Delaunay Triangulation

STTP CAD 2011

Page 69: Fundamentals of computational geometry

Fundamentals of computational geometry

Voronoi Diagram & Delaunay Triangulation

STTP CAD 2011

Page 70: Fundamentals of computational geometry

Fundamentals of computational geometry

Skeleton – Medial Axis

The medial axis (MA), or skeleton of the set D, is defined as the locus of points inside which lie at the centers of all closed discs (or balls in 3-D) which are maximal in D.

STTP CAD 2011

Page 71: Fundamentals of computational geometry

Fundamentals of computational geometry

Exercises Art-gallery problem for

orthogonal polygon

STTP CAD 2011

smallest circle that completely encloses a set of points

Relation between MA and VD for a) convex and b) non-convex polygons.

Page 72: Fundamentals of computational geometry

Fundamentals of computational geometry

Web resources and books www.cs.iastate.edu/~cs518/handouts/art-gallery.ppt www.tcs.tifr.res.in/~igga/lectureslides/vor-July-08-2009.

ppt in2.csie.ncu.edu.tw/~jrjiang/alg2008/Voronoi.ppt www.cse.ttu.edu.tw/~jmchen/compg/slides/voro-apps.

ppt www.cse.yorku.ca/~andy/courses/4101/Slides/CG-Intro

.pptx Joseph O’Rourke, Computational Geometry in C,

Second edition, Cambridge university press, 1998 Joseph O’Rourke, Art Gallery theorems and

algorithms, Oxford university press, 1987

STTP CAD 2011