Introduction Segment-Segment intersections Polygon … › CADCG › CADCG_11.pdf · 2020-06-10 ·...
Transcript of Introduction Segment-Segment intersections Polygon … › CADCG › CADCG_11.pdf · 2020-06-10 ·...
1
CAD & Computational Geometry
Course plan
Introduction Segment-Segment intersections Polygon Triangulation Intro to Voronoï Diagrams & Delaunay Triangulations Geometric Search Sweeping algorithm for Voronoï Diagrams
2
CAD & Computational Geometry
Voronoi Diagrams
Voronoi Diagrams or Dirichlet Tessellations In dimension 2 or 3
Johann Peter Gustav Lejeune Dirichlet (1805-1859) ~ 1850.
For all dimensions :
Georgy Feodosevich Voronoy (1868-1908) ~ 1908
G.F. Voronoï (1908). "Nouvelles applications des paramètres continus à la théorie des formes quadratiques". Journal für die reine und angewandte Mathematik 134: 198–287.
3
CAD & Computational Geometry
Voronoi Diagrams
Let P={ p0, p
1, … , p
n-1 } a point set in the plane
The Voronoi diagram Vor(P) is a paving of the plane into n cells V( p
i ).
Inside cell V( pi ), the closest point belonging to P is p
i .
Here, the we consider the euclidean distance :
A point q is inside the cell corresponding to point p
i iff
Dist p , q= p x−q x2 p y−q y
2
Dist q , piDist q , p j ∀ p j∈P , j≠i
4
CAD & Computational Geometry
Voronoi Diagrams
What is the structure of the Voronoi diagram ? The bissector of points p and q separates the plane in two half-planes Let h(p,q) the open half plane containing p We have then
and V( p
i) is the intersection of the n-1 half-planes, a possibly open polygonal region,
limited by at most n-1 edges and n-1 vertices. The shape is necessarily convex.
p
q
r∈h( p ,q) iff Dist (r , p)<Dist (r , q)
h(p,q)
V pi= ∩j≠i h pi , p j
v(pi)
Vor(P) is either
a) a set formed by n-1 parallel lines
b) a connected set of line segments or half-lines.
5
CAD & Computational Geometry
Voronoi Diagrams
Demonstration Case a) straightforward Case b) : Let us consider that an edge e that
bounds two Voronoi cells V(pi) and V(p
j) is a
line : it separates the plane in two parts. Let pk
a third point, not colinear with pip
j : necessarily,
the edge e' bounding V(pj) and V(p
k) is not
parallel to e and intersects it. The part of e which is in h(p
k,p
j) cannot be on the boundary
of V(pj) since it is closer to p
k than p
j .
Therefore, the edges of the Voronoi diagram are either half-lines or line segments, or only complete lines as in the case a)
n-1 parallel lines
pi
pj
pk
e
e'
6
CAD & Computational Geometry
Voronoi Diagrams
There remains to prove that the Voronoi diagram is a connected graph.
Let us suppose that it is not the case. At least one Voronoi cell woud separate the plane in two parts. Since Voronoi cells are convex, its bundaries are necessarily made of at least some complete lines, which is a contradiction with the previous demonstration (either only complete lines; or only line segments and half-lines).
7
CAD & Computational Geometry
Voronoi Diagrams
Complexity of the Voronoi diagram
What is the number of cells, edges and vertices ? There are n sites in P ; and in the worst case, a cell may have n-1
edges and vertices. The global complexity of Vor(P) could be quadratic. In fact, it is not the case:
Euler formula for a plane graph (including the unbounded face around the graph) : v – e + f = 2Here, we consider an additional vertex infinitely far away ; we have thereforen
v +1 – n
e + n = 2 → 2n
v – 2n
e + 2n = 2
Each edge has two vertices ; the sum of the valence of each vertex is twice the numberof edges. Also, the valence is at least 3.
v¥
2 ne≥3(nv+1)
2 nv−3(n v+1)+2 n≥2 → nv≤2 n−5
2 n−5+1−ne+n≥2 → ne≤3 n−6
8
CAD & Computational Geometry
Voronoi Diagrams
The number of bisectors is quadratic, but only a small fraction (linear in n) are part of the Voronoi diagram.
Which ones ?
One defines CP(q) as the greatest circle of center q which does not
contain any point pi of P in its interior. It has at least one point of P on
its boundary.
Then : One point q is a vertex of Vor(P) iff C
P(q) has at least three points of P on its
boundary. A bissector of points p
i et p
j exists as an edge in Vor(P) iff there are points q on it
such that CP(q) has p
i and p
j on its boundary but not any other point of P.
q
CP(q)
9
CAD & Computational Geometry
Voronoi Diagrams
Demonstration 3 points or more on the boundary → Center of the
circle is a vertex of the Voronoi diagram 2 points on the boundary → Center is on an edge
of the Voronoi diagram Only one point on the boundary → Center located
inside a cell of the Voronoi diagram
10
CAD & Computational Geometry
Voronoi Diagrams How to compute the Voronoi diagram ?
For each cell V(pi), compute the intersections of all the half-planes
h(pi,p
j) with j≠i using the intersection of lines of chapter CG2
Complexity : in nlog n for each cell (one does not know in advance which intersections will be found in the final shape of the cell)
There are n cells → n²log n globally. However, the complexity of the diagram is only O(n)...
Is it possible to be faster ? → yes ! Optimum : Ω(nlog n) Demonstration later on.
11
CAD & Computational Geometry
Voronoi Diagrams
Line sweeping algorithme for the computation of a Voronoi Diagram
Also known as Fortune’s algorithm
Steven Fortune, A sweepline algorithm for Voronoi diagrams, Algorithmica 2 (1-4),pp. 153-174, 1987DOI: 10.1007/BF01840357
Algorithm in O(nlog n)
Known sweep line process :- an imaginary line l sweeps the plane- a status T is updated at each event- the event list F contains event in the order in which they appear (x-wise)- the Voronoi diagram is built step by step in relation with T- By duality, it is another way of computing the Delaunay triangulation...
l
12
CAD & Computational Geometry
Voronoi Diagrams
The paradigm of sweep line algorithms implies an invariant. Here, it will be the portion of the Voronoi diagram that we know will not change for subsequent events.
It is not the portion of the Voronoi diagram on the left of the line l.
In fact, a part of Vor(P) located on the left of l still depends on some of the points p
i that are located on the right.
More precisely, the part that does not change is the set of points q such that the distance to the line l is greater or equal to the distance to the poinst p
j located on the left of l.
The limit of such a domain is a succession of parabolas, shaped somewhat like a “beach line”.
The “beach line” is y-monotone. The status T will be this beach line.
How does it change when events occur ?(What are in fact these events ?)
q
l
pj
l
13
CAD & Computational Geometry
Voronoi Diagrams
Configurational changes in the beach line A new parabolic arc appears
In fact, only when the line l sweeps past a point pi. This is the first
kind of events (points of P)
Proof : cf Book , p 153
l l
14
CAD & Computational Geometry
Voronoi Diagrams
Configuration changes in the beach line Existing parabolic arcs may disappear
This happens only when the beach line moves past a vertex of the Voronoi diagram, otherwise said, when the line l meets the extremal point of the circle going through three points p
i that correspond the
three consecutive arcs ai of the beach line.
This is the second type of events (limit circles)
l1
2
3
l1
3
l
1
3
15
CAD & Computational Geometry
Voronoi Diagrams
Data structures The Voronoi diagram : e.g. a Doubly Connected Edge List. Ideally
one needs a bounding box so that the cells are closed, and the half edges all able to have a geometrical meaning (a direction and starting point)
s¥
16
CAD & Computational Geometry
Voronoi Diagrams
Data structures Status T : The beach line – y-monotone – is a binary balanced tree.
The leaves store the parabolic arcs and are sorted by increasing y coodinate. For each leaf, there is a pointer to an event in the even list – the limit circle event that correspond to the disapearing of the corresponding parabolic arc. If it does not yet exist, store e.g. a null pointer.
The internal nodes inside the tree are the “breaks” in the beach line. Those are indentified with an ordered tuple (p
i, p
j) , where p
i is
the point corresponding to the inferior parabola, and pj that of the
superior parabola. At each interior node, one ca store a pointer to a half-edge of the Voronoi diagram
One may look for the are immediately to the left of a given point pk
inO(log n). Upon tree traversal, at each internal node, it is sufficient to compare the y coordinate of the point p
k with the y coordinate of
the “break”, which may be computed “on the fly” knowing the position of l (which goes through p
k).
17
CAD & Computational Geometry
Voronoi Diagrams
Data structures Event list F : It is a priority queue for which the events are sorted
lexicographically by increasing x , then increasing y .
In this list, on can find all the points pi Î P, and the limit circle
events . The point used to classify the cicle events is the rightmost point of the circle. Moreover, a pointer to the arc inside the status T shall be stored.
Every point pi is known in advance, however circle events are not
and must be detected “on the fly”.
18
CAD & Computational Geometry
Voronoi Diagrams
Determination of circle events As each event is processed, triplets of contiguous arcs appear or
disappear Those correspond potentially to a circle event (in the future)
It is clear that at each new triplet of arcs, a circle event should be inserted in the list F.
Two remarks: It is possible that, for a given triplet, the two edges that are concerned in the
Voronoi diagram are divergent. In this case, no need to insert a new event (it would be in the past !)
If the edges are convergent it is still possible that the corresponding triplet disappear before it is processed. This would be because of another event (e.g. a point event), and has to be considered as a “false alarm”, thus the corresponding circle event should be deleted from L.
19
CAD & Computational Geometry
Voronoi Diagrams
Two remarks: It is possible that, for a given triplet, the two
edges that are concerned in the Voronoi diagram are divergent. In this case, no need to insert a new event (it would be in the past !)
20
CAD & Computational Geometry
Voronoi Diagrams
Two remarks: If the edges are convergent it is still possible that
the corresponding triplet disappear before it is processed. This would be because of another event (e.g. a point event), and has to be considered as a “false alarm”, thus the corresponding circle event should be deleted from L.
It is easy if there is a link between the arcs in the status and the circle events (a pointer) stored along with the arc in the status.
21
CAD & Computational Geometry
Voronoi Diagrams
Global algorithm
Voronoi(P)Input : a set of points P={p
0,p
1 … , p
n-1}
Output : a DCEL of the V.D. of P in its bounding box (V){ Initialize an event list F with the points in P ( ‘point’ events) Initialize en empty status T Initializer an empty DCEL V While F contains events { Take the first event from F (lexicographic order) If it is a “point” event then ProcessPointEvt(pi) Else ProcessCircleEvt(f) // f is the leaf in the status corresponding to the arc that will be deleted } The internal nodes of T are half edges of the V.D. they should be limited by the bounding box so that “outer” cells are bounded and allow traversal Walk the DCEL and create faces (cells)}
22
CAD & Computational Geometry
Voronoi Diagrams
ProcessPointEvt(pi)
{ If T is empty, insert p
i into T
Else { Look for the arc a immediately on the left to p
i ; it is associated to another point p
j
If the leaf containing a has a pointer toward a circle event in F, delete that event. Replace the leaf in T with a subtree having 3 leaves that correspond to the 3 new triplets In this subtree : The middle leaf corresponds to the new arc a
i associated to p
i ;
The two others are copies of the old arc a (cut in two) Insert two new internal nodes (p
i,p
j) and (p
j,p
i)
Re-balance the tree. Create two new half edges in the DCEL V, for the edge separating V(p
i) et V(p
j)
Check that the triplets of consecutive arcs that are above or below the new arc ai (from p
i ) correspond to
converging edges : if yes then add a corresponding circle event in the list F. }}
a,pj
a,pj
a,pj
a',pi
(pj,p
i)
(pi,p
j)
23
CAD & Computational Geometry
Voronoi Diagrams
ProcessCircleEvt(c){ Delete the leaf c (that contain the arc a) from T. Update the tuples in the internal nodes of T Delete every circle event associated to a (they can be found by walking T from c) Add the center of the circle as a new vertex into the DCEL of the V.D. Create two new half edges that correspond to the new triplets Check that the new triplets correspond to converging edges : if yes then add a corresponding circle event in the list F. }
a',pj
a",pk
a,pi
(pj,p
i)
(pi,p
k)
a',pj
a",pk
(pj,p
k)
c......
24
CAD & Computational Geometry
Voronoi Diagrams
Some degenerate cases : At the beginning of the algorithm : points having the same x
coordinate
Concyclic points (4 or more)
Point event exactly on the right of a break in the beack line (same y coordinate)
Points corresponding to three successive arcs that are also co-linear
25
CAD & Computational Geometry
Voronoi Diagrams
Some othe types of Voronoï diagrams
26
CAD & Computational Geometry
Voronoi Diagrams
Order p Voronoi diagrams Aims to build regions closest to p of the sites Order 1 diagram is the regular Voronoi diagram With n sites, it is possible to build a diagram of maximum
order n – 1 This diagram of order n – 1 is also called the Maximum
Distance Diagram (MDD)
27
CAD & Computational Geometry
Voronoi Diagrams
Order 2 diagram Order n – 1 diagram
Cell where p
1 and p
2 are
the closest
p1
p2 p
3
p4
p5
p6
p7
p8
Cell where p
4 and p
5 are
the closest
Cell closestto p
2 – p
9
(furthestawayfrom p
1)p
1
p2 p
3
p4
p5
p6
p7
p8
p9
Cell where p
3 and p
8 are
the closest
Cell furthestawayfrom p
4
28
CAD & Computational Geometry
Voronoi Diagrams
Properties of the MDD
Let P = {p1 … p
n–1} a set of points in the plane
A point pi of P is associated to a cell of the
MDD of P only if it belongs to theconvex hull of P.
The proof is trivial : a point p inside the convex hull of P, is never the furthest away fromany other point q : on a straight line joining p and q, there necessarily exist points on the convex hullsuch that the distance to q is greater.
q
p
29
CAD & Computational Geometry
Voronoi Diagrams
Properties of the MDD The cells are infinite, hence there are no
cycles in the MDD, therefore its graph is a tree.
Proof : from a point q ; located in a cellassociated to p
i, one draw a line (qp
i).
For every point of the half line from q goingopposite to p
i, p
i is the most far away
point from P.
There are O(n) cells, vertices; edges(the proof is similar to the one for regularVoronoï diagrams)In particular,
qp
i
ne≤2n−3
30
CAD & Computational Geometry
Voronoi Diagrams
Properties of the MDD The center c of any circumscribed circle to P
(three points or more) is located on a vertex of the MDD Or exactly on the middle of a segment joining
the two sites associated to an edge of the MDD(two points).
cc
31
CAD & Computational Geometry
Voronoi Diagrams
Computation of the MDD
- Computation of the convex hull of P. The vertices located on the convex hull are ordered in a cycle s
0 … s
h–1 (seen in a previous
chapter)
- One « mixes » randomly the vertices that hare located on the convex hull. Lets call p
0 … p
h–1 this ordering.
- One takes the vertices one by one : k=0... h–4 ( ph–1
… p3 )
- The preceding vertex is stored (clockwise order) and the successor (anticlockwise) : to p
h-k-1 correspond s
j, and we associate s
j–1 mod (h-k)
and sj+1 mod (h-k)
- One takes off ph-k-1
(hence sj) from the cycle (while updating the
cycle so that it remains ordered … ). Therefore, ph-k-1
cannot be the predecessor or successor of points canceled later on
- Finally, one obtains a structure that allows ; starting from 4 points of the convex hull, to rebuild the convex hull while maintaining the ordering at every moment.
32
CAD & Computational Geometry
Voronoi Diagrams
Computation of the MDD
- Associated to a point pj, one keeps a pointer to the most anti-
clockwise edge of the cell associated to pj.
pj
Cell of pj
33
CAD & Computational Geometry
Voronoi Diagrams
Computation of the MDD
- Incrémental approach : from the MDD of pi–1
, one builds the MDD for p
i
pi
pred(pi)
succ(pi)
Cellule de succ(p
i)
Cellule de pred(p
i)
pi+1 pred(p
i+1)succ(p
i)
Cellule de pi
Cellule de succ(p
i)
Cellule de pred(p
i)
succ(pi+1
)
pi
pred(pi)
34
CAD & Computational Geometry
Voronoi Diagrams
Computation of the MDD
- The cell for pi comes “in between” that of pred(p
i) and succ(p
i)
- These two cells are separated by a half line that is part of the bissector of pred(p
i) and succ(p
i)
- succ(pi) has in fact a pointer on this edge.
- The bissector of pi and succ(p
i) induces a new edge (a half line, in
red)
succ(pi)
pi succ(p
i)
pi
Cellule de succ(p
i)
pred(pi)pred(p
i)
Cellulede pred(p
i)
35
CAD & Computational Geometry
Voronoi Diagrams
Computation of the MDD
- One has to traverse the cell of succ(pi) in the clockwise order to
know which edge is intersected by the new half edge.
- From the other side of this edge, there is the cell corresponding to another point p
j
- One traverse this cell again, to find the intersection with the bissector of p
i-p
j
succ(pi)
pi
Cellule de succ(p
i)
pi
pj
pi
pk
Cellule de pj
Cell.de p
k
36
CAD & Computational Geometry
Voronoi Diagrams
Computation of the MDD - One repeats this set of operations until we meet pred(p
i), which wil
give the other half-line that bounds the cell of pi.
Do not forget to update the pointers between the existing points pi
and the corresponding edges (most anticlockwise) ...
pi
pk
pi pred(p
i)
pi
Cellule de pi
Cell.de p
k
Cell.de pred(p
i)
37
CAD & Computational Geometry
Voronoi Diagrams
Computation of the MDD The computation may be initialized with a MDD of the 4 first vertices
p0...p
3 for which the MDD is trivial :
p1
p2p
3
p0
38
CAD & Computational Geometry
Voronoi Diagrams
Complexity of the algorithm Initial convex hull : O(nlog n), contains the n points in the worst case.
After the insertion of pi, the corresponding cell has k edges.
Hence, to build this cell from the MDD obtained after the insertion of pi–1
, the algorithm has walked in k neighboring cells.
These k cells are separated by a subtree that has at most 2k–3 distinct edges, and in the worst case, one will walk these edges two times, hence a total of 4k–6 tests (linear in k)
pi
The MDD at step i has at most 2i–3 edges. Each edge separates two cells. So, in average, each cell has less than (4i–6)/i edges, which is smaller than 4.
Each point pi has the same probability to be inserted at
the end of the process, so globally the complexity to build the MDD is in O(n).
Globally, the complexity is therefore in O(nlog n) with a storage in O(n).
39
CAD & Computational Geometry
Voronoi Diagrams
Application of the MDD Metrology ( in relation with the classical V.D.)
Dertermine the two min-max circles having the same center that approximate a cloud of samples (coming e.g. from a laser scanner operating on a machined cylindrical part, to asses the quality of the machining)
There are multiple cases : The interior circle (max size) goes through 3 or more samples – its center is
therefore on a vertex of the classical V.D. The exterior circle is then coincident with only one point (the one corresponding to a cell of the MDD)
The exterior circle (min size) goes trough three or more points – its center is therefore on a vertex of the MDD. The internal circle is then coincident with only one sample (that corresponding the a cell of the V.D.)
Finally; the external circle goes through two points, as well as the interior circle. The center is therefore at the intersection of an edge of the MDD, and one of the V.D.
To compute these circles and find the optimum, one must therefore compute the arrangements between a V.D. and the MDD.
40
CAD & Computational Geometry
Voronoi Diagrams
For each vertex of the MDD, find the point of P that is the closest(gives 4 points)
For each vertex of the V.D., find the point of P the most far away(gives 4 points)
For each intersection between the V.D. and the MDD, determine the 4 points in P
For each of these groups of candidates, find the one which gives the smallest ring.
This may be done in O(n²) in the worst case
There may be O(n²) additional sites due to the intersection of the two graphs.
41
CAD & Computational Geometry
Voronoi Diagrams
In the present case; 13 combinations have to be checked
42
CAD & Computational Geometry
Voronoi Diagrams
Voronoi diagrams in other norms (Lp,p≠2 ; polygonal ...)
Uniform L1 norm “local” polygonal norms