d3-delaunay
d3-delaunay copied to clipboard
convenience delaunay.edges() function?
Currently to get a list of all edges (say to reproduce "links" in d3-voronoi) you need to write something like:
{
const { halfedges, triangles, hull } = d3.Delaunay.from(points);
return [
...Array.from(hull, (i, k) => [i, hull[(k + 1) % hull.length]]),
...Array.from(halfedges, (i, j) => i > j ? [[triangles[i], triangles[j]]] : []).flat()
].map(([i, j]) => ({ source: points[i], target: points[j] }));
}
What about making this into a convenience method delaunay.edges:
[
...Array.from(hull, (i, k) => [i, hull[(k + 1) % hull.length]]),
...Array.from(halfedges, (i, j) => i > j ? [[triangles[i], triangles[j]]] : []).flat()
];