Delaunay Triangulation in .NET 2.0

by Morten 3/9/2006 10:26:00 AM

Based on an article by Paul Bourke, I've created a small light-weight .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.

Currently rated 4.7 by 3 people

  • Currently 4.666667/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

GIS

Comments are closed

Powered by BlogEngine.NET 1.4.5.0


Join the plan!

Recent Comments

Comment RSS

About the author

Morten Nielsen Morten Nielsen
<--That's me
E-mail me Send mail

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008