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

Identify a certain triangle #21

Open
holmhaavard opened this issue Oct 14, 2019 · 2 comments
Open

Identify a certain triangle #21

holmhaavard opened this issue Oct 14, 2019 · 2 comments

Comments

@holmhaavard
Copy link

Hello,
If I have a large number of triangles and want to find which triangle encapsulates a certain point. What is the best method to do that ?

eg. I triangulated a domain ❌0-1, y:0-1 and want to find which triangle that enclose the point 0.1, 0.1. Are there routines sin delaunator to do that efficiently ?

@abellgithub
Copy link

No. There are fast point-in-triangle algorithms. You can look here:

https://github.com/PDAL/PDAL/blob/master/filters/HAGFilter.cpp

Though filtering by box containment before doing any multiply/divide would probably be advisable.

@lauraxinzhang
Copy link

@holmhaavard I'm a bit late to the game, but the way that triangles are stored in this particular implementation of the Delauney actually makes it very easy to "walk on a triangulation". This is because you can very easily find the neighbor triangle that shares a particular edge with. You get an average constant time access with it.

You can find a lot of resources on this with a quick google search. But here's the basic algorithm:

  • You want to locate point P in the triangulation.
  • Start from any triangle t, find point P0 that's in t. (centroid, for example)
  • connect P and P0. Find the edge e in t that P-P0 intersects with
  • Walk to the other triangle that shares e with t
  • repeat.

To OP: thanks for this great library! It's very easily workable and made my life a lot easier.

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

3 participants