Effectively check if a point is inside a large number of triangles in 2D

I performed an algorithm to check if a point is inside a triangle in 2D, calling the first algorithm in this question: how to determine if a point is inside a two-dimensional triangle .

This algorithm works, but I think that if I pre-process the triangle and use an intelligent data structure, I can make it efficient. I use about 10 million triangles. I think one way to do this quickly is to calculate the bounding rectangles for the triangles and check the points in the rectangle, but I feel that even this case can be done faster using some data structure to check only close rectangles.

Is there such a data structure and algorithm?

+6
source share
1 answer

The classic approach from computational geometry is to triangulate and then to the location point, but it’s much easier to just use the kd tree , placing the triangles that intersect the dividing line of the internal tree with node so that they can be checked on the way down to the leaves.

k-d . (x y, ), , , , . , . , . (, ) .

, , . , , . , .

+5

Source: https://habr.com/ru/post/1016218/


All Articles