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

Adding points incrementally without retriangulating #105

Closed
Kebabrulle4869 opened this issue Feb 14, 2020 · 3 comments
Closed

Adding points incrementally without retriangulating #105

Kebabrulle4869 opened this issue Feb 14, 2020 · 3 comments

Comments

@Kebabrulle4869
Copy link

Hello!

I've been using this library for my "gymnasiearbete", a final work during Swedish high school, and I've had great success in doing so. However, I can't quite figure out how to add points incrementally to the triangulation without redoing the entire thing. I'm guessing that this is possible with this library somehow, based on the demo. I would imagine you're using some functionality I've missed in the library, and if you're not and you're just retriangulating after every new point, I think a function that could add a single point quickly to an existing triangulation would be very welcome.

More specifically, I'm using this library to randomly place points in the plane with a minimum distance between them. Using this library, I can make a triangulation of the existing points, then find the nearest point to the new candidate point, and check the distance between them. I think this would be more effective if I could figure out how to add points incrementally, and be able to execute other functions between adding points. I've already tried using .update(), but it seems to only work when moving points, not adding points.

Sorry if this is the wrong place to ask this sort of thing - I'm not too familiar with using github, and thank you in advance.

@mbostock
Copy link
Member

I don’t think that’s possible with the sweep-line algorithm used by this library, but the place to file this request would be over in mapbox/delaunator.

@mbostock
Copy link
Member

(Also this library is very fast, so unless you have a lot of points, recomputing the triangulation from scratch is unlikely to be a problem.)

@Fil
Copy link
Member

Fil commented Feb 14, 2020

A small addition: if you want to use delaunay.update(), it's true that you need to make sure that the number of points does not increase. But it doesn't means you can't "add" points: the trick is to reserve enough space by instantiating the coordinates array with enough duplicates of (for instance) the first point; then you can inject the new points in those reserved slots.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants