Skeletons from freeform - Department of Engineering Design

Download Report

Transcript Skeletons from freeform - Department of Engineering Design

M. Ramanathan
STTP CAD 2011
Fundamentals of computational geometry
camera
How many cameras are needed to guard a gallery and
How should they be placed?
STTP CAD 2011
Fundamentals of computational geometry
v0 , v1,
,vn1, vn1 vertices of an n-vertex polygon.
Edges e0  v0 v1 ,
, ei  vi vi 1 ,
, en 1  vn 1v0 are
bounding a polygon by a simple closed curve iff:
ei
ei 1  vi 1 , i  0,
, n  1, and ei
e j  , j  i  1.
Jordan Curve theorem : Every simple closed plane
curve divides the plane into two components.
STTP CAD 2011
Fundamentals of computational geometry
Model the art gallery as a region bounded by some simple
polygon (no self-crossing).
Regions with holes are not allowed.
convex polygon
one camera
an arbitrary n-gon (n vertices)
Bad news: finding the minimum number of cameras for a
STTP CAD 2011
Fundamentals
of computational(exponential
geometry
given polygon
is NP-hard
time).
Simple polygon
Nonsimple
polygons
There are no holes in a simple polygon.
STTP CAD 2011
Fundamentals of computational geometry
How 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 P, a point x can see a point y (y is visible
from x) iff [ 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
Fundamentals of computational geometry
This 12-vertex polygon needs
3 guards to cover it.
This 12-vertex polygon
needs 4 guards to cover it
STTP CAD 2011
Fundamentals of computational geometry
g  P  - smallest number of guards needed to cover P.
g  P   min | S : S covers P | .
S
G  n  - maximum of g  Pn  over all n-vertex polygons.
G  n   max g  Pn  .
Pn
What is G  n ?
A trivial lower bound: G  n   1
G  n   n.
A trivial upper bound: Put a guard at each vertex.
STTP CAD 2011
Fundamentals of computational geometry
What is G 3 ?
G 3  1.
What is G  4 ?
G  4  1. Put a guard on internal diagonal.
G 5  1. Put a guard at overlap of triangles.
STTP CAD 2011
Fundamentals of computational geometry
Hexagons may require two guards, G 6  2.
A shape with k prongs, n  3k , is covered by k guards.
n  12, k  4
g  P  4
Is the conjecture G  n  n 3 true?
STTP CAD 2011
Fundamentals of computational geometry
Proving G  n  n 3
Necessity follows from the prong’s example.
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.
1.
2.
3.
4.
Triangulation of polygon.
3-coloring of triangulation graph.
Placing guards at a single color guarantees cover.
“Pigeon-hole principle”: placing n objects in k holes, one at
least contains no more than └n/k┘ objects.
STTP CAD 2011
Fundamentals of computational geometry
A diagonal of a polygon is a line segment connecting two
visible vertices.
[a, b] is a diagonal of P iff:
[a, b] P  a, b and (a, b)  P \ P.
Diagonals [a, b] and [c, d ] are called noncrossing if
(a, b) (c, d )  .
Triangulation: the partition of a polygon by maximal non
crossing diagonals into triangles (not unique!).
STTP CAD 2011
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
Fundamentals of computational geometry
G(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
Fundamentals of computational geometry
5
4
5
The coloring of a
triangulation graph
is unique!
6
3
5
STTP CAD 2011
Assigning color to
first vertex enforces
the rest color
assignments.
Fundamentals of computational geometry
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┘.
Conclusion : n 3 guards are sufficient.
STTP CAD 2011
Fundamentals of computational geometry
An example of a polyhedron with interior points not visible from
any vertex.
STTP CAD 2011
Fundamentals of computational geometry

Schönhardt
polyhedron is the
smallest non-convex
polyhedron which
cannot be triangulated
into tetrahedra
without adding new
vertices.
STTP CAD 2011
Fundamentals of computational geometry
Let a, b, c  R 3 , and Α  b  a,
c
B  c  a, be two vectors. The
area of the parrallelogram
B
a
A
Determinant
notation:
STTP CAD 2011
b
defined by Α and B is Α  B .
uz
A B
Ay
Az   Az Bx  Ax Bz  u y 
By
Bz
A B
ux
uy
Ax
Bx
y
x
Fundamentals of computational geometry
z
y
 Az By  u x 
 Ay Bx  u z .
In R 2 Az  Bz  0, so the area of a triangle T is:
1
A T    Ax By  Ay Bx 
2
1
  bx  ax   c y  a y    by  a y   cx  ax  
2
1
  ax by  a y bx  a y cx  ax c y  bx c y  by cx  .
2
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
Fundamentals of computational geometry
v3
v4
v2
v5
P
v1
v0
v7
v6
A  P  A  v0 , v1, v2   A  v0 , v2 , v3  
 A v0 , vn2 , vn1 
A(P) expression depends on triangulation.
We’ll consider first quadrilaterals and show its area is
independent of triangulation.
STTP CAD 2011
Fundamentals of computational geometry
c
d
c
d
Q
Q
b
a
b
a
A Q  A  a, b, c   A  a, c, d   A  d , a, b  A  d , b, c 
2A  Q    axby  a ybx  a y cx  ax cy  bx c y  by cx 
  a x c y  a y c x  a y d x  a x d y  cx d y  c y d x 
Diagonal related terms are canceled out!
For any convex polygon: 2A  P    i 0  xi yi 1  xi 1 yi 
n 1
STTP CAD 2011
Fundamentals of computational geometry
v2
v3
What happens for non-convex
quadrilateral ?
Q
v1
A  Q   A  v0 , v1 , v2   A  v0 , v3 , v2 
  i 0  xi yi 1  xi 1 yi .
3
v0
The terms involving v0v cancel out.
Lemma : Let T  abc be a triangle whose vertices are
counterclockwise oriented, and p a point in the plane,
then A T   A  p, a, b   A  p, b, c   A  p, c, a  .
STTP CAD 2011
Fundamentals of computational geometry
c
T
b
p
a
We’d like to obtain the area of a general simple polygon in
terms of its vertices only.
Theorem : Let the vertices v0 , v1 ,
, vn 1 , vi   xi , yi 
be labled counterclockwise, defining a polygon P,
and let p be an arbitrary point. Then
A  P    i 0 A  p, vi , vi 1    i 0  xi yi 1  xi 1 yi 
n 1
n 1
  i 0  xi  xi 1   yi 1  yi  .
n 1
STTP CAD 2011
Fundamentals of computational geometry
Definitions
Basic algorithms
Gift Wrapping (algorithm of Jarvis)
Graham scan
Divide and conquer
STTP CAD 2011
Fundamentals of computational geometry

A set S is convex if x  S and y  S implies
the segment xy  S
x
STTP CAD 2011
Fundamentals of computational geometry
y


STTP CAD 2011
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
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
Fundamentals of computational geometry


STTP CAD 2011
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
Fundamentals of computational geometry
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
Fundamentals of computational geometry
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
Fundamentals of computational geometry



STTP CAD 2011
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
Fundamentals of computational geometry
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
Fundamentals of computational geometry



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
•
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
Fundamentals of computational geometry
y
e
θ
x
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
Fundamentals of computational geometry
Find the lowest point (smallest y coordinate)
Let i0 be its index, and set i ← i0
repeat
for each j ≠ i do
compute counterclockwise angle θ from previous hull edge
Let k be the index of the point with the smallest θ
Output (pi ,pk) as a hull edge
i ← 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
Fundamentals of computational geometry
p10
p9
p12
p6
p5
p7
p11
p8
p4
p2
p0
STTP CAD 2011
Fundamentals of computational geometry
p3
p1
p10
p9
p12
p6
p5
p7
p11
p8
p4
p2
p0
STTP CAD 2011
Fundamentals of computational geometry
p3
p1
p10
p9
p12
p6
p5
p7
p11
p8
p4
p2
p0
STTP CAD 2011
Fundamentals of computational geometry
p3
p1
p10
p9
p12
p6
p5
p7
p11
p8
p4
p2
p0
STTP CAD 2011
Fundamentals of computational geometry
p3
p1
p10
p9
p12
p6
p5
p7
p11
p8
p4
p2
p0
STTP CAD 2011
Fundamentals of computational geometry
p3
p1
p10
p9
p12
p6
p5
p7
p11
p8
p4
p2
p0
STTP CAD 2011
Fundamentals of computational geometry
p3
p1
p10
p9
p12
p6
p5
p7
p11
p8
p4
p2
p0
STTP CAD 2011
Fundamentals of computational geometry
p3
p1
p10
p9
p12
p6
p5
p7
p11
p8
p4
p2
p0
STTP CAD 2011
Fundamentals of computational geometry
p3
p1
p10
p9
p12
p6
p5
p7
p11
p8
p4
p2
p0
STTP CAD 2011
Fundamentals of computational geometry
p3
p1
p10
p9
p12
p6
p5
p7
p11
p8
p4
p2
p0
STTP CAD 2011
Fundamentals of computational geometry
p3
p1
p10
p9
p12
p6
p5
p7
p11
p8
p4
p2
p0
STTP CAD 2011
Fundamentals of computational geometry
p3
p1
p10
p9
p12
p6
p5
p7
p11
p8
p4
p2
p0
STTP CAD 2011
Fundamentals of computational geometry
p3
p1
p10
p9
p12
p6
p5
p7
p11
p8
p4
p2
p0
STTP CAD 2011
Fundamentals of computational geometry
p3
p1
p10
p9
p12
p6
p5
p7
p11
p8
p4
p2
p0
STTP CAD 2011
Fundamentals of computational geometry
p3
p1
p10
p9
p12
p6
p5
p7
p11
p8
p4
p2
p0
STTP CAD 2011
Fundamentals of computational geometry
p3
p1
p10
p9
p12
p6
p5
p7
p11
p8
p4
p2
p0
STTP CAD 2011
Fundamentals of computational geometry
p3
p1
p10
p9
p12
p6
p5
p7
p11
p8
p4
p2
p0
STTP CAD 2011
Fundamentals of computational geometry
p3
p1
p10
p9
p12
p6
p5
p7
p11
p8
p4
p2
p0
STTP CAD 2011
Fundamentals of computational geometry
p3
p1
p10
p9
p12
p6
p5
p7
p11
p8
p4
p2
p0
STTP CAD 2011
Fundamentals of computational geometry
p3
p1
p10
p9
p12
p6
p5
p7
p11
p8
p4
p2
p0
STTP CAD 2011
Fundamentals of computational geometry
p3
p1

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)
Complexity: O(nlogn)
n
T (n)  2T    O(n)
2
STTP CAD 2011
Fundamentals of computational geometry
Voronoi Diagram
STTP CAD 2011
Fundamentals of computational geometry
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
Fundamentals of computational geometry
P3
P1
P2
P2
P1
Remember that VD is not
defined for just points but
for any set e.g. curves,
surfaces etc. Moreover, the
definition is applicable for
any dimension.
STTP CAD 2011
Fundamentals of computational geometry
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.
STTP CAD 2011
Assumption: No 4 points are cocircular.
Fundamentals of computational geometry
Search for nearest neighbour
Input: 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
Fundamentals of computational geometry
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 empty
circle. Find one having maximum
radius.
Computing Euclidian Minimum Spanning Tree:
Compute dual of the Voronoi diagram, and apply
Kruskal’s algorithm for computing the minimum
Spanning tree.
STTP CAD 2011
Fundamentals of computational geometry
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
Fundamentals of computational geometry
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
Fundamentals of computational geometry
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
Thus, a point having large weight
will cover bigger space
Weighted Voronoi diagram
WVD(S)  the subdivision of
the plane such that
region(p) = {x : dw(x,p) < dw(x,q)
qS
STTP CAD 2011
Fundamentals of computational geometry
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 endpoint and a segment’s interior.
STTP CAD 2011
Fundamentals of computational geometry
Voronoi Diagram & Delaunay Triangulation
Nearest site proximity partitioning of the plane
STTP CAD 2011
Fundamentals of computational geometry
Voronoi Diagram & Delaunay Triangulation
STTP CAD 2011
Fundamentals of computational geometry
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
Fundamentals of computational geometry



Art-gallery problem for orthogonal
polygon
smallest circle that completely
encloses a set of points
Relation between MA and VD for a)
convex and b) non-convex polygons.
STTP CAD 2011
Fundamentals of computational geometry







www.cs.iastate.edu/~cs518/handouts/artgallery.ppt
www.tcs.tifr.res.in/~igga/lectureslides/vor-July08-2009.ppt
in2.csie.ncu.edu.tw/~jrjiang/alg2008/Voronoi.ppt
www.cse.ttu.edu.tw/~jmchen/compg/slides/vor
o-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
Fundamentals of computational geometry