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

Does this support constrained delaunay triangulation? #14

Open
SimonEast opened this issue Feb 10, 2023 · 2 comments
Open

Does this support constrained delaunay triangulation? #14

SimonEast opened this issue Feb 10, 2023 · 2 comments

Comments

@SimonEast
Copy link

I've had a quick look into your library, which looks impressive.

I'm wondering about whether it's possible to "constrain" certain vertices so that contours may not cross those lines. This is important when you want to generate contours for real world terrain and ensure that contours don't accidentally cross over a ridgeline or valley.

Is it true that this library uses d3-delaunay for the triangulation? Perhaps if that library doesn't support it, I wonder if cdt-js might be able to swapped in as a replacement triangulation library.

Has anyone had any experience with this?

@Fil
Copy link
Owner

Fil commented Feb 10, 2023

Yes we use d3-delaunay, which doesn't do CDT. cdt-js seems nice but it's an app, not an API, so it looks like it would be a lot of work to swap it in? But please report any progress you do with that.

Note that an alternative way to generate something similar to tricontours is now available with Observable Plot, using the Plot.contour mark. This mark subsumes both d3-contour (applying marching squares on gridded points) and partially d3-tricontour (by applying a barycentric interpolation on non-gridded points). A lower-level API is available if you need the interpolated values to be returned as a grid: see interpolatorBarycentric. It's not doing meandering triangles though, so not a pure replacement for d3-tricontour.

@SimonEast
Copy link
Author

cdt-js seems nice but it's an app, not an API

Oh yes, you're right. I thought it existed as a standalone library, but apparently not yet. 🤔

And thanks for the tip about Plot.contour. I will keep that in mind as I'm exploring options.

In theory, I might be able to implement constraining by injecting a series of interpolated points along each vertex that needs to be constrained. That might work. I'll have a play when I get available time and see how it goes.

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

No branches or pull requests

2 participants