CSE 4101/5101

46
CSE 4101/5101 Prof. Andy Mirzaian

description

CSE 4101/5101. Prof. Andy Mirzaian. Computational Geometry. Overview. Computational Geometry: Study of algorithms, data structures, and computational complexity of computational problems in geometry. Dimension: 1 2 3 … d … Objects: Finitely specifiable points - PowerPoint PPT Presentation

Transcript of CSE 4101/5101

Page 1: CSE 4101/5101

CSE 4101/5101

Prof. Andy Mirzaian

Page 2: CSE 4101/5101

2

Overview

Page 3: CSE 4101/5101

3

Computational Geometry:Study of algorithms, data structures, and computational complexity of computational problems in geometry.

Dimension: 1 2 3 … d …

Objects: Finitely specifiable• points• lines ( line segments, rays, oriented, …)• circles ( conics )• polygons• …

Computational Model & Primitive operations: • real-RAM (Random Access Machine with exact real arithmetic)• Arithmetic: + - • Comparison: = < > • Logic: not and or• other: sin cos … ( as little as possible)

Page 4: CSE 4101/5101

4

Landscape of Computational Geometry

Applications:• Graphics• Robotics• Vision • GIS• CAD• VLSI• Pattern Recognition• Optimization• Transportation• Statistics • . . .

Geometric Tools:• Convex Hull• Space subdivision• Arrangements• Voronoi / Delaunay Diagram• Triangulations• Geometric Transforms• Duality • . . .

Algorithmic Tools:• general • incremental• divide-&-conquer• space sweep• topological sweep• prune and search• random sampling• locus approach• multidimensional search• dynamization• . . .

Data Structures: • general• interval trees • range trees • segment trees• priority search trees• K-d trees• fractional cascading• persistent D.S. • . . .

Analysis Tools:• general• amortization• Davenport-Schinzel• . . .

Implementation Issues:• Degeneracy (symbolic perturbation) • Robustness (inexact arithmetic) • . . .

Page 5: CSE 4101/5101

5

Example 1: Convex Hull

Page 6: CSE 4101/5101

6

Example 1: Convex Hull

Page 7: CSE 4101/5101

7

Example 2: Point set triangulation

Page 8: CSE 4101/5101

8

Example 2: Point set triangulation

Page 9: CSE 4101/5101

9

Non-simple Simple Convex

Example 3: Simple PolygonPolygon: A closed curve in the plane consisting of finitely many straight segments.Simple Polygon: A connected non-self-crossing polygon.Convex Polygon: A simple polygon with no interior angle exceeding 180°.

Page 10: CSE 4101/5101

10

Example 3: Simple Polygon Triangulation

Page 11: CSE 4101/5101

11

Example 4: Planar Line Arrangement

Page 12: CSE 4101/5101

12

Example 4: Planar Line Arrangement

Page 13: CSE 4101/5101

13

Example 5: Voronoi Diagram & Delaunay Triangulation

Page 14: CSE 4101/5101

14Nearest site proximity partitioning of the plane

Example 5: Voronoi Diagram & Delaunay Triangulation

Page 15: CSE 4101/5101

15

Delaunay Triangulation = Dual of the Voronoi Diagram.

Example 5: Voronoi Diagram & Delaunay Triangulation

Page 16: CSE 4101/5101

16

Delaunay triangles have the “empty circle” property.

Example 5: Voronoi Diagram & Delaunay Triangulation

Page 17: CSE 4101/5101

17

Example 5: Voronoi Diagram & Delaunay Triangulation

Page 18: CSE 4101/5101

18

x

z

y

z=x2+y2

Example 6: 2D Delaunay Triangulation via 3D Convex Hull

Page 19: CSE 4101/5101

19

D

A

B

C

D

A

B

C

Applications:• Graphics• Multi-window user systems• …

E E

Example 7: Hidden Surface Removal

Page 20: CSE 4101/5101

20

Koebe-Andreev-Thurston’s Circle Packing Theorem: [1]

Any planar graph can be drawn in the plane withvertices as centers of non-overlapping circles, such that edge between two vertices the two circles touch.

Applications: CAD, VLSI, Graphics, …

Example 8: Planar Graph Drawing

Page 21: CSE 4101/5101

21

Geometric Preliminaries

Page 22: CSE 4101/5101

22

Metric Space (S,d)

S = a set of objects called “points” of the space, d: S2 called the distance metric

Metric Axioms: (x,y,z S)

1. d(x,y) 0 (non-negativity) 2. d(x,y) = 0 x=y (positive definiteness) 3. d(x,y) = d(y,x) (symmetry) 4. d(x,y) + d(y,z) d(x,z) (triangle inequality)

Page 23: CSE 4101/5101

23

d = d-dimensional real spaceis the set of d-vectors x=(x1,x2, … ,xd)d, xi (for i=1..d).

d forms a vector space, i.e., it is closed under:

• scaling: x = (x1, x2, … ,xd) d , .

• addition: x+y = (x1+y1, x2+y2, … , xd+yd) d.

x1 x2

x3

3

Page 24: CSE 4101/5101

24

Normed space Inner product of two vectors x and y: x , y . x , x 0 (with equality x=0) x , y = y , x x , y = x , y

Norm of a vector x: ||x|| = x , x ½ . Distance between vectors x,y: d(x,y) = || x – y || ||.|| is a metric norm if d(x,y) = || x – y || forms a metric.

Example: dot-product x , y = xTy = x1y1+ x2y2+ … + xdyd defines Euclidean norm ||x|| = (|x1|2 + |x2|2 + … + |xd|2)1/2

Page 25: CSE 4101/5101

25

Unit Ball of Norm: Unit Ball of the norm ||.|| is B = { xd | ||x|| 1} & satisfies:

B is symmetric about the origin, i.e., xB -xB. B is convex B is closed, bounded, and has nonempty interior.

Conversely, norm can be defined in terms of the unit ball:||x|| = min { 0 | x B } B = { y | yB }

x

-1xO

B ||x||=

B

Page 26: CSE 4101/5101

26

Minkowski Metric Lp (1 p )

|| x ||p = (|x1|p + |x2|p + … + |xd|p)1/p

dp(x,y) = || x-y ||p = (|x1 –y1|p + … + |xd –yd|p)1/p

Example:L2 : (Ed : Euclidean) ||x||2 = (|x1|2 + |x2|2 + … + |xd|2)1/2

L1 : (Manhattan) ||x||1 = (|x1| + |x2| + … + |xd|)

L : ||x|| = max { |x1| , |x2| , … , |xd| }

Page 27: CSE 4101/5101

27

Unit Ball of Minkowski Metric Lp

2

p=1p=2

p=3

p=

Minkowski metric is indeed a metric:

The triangle inequality is known as the Minkowski inequality [1]It is obtained from the Holder inequality [2]

Page 28: CSE 4101/5101

28

points q1 , q2 , … , qk d

coefficients 1 , 2 , … , k

Linear combination: p = i iqi = 1q1+2q2+ … +kqk (this is a vector sum)

Affine combination: p = i iqi = 1q1+2q2+ … +kqk s. t. i i =1

Convex combination: p = i iqi = 1q1+2q2+ … +kqk s. t. i i =1 & i0

Linear, affine & convex combinations

Page 29: CSE 4101/5101

29

Example: d=3, k=2

x1x2

x3

3

q1

q2

OLinear combinations:span(q1,q2) = {1q1+2q2 | 1 ,2 }

= plane(O,q1,q2)

Affine combinations:aff(q1,q2) = { q1+(1-)q2 | }

= line q1q2

Convex combinations:conv(q1,q2) = { q1+(1-)q2 | 0 1 }

= line segment q1q2

conv(q1,q2,q3) = triangle q1q2q3

q1

q2

=1

0 1 =0

<0

>1

q2

q1

q3r

p

Page 30: CSE 4101/5101

30

x

y

p1

p2

p3

> 0 (p1 p2 p3 ) counter-clockwise (CCW), i.e., left turn

< 0 (p1 p2 p3 ) clockwise (CW), i.e., right turn

= 0 (p1 p2 p3 ) collinear

½ | | = area of triangle (p1 p2 p3)

-test: consider 3 points pi = (xi,yi)2, i=1,2,3

1yx1yx1yx

det )pp(p

33

22

11

321

Page 31: CSE 4101/5101

31

Consider d+1 points pi = (xi1,…,xid) d, i=1..d+1.

|| /d! = volume of d-simplex (p1 ,p2 …,pd+1).

sign() = orientation of d-simplex (p1 ,p2 …,pd+1).

-test in higher dimensions:

1..

.

...

.

.11

det)pp(p

d1,d21,d1,1d

d22221

d11211

1d21

xxx

xxxxxx

Page 32: CSE 4101/5101

32

1. Polar angle comparison: (0i<) 1 2 (O,p1,p2) 0 [no need to compute trigonometric functions]

p1

p2

O1 2

Cont’d

Some applications of -test

p1

q1

p2

q2

3. Open line-segment crossing: p1p2 q1q2 (p1,p2,q1) (p1,p2,q2) < 0

and (q1,q2,p1) (q1,q2,p2) < 0

pr1

r2q

2. In-sector test: q sector(p,r1,r2) q is left of r1 and right of r2. (assume r2 is CCW from r1 about p.)

Page 33: CSE 4101/5101

33

(y1 - y2) x – (x1- x2) y + x1 y2 - x2 y1 = 0

a b c

(x1,y1)

(x2,y2)

(x,y)

collinear points

Some special cases:• non-vertical (b0; divide by b): y = x + • vertical (a0, b=0; divide by a): x =

01yx1yx1yx

det )pp(p 22

11

321

4. Line equation in 2D (ax+by+c=0)

Page 34: CSE 4101/5101

34

Simple Polygons

Page 35: CSE 4101/5101

35

Area of a simple polygon P=(p1,p2, …, pn)

FACT: 2A(P) = (O, pi ,pi+1) = (xi yi+1 – xi+1 yi ) = xi(yi+1 – yi-1)

O

pi

pi+1

P

x

y

i=1 i=1 i=1

n n n

(where O = origin, pn+1 = p1 , p0 = pn )

Algebraic area A(P) A(P) > 0 if P is CCW, A(P) < 0 if P is CW

Geometric area Area(P) = |A(P)|

Page 36: CSE 4101/5101

36

A Jordan Curve is any closed non-self-crossing curve in the plane.

Jordan Curve

Jordan Curve Theorem: Any Jordan curve J partitions the plane into two regions,and J is their common boundary. The bounded region is called the interior of J.The unbounded region is called the exterior of J.

Page 37: CSE 4101/5101

37

Input: Simple n-gon P & query point q.Query: Is q inside P?

q

P

Point in Polygon Inclusion Problem

Page 38: CSE 4101/5101

38

q

P

In O(n) time shoot a ray out of q and count “proper” boundary crossings with P.

Point in Polygon Inclusion Problem

Page 39: CSE 4101/5101

39

q

P

In O(n) time shoot a ray out of q and count “proper” boundary crossings with P.

Point in Polygon Inclusion Problem

Page 40: CSE 4101/5101

40

q

Degenerate cases:How to count if ray passes through a vertex of the polygon?

q

Answer: implicit and slight ray perturbation:

Point in Polygon Inclusion Problem

Page 41: CSE 4101/5101

41

Can we solve the problem in sub-linear time if P is convex?

p1

p2

pn

pn-1

Step 1: Is q in sector p1 pn pn-1?If not, then return “outside”

pnp1

pn-1

(O(1) time. Use -test.)

Step 3: j=i+1. q is inside P qpn does not cross pip i+1 . (O(1) time.)

pi

pi+1

pn

q

Step 2: Binary search. q is in sector pi pn pj, 0<i<j<n.Let m = (i+j)/2. Is q to the left of pnpm? Update i or j to m accordingly. Repeat until j=i+1. (O(log n) time.)

pi

pj

pm

pn

Point in Polygon Inclusion Problem

Answer: Yes, in O(log n) time by “binary Search”.

Page 42: CSE 4101/5101

42

Exercises

Page 43: CSE 4101/5101

43

1. Show the following relationships hold for Minkowski norms in the plane:

In general, how do these Minkowski norms compare in d ?[See the CSE6118: Lecture Slide 6 for a more general result.]

2. We are given a triangle T = t1, t2, t3 by its 3 vertices in counter-clockwise order and a query point q, all in the plane. Give a simple O(1) time test to determine whether T contains q (inside or on its boundary). [Simplify your test “formula” as much as you can.]

3. We are given a sequence P = p1, p2, … , pn of n points in the plane purported to be the vertices of a convex polygon in counter-clockwise order around its boundary. Give an efficient verification algorithm that P indeed represents such a polygon.

4. We are given a convex polygon P with n vertices. Devise efficient algorithms to find(a) the largest circle inside P,(b) the largest axis-parallel square inside P,(c) the largest arbitrarily oriented square inside P.[Revisit this after we study Voronoi Diagrams and Delaunay Triangulations.]

.||||||||||||||||||||212

22 22

xxxxxx

Page 44: CSE 4101/5101

44

5. Let P be a given simple polygon with n vertices and q a given point inside P. For an arbitrary ray r that emanates from q, let CN(r, q, P) denote the crossing number of r, i.e., the number of edges of P crossed by ray r. Define Depth(q, P) to be the minimum CN(r, q, P) over all rays r emanating from q.

Devise an efficient algorithm to compute Depth(q,P).

6. Let P be an arbitrary simple polygon.(a) Show that there exists a square S that contains P and all 4 sides of S touch P. (A corner of S belongs to its both incident sides.) [Hint: the smallest bounding box of P at an arbitrary rotational orientation is a rectangle. We want a square. Continuously rotate the bounding box.](b) Prove or disprove: there exists a square with all 4 corners on P. [This is hard.]

Page 45: CSE 4101/5101

45

7. We are given a set S of n pairwise disjoint line-segments in the plane. A J-walk of S is a Jordan curve that passes through the 2n endpoints of the segments in S, and contains each (open) segment of S either completely on its boundary, or completely in its interior, or completely in its exterior. A J-walk that is a polygon with exactly 2n vertices is called a P-walk of S. (See the figure below.) If a J-walk contains all segments of S on its boundary, then it is called a J-traversal. A P-walk whose (open) exterior is void of any segment of S is called a circumscribing P-walk.

(a) Show that S has a J-traversal. [Hint: use induction.](b) Show that S has a J-traversal that is a polygon with O(n) vertices?

[Hint: Extend each segment of S (in some arbitrary order) from both sides until it hits (the extension of) another segment. Now the plane is divided into O(n) convex regions. Navigate through these regions.]

(c) Show that S has a P-walk. [Harder. Use the above hint.](d) Devise an efficient algorithm to construct a P-walk of S. (e) Show that the instance below-left has no circumscribing P-walk.

Page 46: CSE 4101/5101

46

END