A simple Delaunay 2D triangulation in python (with numpy)
Switch branches/tags
Nothing to show
Latest commit 2066ec0 Nov 6, 2017
 Failed to load latest commit information. .gitignore Dec 13, 2016 LICENSE Dec 13, 2016 README.md Nov 6, 2017 delaunay2D.py Jun 21, 2017 delaunay2D_miniDemo.py Jun 21, 2017 delaunay2D_plotDemo.py Jun 22, 2017 output-delaunay2D.png Dec 15, 2016

# PyDelaunay2D

A Simple Delaunay triangulation and Voronoi diagram constructor in 2D. Written by Jose M. Espadero

Just pretend to be a simple and didactic implementation of the Bowyer-Watson algorithm to compute the Delaunay triangulation and the Voronoi diagram of a set o 2D points.

It is written in pure python + numpy (tested with python2.7 and python3). A test example is provided showing how to call and plot the results using matplotlib.

It support the robust inCircle2D predicate from Jonathan Richard Shewchuk, but it is disabled by default due to perfomance penalties, so do not expect to work on degenerate set of points. If you really need to compute triangulation on big or degenerate set of points, try scipy.spatial.Delaunay instead.

## Is it fast?

No. This code has been written to stay clear, easy to read by novices, instead of highly-optimized. There is a section in `addPoint()` that performs specially bad:

```    # Search the triangle(s) whose circumcircle contains p
for T in self.triangles:
if self.inCircle(T, p):

Here, we should avoid iterating over the complete list of triangles. Best way is to use a structure that allows a spatial search (as a QuadTree). Then, continue the search over the neighbours of the initial search.

Despite that, it will compute DT of less than 1000 points in a reasonable time.

Again, just pretend to keep the code simple, didactic and with minimal dependencies.

## Why did you write it?

Mainly, to provide a didactic implementation of the algorithm. You can use:

```import numpy as np
from delaunay2D import Delaunay2D

# Create a random set of points
seeds = np.random.random((10, 2))

# Create delaunay Triangulation
dt = Delaunay2D()
for s in seeds: