Computational Geometry: Spatial Data Structures, Voronoi Diagram and Delaunay Triangulation§

author:David Coeurjolly

Point Set Spatial Data Structures§

Range Queries§

Problem setting

Dimension 1

\Rightarrow O(n) storage and O(n\log n) construction time, then O(k + \log(n)) per query (k is number of reported points)

Regular but recursive spatial decomposition: QuadTree/OctTree§

Idea

_images/quadtree.png _images/octree.png

Implementation: Pointerless Trees§

Idea

_images/quadtree1.png _images/quadtree2.png
_images/morton.png

Implementation: Pointerless Trees (again)§

Ctd.

QuadTree/Octree conclusion§

… but

Kd-Tree structure§

Description

Pseudo-code in 2D:

BuildKdTree(S, depth)
  if |S|=1
     return a leaf containing this point

  if depth is even
     Let l be the vertical line with median x-coordinate
     Split S w.r.t. l -> S1 and S2

  if depth is odd
     Let l be the horizontal line with median y-coordinate
     Split S w.r.t. l -> S1 and S2

  SubTree1 = BuildKdTree(S1,depth + 1)
  SubTree2 = BuildKdTree(S2,depth + 1)

  return Tree(l , SubTree1, SubTree2)

Computational cost§

\Rightarrow KdTree construction in O(n \log n), O(n) storage

Example <Cf board>

FYI: Median of a scalar vector§

Random algorithm

QuickSelect(A, k)
  Pick a pivot element p randomly from A
  Split A into LESS and GREATER sets
  L =  number of elements in the LESS array
  if (L == k-1)
     return p;

  if (L > k-1)
     return QuickSelect(LESS, k)

  if (L < k-1)
     return QuickSelect(GREATER, k - L - 1)

\Rightarrow randomized O(n) expected time to get the k-rank element

FYI: Median of a scalar vector§

Deterministic algorithm

QuickSelect(A, k)
  Group the array into n/5 groups of size 5
  Find the median of each group  //Let M be the set of medians

  p = QuickSelect(M,k)  // median of the medians

  Split A into LESS and GREATER sets
  L =  number of elements in the LESS array
  if (L == k-1)
     return p;

  if (L > k-1)
     return QuickSelect(LESS, k)

  if (L < k-1)
     return QuickSelect(GREATER, k - L - 1)

\Rightarrow Deterministic O(n) time to get the k-rank element (details skipped but I encourage you to have a look!)

KdTree: Advantages/Drawbacks§

Range query in kd-Tree§

Algo

RangeQueryKdTree(node, Range)

  //Stop
  if node is a leaf
     return the p point in node if p in Range

  //left child
  if region(leftChild(node)) is fully contained in Range
     return all points in the subtree leftChild(node) //(A)
  else
     if region(leftChild(node)) intersects Range
       return RangeQueryKdTree( leftChild(node) , Range)

  //right child
  if region(rightChild(node)) is fully contained in Range
     return all points in the subtree rightChild(node) //(B)
  else
     if region(rightChild(node)) intersects Range
       return RangeQueryKdTree( rightChild(node) , Range)

Hints

Proof Ctd.§

Obs1 If l is vertical and the constraint of the root is vertical, l only crosses one of the root children regions

Obs2 If l is vertical and the constraint of the root is horizontal, l crosses both root children regions

\Rightarrow two step recurrence (sub-trees of depth 2 have n/4 points)

Q(n) = 2 + 2Q(n/4)

\Rightarrow Q(n) = O(\sqrt{n})\quad \Box

Thm.

Range tree structure in dimension d with O(n\log^{d-1}n) storage constructed in O(n\log^{d-1}n) can answer to hyperrectangular range queries in O(\log^dn + k).

Voronoi Diagram / Delaunay Triangulation§

(Some images from Olivier Devillers, INRIA Sophia-Antipolis)

Simple Construction§

Setting Given a set of sites \{S_i\}, answer to closest site queries

_images/delaunay-init.png

Simple Construction§

Setting Given a set of sites \{S_i\}, answer to closest site queries

_images/delaunay-1.png

Simple Construction§

Setting Given a set of sites \{S_i\}, answer to closest site queries

_images/delaunay-2.png

Simple Construction§

Setting Given a set of sites \{S_i\}, answer to closest site queries

_images/voronoi1.png

Simple Construction§

Setting Given a set of sites \{S_i\}, answer to closest site queries

_images/voronoi-delaunay.png

Closest site query§

Find closest site <=> point location in a Voronoi diagram

Key Property for Delaunay triangle/edges Empty circle property

_images/delaunay-empty.png

Remember the InCircle(p,q,r,s) predicate ?

InCircle predicate§

_images/orientation_circle.svg

Properties of the Delaunay Triangulation§

Triangulation where smallest angle is maximal

_images/smallest.png

true for all angles in lexicographic order

_images/smallest1.png _images/smallest2.png

Properties Ctd.§

Many deeper properties

Widely used for surface reconstruction and finite element computations for example

_images/meshing.png

Delaunay Construction§

Local Delaunay tests

Given a triangle T(a,b,c) and adjacent triangles T(a,b,p), T2(a,c,q) and T3(b,c,r), T is locally delaunay if InCircle predicates (a,b,c,p) (a,b,c,q) and (a,b,c,r) fails

Main result

Thm.

Everywhere locally Delaunay \Leftrightarrow Globally Delaunay

Naive Algorithm

Incremental Delaunay Construction§

Idea

SubProblems

returns the triangle T containing p

locally triangulate the one-ring of T + p

maintain Delaunay property

Detecting Conflicts§

_images/delinc1.png

Detecting Conflicts§

_images/delinc2.png

Detecting Conflicts§

_images/delinc3.png

Detecting Conflicts§

_images/delinc4.png

Overall Incremental Construction§

_images/delinc1.png

Overall Incremental Construction§

_images/delinc-hole.png

Overall Incremental Construction§

_images/delinc-add.png

Computational Cost§

Straightforward analysis

\Rightarrow O(n^2)

_images/delworstcase.png

Optimizing the Localization§

Main Idea

Straight-line walk§

Idea

_images/delwalk1.png _images/delwalk2.png _images/delwalk3.png _images/delwalkend.png

Important bad orientation predicates may lead to cycles in the walk…

Optimized walks§

Visibility walk

_images/delvis1.png _images/delvis2.png

Jump & Walk

Hierarchical structure

Delaunay Triangulation can be obtained in O(n \log n) (O(n) storage)

Alternative algorithms: Sweep lines§

Idea

_images/sweep1.png _images/sweep2.png
_images/sweep3.png _images/sweep4.png

Alternative algorithms: Divide and Conquer§

Idea

_images/deldivide.png _images/deldivide2.png
_images/deldivide3.png _images/deldivideend.png

Alternative algorithms: as Convex Hull in 3-space§

Idea