Home

Awesome

Delaunator C#

openupm

Fast Delaunay triangulation of 2D points implemented in C#.

This code was ported from Mapbox's Delaunator project (JavaScript).

<p float="left" align="middle"> <img src="https://raw.githubusercontent.com/nol1fe/delaunator-sharp/master/Images/Delaunator_Unity_Example.gif" height="400" width="410"> <img src="https://raw.githubusercontent.com/nol1fe/delaunator-sharp/master/Images/Delaunator_Unity_Example_Mesh.gif" height="400" width="410"> </p>

Documentation

See https://mapbox.github.io/delaunator/ for more information about the Triangles and Halfedges data structures.

Unity Installation

Simply edit manifest.json file in your Unity Packages directory

{
  "dependencies": {
    "com.nol1fe.delaunator": "https://github.com/nol1fe/delaunator-sharp.git?path=DelaunatorSharp.Unity",
}

Unity Example

From UnityPackage Menager select Delaunator and press "Import into Project".

<p float="left" align="middle"> <img src="https://raw.githubusercontent.com/nol1fe/delaunator-sharp/master/Images/Delaunator_Package%20Manager.png" height="300" width="450"> </p>

Burst Triangulator (optional)

For Unity developers seeking even greater performance and advanced triangulation capabilities, consider exploring BurstTriangulator.

Built with Unity's Burst compiler, it offers lightning-fast triangulation, making it ideal for large datasets and real-time applications.

WPF Example

There is available playground in DelaunatorSharp.WPF.Example project that shows examples of drawing Voronoi Diagram, Delaunay triangulation and Convex Hull

<p float="left" align="middle"> <img src="https://raw.githubusercontent.com/nol1fe/delaunator-sharp/master/Images/Delaunator_Rectangle.png" height="200" width="200"> <img src="https://raw.githubusercontent.com/nol1fe/delaunator-sharp/master/Images/Delaunator_Circle.PNG" height="200" width="200"> </p>

Points were generated with Poisson Disc Sampling implemented by UniformPoissonDiskSampler

Performance

BenchmarkDotNet=v0.12.1, OS=Windows 10.0.19043
11th Gen Intel Core i7-11800H 2.30GHz, 1 CPU, 16 logical and 8 physical cores .NET Core SDK=5.0.401
MethodCountTypeMeanErrorStdDev
Delaunator100000Uniform63.66 ms21.68 ms14.34 ms
Delaunator100000Gaussian62.07 ms21.60 ms14.29 ms
Delaunator100000Grid46.88 ms18.53 ms12.25 ms
Delaunator1000000Uniform658.91 ms41.11 ms27.19 ms
Delaunator1000000Gaussian680.02 ms96.03 ms63.52 ms
Delaunator1000000Grid516.89 ms60.64 ms40.11 ms

NuGet

https://www.nuget.org/packages/Delaunator/