1

If you have a set of 'regular' connected triangles such as this:

geodesic mesh sphere

...and you know the vertices / normals of every triangle, what is an efficient method to test whether or not another point is 'inside' or 'contained within' the set of triangles?

Thanks!

HotDogCannon
  • 2,113
  • 11
  • 34
  • 53

1 Answers1

5

From the given point, cast a straight line. Test intersection of the line with every triangle and count all intersections found on the same side of the point. If this count is odd, you are inside.

To make computation easy, use x=x0, y=y0 for the line and project everything on the XY plane. Use How to determine if a point is in a 2D triangle? and finally check the z value of the intersection.

Community
  • 1
  • 1
  • 1
    It's the brute force approach. A more efficient approach (for large meshes and if there are enough location queries to amortize the initial cost) for ray casting would build a hierarchical spatial data structure (BSP tree, k-d tree, Octree) to cull lots of triangles during the query and significantly reduce the total number of ray / triangle intersection tests. Since here the ray direction is actually fixed, a simpler 2D spatial data structure in the xy plane could even be used instead. – user3146587 Jan 22 '14 at 18:01