4
votes

I've got a triangular mesh description of a surface. I also have a point P that lies outside the surface. How can I find the point on the surface that is closest to P?

I know how to find the closest vertex, but the closest point is probably between vertices. I also thought about doing a ray trace, but that won't always work since I don't know the direction.

4

4 Answers

4
votes

Finding the minimum distance to each triangle from the point and find the smallest minimum distance from them is the only way. This brute-force method will be very computationally expensive if you have many points to find the closest distance to the triangular mesh (which in turns could contain many many triangles). If you have multiple points, I suggested creating a octree for your triangle mesh first. This will speed up the minimum distance computation (for multiple points) a lot.

0
votes

I couldn't find anything built-in to matlab, but I found a description/video that may help you. Hopefully someone else can find something more useful if this is not enough. The website is here.

It looks like it's going to have to be an interative solution. If the link itself doesn't help, there were some comments left in that link that could be useful.

Hope this helps.

0
votes

You can minimize the distance to each triangle as discussed in this question.

0
votes

One possibility is to use user contributions from the FileExchange:

  • the function point2trimesh by Daniel Frisch returns the closest point on the mesh as second output. It is possible to use parallelization, making it rather fast
  • the function pointTriangleDistance by Gwendolyne Fischer processes only the case of a single face, but it is easy to extend to triangular meshes.