This module provides functionality for working with Delaunay triangulations.

You can:
TriangularMeshThe current implementation is somewhat inefficient, but there are plans to speed it up in the future (without requiring any changes to the API).
An error type indicating that the two given vertices have the same position.
All the details about a particular face of a Delaunay triangulation:
Triangle2d defining its shapeConstructing a Delaunay triangulation from points/vertices is currently an O(n^2) operation but should be O(n log n) in the future.
An empty Delaunay triangulation with no vertices or faces.
Construct a Delaunay triangulation from an array of points. The points must
all be distinct; if any two points are equal, you will get an Err
CoincidentVertices.
Note that if all points are collinear, then the resulting triangulation will be empty (have no faces).
Construct a Delaunay triangulation from an array of vertices of arbitrary
type, by supplying a function that returns the position of each vertex as a
Point2d. For example, if you had
types alias Vertex =
{ position = Point2d Meters WorldCoordinates
, color = String
}and
vertices : Array Vertex
vertices =
...then you would use
DelaunayTriangulation2d.fromVerticesBy .position
verticesThe vertices must all be distinct; if any two have the same position, you will
get an Err CoincidentVertices.
Note that if all vertices are collinear, then the resulting triangulation will be empty (have no faces).
Inserting a point into a Delaunay triangulation is currently an O(n) operation but should be O(log n) in the future.
Add a new point into an existing Delaunay triangulation. It must not be
equal to any existing point; if it is, you will get an Err CoincidentVertices.
Add a new vertex into an existing Delaunay triangulation, by supplying a
function to get the position of the vertex. The vertex must not have the same
position as any existing vertex; if it is, you will get an Err
CoincidentVertices.
Get the vertices of a Delaunay triangulation. If the triangulation was
constructed by calling fromPoints or fromVerticesBy, then the returned
vertex array will simply be the array that was passed in. If any vertices were
added using insertPoint or insertVertexBy, then they will be appended to
the end of the array. This is a simple accessor, so complexity is O(1).
Get all triangles in a given Delaunay triangulation;
DelaunayTriangulation2d.triangles triangulationis equivalent to
DelaunayTriangulation2d.faces triangulation
|> List.map .trianglebut somewhat more efficient. Complexity: O(n).
Get all circumcircles in a given Delaunay triangulation;
DelaunayTriangulation2d.circumcircles triangulationis equivalent to
DelaunayTriangulation2d.faces triangulation
|> List.map .circumcirclebut somewhat more efficient. Complexity: O(n).
Get a list of all Faces in a given Delaunay triangulation. Complexity:
O(n).
Convert a Delaunay triangulation to a TriangularMesh.
Complexity: O(n).
A 2D Delaunay triangulation of a set of vertices.