Convex Hulls in 3-space

41
October 7, 2003 Lecture 10: Convex Hulls in 3D 1 / 41 Convex Hulls in 3-space (slides mostly by Jason C. Yang)

description

Convex Hulls in 3-space. (slides mostly by Jason C. Yang). Problem Statement. Given P : set of n points in 3D Return: Convex hull of P : CH ( P ) , i.e. smallest polyhedron s.t. all elements of P on or in the interior of CH ( P ). Complexity. - PowerPoint PPT Presentation

Transcript of Convex Hulls in 3-space

Page 1: Convex Hulls in 3-space

October 7, 2003 Lecture 10: Convex Hulls in 3D 1 / 41

Convex Hullsin 3-space

(slides mostly by Jason C. Yang)

Page 2: Convex Hulls in 3-space

October 7, 2003 Lecture 10: Convex Hulls in 3D 2 / 41

Problem Statement

• Given P: set of n points in 3D

• Return:– Convex hull of P: CH(P), i.e. smallest polyhedron s.t.

all elements of P on or inthe interior of CH(P).

Page 3: Convex Hulls in 3-space

October 7, 2003 Lecture 10: Convex Hulls in 3D 3 / 41

• Complexity of CH for n points in 3D is O(n)

• ..because the number of edges of a convex polytope with n vertices is at most 3n-6 and the number of facets is at most 2n-4

• ..because the graph defined by vertices and edges of a convex polytope is planar

• Euler’s formula: n – ne + nf = 2

Complexity

Page 4: Convex Hulls in 3-space

October 7, 2003 Lecture 10: Convex Hulls in 3D 4 / 41

Complexity

• Each face has at least 3 arcs• Each arc incident to two faces

2ne 3nf

• Using Eulernf 2n-4 ne 3n-6

Page 5: Convex Hulls in 3-space

October 7, 2003 Lecture 10: Convex Hulls in 3D 5 / 41

Algorithm

• Randomized incremental algorithm

• Steps:– Initialize the algorithm– Loop over remaining points

Add pr to the convex hull of Pr-1 to transform CH(Pr-1) to CH(Pr)

[for integer r1, let Pr:={p1,…,pr} ]

Page 6: Convex Hulls in 3-space

October 7, 2003 Lecture 10: Convex Hulls in 3D 6 / 41

Initialization

• Need a CH to start with• Build a tetrahedron using 4 points in P

– Start with two distinct points in P, say, p1 and p2

– Walk through P to find p3 that does not lie on the line through p1 and p2

– Find p4 that does not lie on the plane through p1, p2, p3

– Special case: No such points exist? Planar case!

• Compute random permutation p5,…,pn of the remaining points

Page 7: Convex Hulls in 3-space

October 7, 2003 Lecture 10: Convex Hulls in 3D 7 / 41

Inserting Points into CH• Add pr to the convex hull of Pr-1 to

transform CH(Pr-1) to CH(Pr)• Two Cases:

1) Pr is inside or on the boundary of CH(Pr-1)– Simple: CH(Pr) = CH(Pr-1)

2) Pr is outside of CH(Pr-1) – the hard case

Page 8: Convex Hulls in 3-space

October 7, 2003 Lecture 10: Convex Hulls in 3D 8 / 41

Case 2: Pr outside CH(Pr-1)

• Determine horizon of pr on CH(Pr-1)– Closed curve of edges enclosing the visible

region of pr on CH(Pr-1)

Page 9: Convex Hulls in 3-space

October 7, 2003 Lecture 10: Convex Hulls in 3D 9 / 41

Visibility

• Consider plane hf containing a facet f of CH(Pr-1)

• f is visible from a point p if that point lies in the open half-space on the other side of hf

Page 10: Convex Hulls in 3-space

October 7, 2003 Lecture 10: Convex Hulls in 3D 10 / 41

Rethinking the Horizon

– Boundary of polygon obtained from projecting CH(Pr-1) onto a plane with pr as the center of projection

Page 11: Convex Hulls in 3-space

October 7, 2003 Lecture 10: Convex Hulls in 3D 11 / 41

CH(Pr-1) CH(Pr)

• Remove visible facets from CH(Pr-1)• Found horizon: Closed curve of edges of CH(Pr-1)

• Form CH(Pr) by connecting each horizon edge to pr to create a new triangular facet

Page 12: Convex Hulls in 3-space

October 7, 2003 Lecture 10: Convex Hulls in 3D 12 / 41

Algorithm So Far…

• Initialization– Form tetrahedron CH(P4) from 4 points in P– Compute random permutation of remaining pts.

• For each remaining point in P– pr is point to be inserted

– If pr is outside CH(Pr-1) then• Determine visible region• Find horizon and remove visible facets• Add new facets by connecting each horizon edge to pr

How do we determine the visible region?

Page 13: Convex Hulls in 3-space

October 7, 2003 Lecture 10: Convex Hulls in 3D 13 / 41

How to Find Visible Region

• Naïve approach:– Test every facet with respect to pr

– O(n2) work

• Trick is to work ahead:Maintain information to aid in determining

visible facets.

Page 14: Convex Hulls in 3-space

October 7, 2003 Lecture 10: Convex Hulls in 3D 14 / 41

Conflict Lists

• For each facet f maintainPconflict(f) {pr+1, …, pn}containing points to be inserted that can see f

• For each pt, where t > r, maintain Fconflict(pt) containing facets of CH(Pr) visible from pt

• p and f are in conflict because they cannot coexist on the same convex hull

Page 15: Convex Hulls in 3-space

October 7, 2003 Lecture 10: Convex Hulls in 3D 15 / 41

Conflict Graph G• Bipartite graph

– pts not yet inserted– facets on CH(Pr)

• Arc for every point-facet conflict

• Conflict sets for a point or facet can be returned in linear time

At any step of our algorithm, we know all conflicts between the remaining points and facets on the current CH

Page 16: Convex Hulls in 3-space

October 7, 2003 Lecture 10: Convex Hulls in 3D 16 / 41

Initializing G

• Initialize G with CH(P4) in linear time

• Walk through P5-n to determine which facet each point can see

f1f2

p6

p5

p7

p6

p7

p5

f2

f1

G

Page 17: Convex Hulls in 3-space

October 7, 2003 Lecture 10: Convex Hulls in 3D 17 / 41

Updating G• Discard visible facets from pr by removing

neighbors of pr in G• Remove pr from G• Determine new conflicts

p6

p7

p5

f2

f1

G

f1

f2

f3

f3

p6

p7

p5

f2

f1

G

p6

p7

p5

f2

f1

G

p5

p7

p6

Page 18: Convex Hulls in 3-space

October 7, 2003 Lecture 10: Convex Hulls in 3D 18 / 41

Determining New Conflicts• If pt can see new f, it can see edge e of f.• e on horizon of pr, so e was already in and

visible from pt in CH(Pr-1)

• If pt sees e, it saw either f1 or f2 in CH(Pr-1)

• Pt was in Pconflict(f1) or Pconflict(f2) in CH(Pr-1)pt

Page 19: Convex Hulls in 3-space

October 7, 2003 Lecture 10: Convex Hulls in 3D 19 / 41

Determining New Conflicts

• Conflict list of f can be found by testing the points in the conflict lists of f1 and f2 incident to the horizon edge e in CH(Pr-1)

pt

Page 20: Convex Hulls in 3-space

October 7, 2003 Lecture 10: Convex Hulls in 3D 20 / 41

What About the Other Facets?

• Pconflict(f) for any f unaffected by pr remains unchanged

pt

• Pconflict(f) for any f unaffected by pr remains unchanged

• Deleted facets not on horizon already accounted for

Page 21: Convex Hulls in 3-space

October 7, 2003 Lecture 10: Convex Hulls in 3D 21 / 41

Final Algorithm

• Initialize CH(P4) and G• For each remaining point

– Determine visible facets for pr by checking G– Remove Fconflict(pr) from CH– Find horizon and add new facets to CH and G– Update G for new facets by testing the points in

existing conflict lists for facets in CH(Pr-1) incident to e on the new facets

– Delete pr and Fconflict(pr) from G

Page 22: Convex Hulls in 3-space

October 7, 2003 Lecture 10: Convex Hulls in 3D 22 / 41

Fine Point

• Coplanar facets– pr lies in the plane of a face of CH(Pr-1)

• f is not visible from pr so we merge created triangles coplanar to f

• New facet has same conflict list as existing facet

Page 23: Convex Hulls in 3-space

October 7, 2003 Lecture 10: Convex Hulls in 3D 23 / 41

Analysis

Page 24: Convex Hulls in 3-space

October 7, 2003 Lecture 10: Convex Hulls in 3D 24 / 41

Expected Number of Facets Created

• Will show that expected number of facets created by our algorithm is at most 6n-20

• Initialized with a tetrahedron = 4 facets

Page 25: Convex Hulls in 3-space

October 7, 2003 Lecture 10: Convex Hulls in 3D 25 / 41

Expected Number of New Facets

• Backward analysis:– Remove pr from CH(Pr)– Number of facets removed same as those

created by pr

– Number of edges incident to pr in CH(Pr) is degree of pr:

deg(pr, CH(Pr))

Page 26: Convex Hulls in 3-space

October 7, 2003 Lecture 10: Convex Hulls in 3D 26 / 41

Expected Degree of pr

• Convex polytope of r vertices has at most 3r-6 edges• Sum of degrees of vertices of CH(Pr) is 6r-12

• Expected degree of pr bounded by (6r-12)/r

Page 27: Convex Hulls in 3-space

October 7, 2003 Lecture 10: Convex Hulls in 3D 27 / 41

Expected Number of Created Facets

• 4 from initial tetrahedron• Expected total number of facets created by

adding p5,…,pn

Page 28: Convex Hulls in 3-space

October 7, 2003 Lecture 10: Convex Hulls in 3D 28 / 41

Running Time

• Initialization O(nlogn)• Creating and deleting facets O(n)

– Expected number of facets created is O(n)

• Deleting pr and facets in Fconflict(pr) from G along with incident arcs O(n)

• Finding new conflicts O(?)

Page 29: Convex Hulls in 3-space

October 7, 2003 Lecture 10: Convex Hulls in 3D 29 / 41

Total Time to Find New Conflicts

• For each edge e on horizon we spendO(|P(e|) time

where P(e) =Pconfict(f1)Pconflict(f2)

• Total time is O(eL |P(e)|)

• Lemma 11.6 The expected value of e|P(e)|, where the summation is over all horizon edges that appear at some stage of the algorithm is O(nlogn)

Page 30: Convex Hulls in 3-space

October 7, 2003 Lecture 10: Convex Hulls in 3D 30 / 41

Randomized Insertion Order

Page 31: Convex Hulls in 3-space

October 7, 2003 Lecture 10: Convex Hulls in 3D 31 / 41

Running Time

• Initialization O(nlogn)• Creating and deleting facets O(n)• Updating G O(n)• Finding new conflicts O(nlogn)

• Total Running Time is O(nlogn)

Page 32: Convex Hulls in 3-space

October 7, 2003 Lecture 10: Convex Hulls in 3D 32 / 41

Convex Hulls in Dual Space

• Upper convex hull of a set of points is essentially the lower envelope of a set of lines (similar with lower convex hull and upper envelope)

Page 33: Convex Hulls in 3-space

October 7, 2003 Lecture 10: Convex Hulls in 3D 33 / 41

Half-Plane Intersection

• Convex hulls and intersections of half planes are dual concepts

• An algorithm to compute the intersection of half-planes can be given by dualizing a convex hull algorithm. Is this true?

Page 34: Convex Hulls in 3-space

October 7, 2003 Lecture 10: Convex Hulls in 3D 34 / 41

Half-Plane Intersection

• Duality transform cannot handle vertical lines• If we do not leave the Euclidean plane, there cannot be any

general duality that turns the intersection of a set of half-planes into a convex hull. Why?

Intersection of half-planes can be empty!And Convex hull is well defined.

Conditions for duality:Intersection is not emptyPoint in the interior is known.

• Duality transform cannot handle vertical lines• If we do not leave the Euclidean plane, there cannot be any

general duality that turns the intersection of a set of half-planes into a convex hull. Why?

Intersection of half-planes can be empty!And Convex hull is well defined.

• Conditions for duality:– Intersection is not empty– Point in the interior is known.

Page 35: Convex Hulls in 3-space

October 7, 2003 Lecture 10: Convex Hulls in 3D 35 / 41

Voronoi Diagrams Revisited

• U:=(z=x2+y2)a paraboloid

• p is point on plane z=0• h(p) is non-vert plane

z=2pxx+2pyy-(p2x+p2

y)• q is any point on z=0• vdist(q',q(p)) = dist(p,q)2

• h(p) and paraboloid encodes any distance p to any point on z=0

Page 36: Convex Hulls in 3-space

October 7, 2003 Lecture 10: Convex Hulls in 3D 36 / 41

Voronoi Diagrams

• H:={h(p) | p P}• UE(H) upper envelope of the planes in H• Projection of UE(H) on plane z=0 is

Voronoi diagram of P

Page 37: Convex Hulls in 3-space

October 7, 2003 Lecture 10: Convex Hulls in 3D 37 / 41

Simplified Case

Page 38: Convex Hulls in 3-space

October 7, 2003 Lecture 10: Convex Hulls in 3D 38 / 41

Demo

• http://www.cse.unsw.edu.au/~lambert/java/3d/delaunay.html

Page 39: Convex Hulls in 3-space

October 7, 2003 Lecture 10: Convex Hulls in 3D 39 / 41

Delaunay Triangulations from CH

Page 40: Convex Hulls in 3-space

October 7, 2003 Lecture 10: Convex Hulls in 3D 40 / 41

Higher Dimensional Convex Hulls

• Upper Bound Theorem:The worst-case combinatorial complexity

of the convex hull of n points in d-dimensional space is (n d/2).

• Our algorithm generalizes to higher dimensions with expected running time of (nd/2)

Page 41: Convex Hulls in 3-space

October 7, 2003 Lecture 10: Convex Hulls in 3D 41 / 41

Higher Dimensional Convex Hulls

• Best known output-sensitive algorithm for computing convex hulls in Rd is:

O(nlogk +(nk)1-1/(d/2+1)logO(n))where k is complexity