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

voronoi.update? #74

Closed
mbostock opened this issue Jul 5, 2019 · 2 comments
Closed

voronoi.update? #74

mbostock opened this issue Jul 5, 2019 · 2 comments
Labels
enhancement New feature or request

Comments

@mbostock
Copy link
Member

mbostock commented Jul 5, 2019

How is delaunay.update supposed to interact with delaunay.voronoi? I assume you are expected to call delaunay.voronoi again after calling delaunay.update, but it’d be nice if there were an equivalent voronoi.update method.

@mourner mourner added the enhancement New feature or request label Jul 5, 2019
@mourner
Copy link
Collaborator

mourner commented Jul 5, 2019

Yeah, adding an update method would allow us to avoid repeated allocation of these two arrays:

const circumcenters = this.circumcenters = new Float64Array(triangles.length / 3 * 2);
const vectors = this.vectors = new Float64Array(points.length * 2);

triangles may slightly vary from update to update, but is close to the max (2 * numPoints - 5), so we could do the same trick as Delaunator — allocate a maximum length circumcenters array as a private property and then expose a trimmed one as voronoi.circumcenters, referencing the same memory (with subarray).

Fil added a commit that referenced this issue Jul 9, 2019
@Fil Fil closed this as completed in 188a5c5 Jul 9, 2019
@mbostock
Copy link
Member Author

mbostock commented Jul 9, 2019

Works great! ❤️

https://observablehq.com/@mbostock/meandering-voronoi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

2 participants