Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convenience delaunay.edges() function? #135

Open
Fil opened this issue May 29, 2022 · 0 comments
Open

convenience delaunay.edges() function? #135

Fil opened this issue May 29, 2022 · 0 comments
Labels
question Further information is requested

Comments

@Fil
Copy link
Member

Fil commented May 29, 2022

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()
  ];
@Fil Fil added the question Further information is requested label Mar 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Development

No branches or pull requests

1 participant