looking for a computational geometry library

Hello,

I need to perform computational geometry computations in a Unity program, including

  • 3D delaunay triangulation,
  • clip meshes with planes (both with and without “capping”), and
  • 2D triangulation of polygons (polygons could be concave and have holes).

I cannot find a mature dot-net library for doing this sort of things.

Could you please recommend a suitable dot-net library?

I think of using VTK and calling it as a DLL from Unity. Probably I will need to build a C (as opposed to C++) interface between the two worlds. Is it a sane approach?

Many thanks,

leonid

For general 2d (3d sort of if on a plane) triangulation I recommend this as most robust and C# friendly: GitHub - speps/LibTessDotNet: C# port of the famous GLU Tessellator - prebuilt binaries now available in "releases" tab
I think Unity’s SVG code uses it.
Otherwise options like poly2tri (used by other assets) cover delaunay but I found it not to be robust in some cases (even LibTessDotNet failed at times without using Double instead of float), so depends on what data is put into it and how close edges and verts come.

For full on 3D I have not found - in some cases you can do on a 2d plane and then project into 3d

I would love to see someone come up with a robust, fast and gc-friendly triangulation lib for C#/Unity that covers the complete set of 2d triangulation needs.

Thank you, andyz!