implementation delaunay triangulation · choosing an algorithm (not only) laziness incremental...

66
Delaunay triangulation: Implementation Monique Teillaud

Upload: phamthuy

Post on 04-Jun-2018

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Delaunay triangulation:

Implementation

Monique Teillaud

Page 2: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Choosing an algorithm

(not only) laziness

Incremental algorithm fully dynamic

any dimension

Page 3: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Choosing an algorithm

(not only) laziness

Incremental algorithm fully dynamic

any dimension

Page 4: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Choosing an algorithm

(not only) laziness

Incremental algorithm fully dynamic

any dimension

Page 5: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Choosing an algorithm

(not only) laziness

Incremental algorithm fully dynamic

any dimension

Page 6: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Choosing an algorithm

(not only) laziness

Incremental algorithm fully dynamic

any dimension

Page 7: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Representation

walk: access to• vertices of a triangle• neighbors of a triangle

in constant time

Page 8: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Representation

walk: access to• vertices of a triangle• neighbors of a triangle

in constant time

store• d-simplices• vertices

combinatorics:

geometry

adjacency relations as pointers

store• points in vertices

Page 9: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Representation

walk: access to• vertices of a triangle• neighbors of a triangle

in constant time

store• d-simplices• vertices

combinatorics:

geometry

adjacency relations as pointers

what about the infinite region? unbounded size. . .

Page 10: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Representation

add a bounding box?

requires to know points in advance

Page 11: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Representation

add a bounding box?

requires to know points in advance

creates ugly triangles

Page 12: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Representation

add a vertex at infinity

compactification of Rd

=⇒ triangulation of the sphere Sd

Page 13: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Representation

no point in the infinite vertex

all d-faces are simplices

infinite simplex = half-space

combinatorics

constant-time access. . .

geometry

constant description

Page 14: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Representation

what if all points are collinear?

Page 15: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Representation

what if all points are collinear?

triangulation of S1

dD triangulation, d ≥ 2 “incomplete” simplices

Page 16: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Representation

what if all points are collinear?

triangulation of S1

what if a non-collinear point comes in ?

Page 17: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Representation

what if all points are collinear?

triangulation of S1

what if a non-collinear point comes in ?

−→ triangulation of S2

Page 18: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Representation

what if all points are collinear?

triangulation of S1

what if a non-collinear point comes in ?

−→ triangulation of S2

what if a non-coplanar point comes in ?

−→ triangulation of S3

Page 19: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Arithmetic computations

Page 20: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Arithmetic computations

Page 21: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

only predicates

Combinatorial structure

Arithmetic computationsArithmetic computations

Page 22: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

constructions

Geometric embedding

same underlying combinatorial structure

Arithmetic computations

Page 23: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Arithmetic computations

inexact evaluation of predicates

in disk1(p) = true

in disk2(p) = false

p

NOT just an imprecision in the result

1

2

Page 24: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Arithmetic computations

inexact evaluation of predicates

in disk1(p) = true

in disk2(p) = false

p

inconsistencies!

NOT just an imprecision in the result

algorithms fail

Page 25: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Arithmetic computations

Is s inside or outside the disk?s

Predicate

Page 26: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Arithmetic computations

Is s inside or outside the disk?s

c

circle C through p, q, rp

q

r

unknowns c, ρsolve −→• center c• radius ρ

ρ

Predicate

Page 27: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Arithmetic computations

Is s inside or outside the disk?s

c

circle C through p, q, rp

q

r

unknowns c, ρsolve −→• center c• radius ρ

ρ

Bad idea. . . reals do not exist!

rounding errors ↪→ p, q, r 6∈ C(c, ρ)

“random” result for s

Predicate

Page 28: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Arithmetic computations

Is s inside or outside the disk?s

sign

∣∣∣∣∣∣∣∣1 1 1 1px qx rx sxpy qy ry sy

p2x + p2y q2x + q2y r2x + r2y s2x + s2y

∣∣∣∣∣∣∣∣

Predicate

in disk(p, q, r, s)

Page 29: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

sign

∣∣∣∣∣∣1 1 1px qx rxpy qy ry

∣∣∣∣∣∣

Arithmetic computations

A simpler predicate

p

q

r

Is r on the left or right side?

orient(p, q, r)

Page 30: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Arithmetic computations

double numbers are not reals53 binary digits

p = (0.5+x.u, 0.5+y.u)0 ≤ x, y < 256,u = 2−53

q = (12, 12)r = (24, 24)

(x, y) = (0, 0)

(x, y) = (256, 256)

orient(p, q, r)> 0

= 0

< 0

fast, but wrong

Page 31: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Arithmetic computations

rely on an exact arithmetic package (multiprecision, etc)

powerful, but slow

a solution:

Page 32: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Arithmetic computations

Exact Geometric Computing paradigm

= exact predicates, 6= exact arithmetics

easy cases are more frequent=⇒ cost ' cost of approximate (double) computation

Filtering

Page 33: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Arithmetic computations

Dynamic filtering interval arithmetic

[ a, a ] +[b, b

]=

[a + a , a + b

]error on +,−, ∗, /,√ known (IEEE 754)

and propagate. . .

Page 34: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Arithmetic computations

Dynamic filtering interval arithmetic

[ a, a ] +[b, b

]=

[a + a , a + b

]error on +,−, ∗, /,√ known (IEEE 754)

and propagate. . .

0 6∈[

result , result]

?

y n

sign certified exact arithmetic

Page 35: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Choosing an algorithm

Degree of predicates & number of operations

−→ constant in O()

−→ size of errors

−→ length of integers for exact arithmetic

Page 36: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Choosing an algorithm

Degree of predicates & number of operations

−→ constant in O()

−→ size of errors

−→ length of integers for exact arithmetic

Incremental algorithmonly uses intrinsic predicates

any algorithm computing Delaunay triangulationis able to answer them

orient, in disk

Sweepuses ad hoc higher degree predicates

Page 37: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

laziness is not the only criterion

Choosing an algorithm

Degree of predicates & number of operations

−→ constant in O()

−→ size of errors

−→ length of integers for exact arithmetic

Incremental algorithmonly uses intrinsic predicates

any algorithm computing Delaunay triangulationis able to answer them

orient, in disk

Sweepuses ad hoc higher degree predicates

Page 38: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Degeneracies

p

Page 39: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Degeneracies

Exact computation

p

in disk(·, ·, ·, p) = 0

what if p lies on a circle?

yes, it does happen!input data are rounded

Page 40: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Degeneracies

Delaunay complex

non-simplicial faces

Page 41: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Degeneracies

Delaunay complex

non-simplicial faces

non-constant storage and access

users want triangles

Page 42: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Degeneracies

p?

“the” Delaunay triangulation is not unique

Page 43: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Degeneracies

Simulating the absence of degeneracies

p

Page 44: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Degeneracies

Simulating the absence of degeneracies

as if p outside

p

Page 45: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Degeneracies

Simulating the absence of degeneracies

p

as if p inside

Page 46: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Degeneracies

Page 47: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

decisions must be made in a consistent way

Degeneracies

Page 48: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Degeneracies

Symbolic perturbation

Input data 7→ data depending on a symbolic parameter ε

• ε = 0: (maybe) degenerate problem• ε 6= 0: non-degenerate problem 7→ Result(ε)

Final result = limε→0+ Result(ε)

Page 49: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Degeneracies

SoS: simulation of simplicity

Input: n points pi = (xi, yi), i = 1, . . . , n

∀i, (xi, yi) 7→ (xi, yi) + ε2i

(i, i2)

Page 50: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Degeneracies

SoS: simulation of simplicity

Input: n points pi = (xi, yi), i = 1, . . . , n

∀i, (xi, yi) 7→ (xi, yi) + ε2i

(i, i2)

orient(O, pi, pi) = sign

∣∣∣∣ xi xjyi yj

∣∣∣∣∣∣∣∣ x3 x1y3 y1

∣∣∣∣ 7→ ∣∣∣∣ x3 + 3ε8 x1 + ε2

y3 + 9ε8 y1 + ε2

∣∣∣∣ =∣∣∣∣ x3 x1y3 y1

∣∣∣∣ + ε2∣∣∣∣ x3 1y3 1

∣∣∣∣ + ε8∣∣∣∣ 3 x19 y1

∣∣∣∣ + ε10∣∣∣∣ 3 19 1

∣∣∣∣

Page 51: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Degeneracies

SoS: simulation of simplicity

Input: n points pi = (xi, yi), i = 1, . . . , n

∀i, (xi, yi) 7→ (xi, yi) + ε2i

(i, i2)

orient(O, pi, pi) = sign

∣∣∣∣ xi xjyi yj

∣∣∣∣∣∣∣∣ x3 x1y3 y1

∣∣∣∣ 7→ ∣∣∣∣ x3 + 3ε8 x1 + ε2

y3 + 9ε8 y1 + ε2

∣∣∣∣ =∣∣∣∣ x3 x1y3 y1

∣∣∣∣ + ε2∣∣∣∣ x3 1y3 1

∣∣∣∣ + ε8∣∣∣∣ 3 x19 y1

∣∣∣∣ + ε10∣∣∣∣ 3 19 1

∣∣∣∣

non-null polynomial

sign = sign of first non-null coefficient

Page 52: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Degeneracies

SoS: simulation of simplicity

Input: n points pi = (xi, yi), i = 1, . . . , n

∀i, (xi, yi) 7→ (xi, yi) + ε2i

(i, i2)

orient(O, pi, pi) = sign

∣∣∣∣ xi xjyi yj

∣∣∣∣−→ always > 0 or < 0

same for in disk

Page 53: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Degeneracies

SoS: simulation of simplicity

Input: n points pi = (xi, yi), i = 1, . . . , n

∀i, (xi, yi) 7→ (xi, yi) + ε2i

(i, i2)

orient(O, pi, pi) = sign

∣∣∣∣ xi xjyi yj

∣∣∣∣−→ always > 0 or < 0

same for in disk

may create FLAT simplices

Page 54: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Degeneracies

Perturbing points in d+ 1th dimension

πi = (xi, yi, ti = x2i + y2i )

pi = (xi, yi)

Page 55: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Degeneracies

Perturbing points in d+ 1th dimension

πi = (xi, yi, ti = x2i + y2i )

in disk(pi, pj , pk, pl) =D(pi,pj ,pk,pl)

orient(pi,pj ,pk)

D(pi, pj , pk, pl) = orient(πi, πj , πk, πl)

pi = (xi, yi)

Page 56: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Degeneracies

Perturbing points in d+ 1th dimension

πi = (xi, yi, ti = x2i + y2i )

in disk(pi, pj , pk, pl) =D(pi,pj ,pk,pl)

orient(pi,pj ,pk)

7→ orient(πεi , π

εj , π

εk, π

εl )

7→ πεi = (xi, yi, ti + εn−i)

D(pi, pj , pk, pl) = orient(πi, πj , πk, πl)

pi = (xi, yi)

Page 57: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

orient(πεi , π

εj , π

εk, π

εl ) =

∣∣∣∣∣∣∣∣∣∣1 1 1 1xi xj xk xlyi yj yk ylzi zj zk zl

ti+εn−i tj+ε

n−j tk+εn−k tl+ε

n−l

∣∣∣∣∣∣∣∣∣∣= D(pi, pj , pk, pl)

−orient(pi, pj , pk)εn−l

+orient(pi, pj , pl)εn−k

−orient(pi, pk, pl)εn−j

+orient(pj , pk, pl)εn−i

−→ non-null polynomial in ε4 cocircular points

point with highest indexin the disk of the other 3

Degeneracies

Perturbing points in d+ 1th dimension

Page 58: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Degeneracies

Perturbing points in d+ 1th dimension

global indexing = lexicographic order

orientation predicate not perturbed

=⇒ NO flat simplex created

easy to implement

−→ Delaunay triangulation uniquely defined

Page 59: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Computational Geometry Algorithms Library

distributed under GPL

www.cgal.org

open source

commercial licences distributed by GeometryFactory

Page 60: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Computational Geometry Algorithms Library

www.cgal.org

2D, 3D, dD [weighted] Delaunay triangulations

fully dynamic

fully robust

2D ' 10 million points / second

3D ' 1 million points / second

(on a standard laptop)

Page 61: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Computational Geometry Algorithms Library

www.cgal.org

2D, 3D periodic [weighted] Delaunay triangulations (flat torus)

Page 62: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Computational Geometry Algorithms Library

www.cgal.org

soon (?)

hyperbolic Delaunay triangulations

Page 63: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Computational Geometry Algorithms Library

www.cgal.org

soon (?)

Delaunay triangulations on the sphere

Page 64: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Computational Geometry Algorithms Library

www.cgal.org

used by astrophysicists, biologists, . . .

Page 65: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Computational Geometry Algorithms Library

www.cgal.org

used by astrophysicists, biologists, . . .mathematician(s?)

Page 66: Implementation Delaunay triangulation · Choosing an algorithm (not only) laziness Incremental algorithm fully dynamic any dimension

Take home (?)

There is a long way from the algorithm to the software

clean mathematical models

knowledge of computers

union makes strength

Needed

good algorithms