## .NET Tips - Delaunay Triangulation in .NET 2.0

*by Morten Nielsen, March 8 2006.*
Based on an article by
Paul Bourke, I've created a .NET 2.0 library
to triangulate point data. The library includes a small Windows Forms example showing how the library works.

Using the generic point type '**Point<T>**' you can triangulate points with any attribute added to it. For instance to
triangulate points with a Z-height, create a list with double-types for Z like this:

List<Point<double>> Vertices = new List<Point<double>>();
//Add vertices ...
//Do triangulation
List<Triangulator.Geometry.Triangle> tris = Triangulator.Delauney.Triangulate(Vertices);

Otherwise you can just derive from and extend the 'Geometry.Point' class to triangulate points with more methods and properties.

The Delauney triangulation doesn't handle duplicate points very well (that is multiple points whose X and Y properties are equal). Luckily
we now have anonymous methods to set up a simple predicate to check if we already have a point in my list before I add it:

Triangulator.Geometry.Point pNew = new Triangulator.Geometry.Point(234.4,782.1); //New point to add
if(!Vertices.Exists(delegate(Triangulator.Geometry.Point p) { return pNew.Equals2D(p); }))
Vertices.Add(pNew);

The library can be downloaded here including a small demo-app. Feel free to use it as you like.