Reputation: 1
I'm using trimesh
to find the closest point on a mesh to a given point,
closest_vertex, d, face_id = trimesh.proximity.closest_point(mesh, [[-5,100,0]])
That's my code for that bit I get an point back from this code and it displays fine on a graph as well. However when I look at the stl
file to figure out the point index, the point does not exist.
Any help would be awesome!
I expect to find this point in the stl as after all it still is returning the closest point.
Upvotes: -1
Views: 84
Reputation: 1003
As per documentation :
Given a mesh and a list of points find the closest point on any triangle.
So it is finding the closest point on your trimesh surface, not the closest vertex. This is why you are not finding the point in your STL file.
To find the nearest vertex, you'll probably need to write a small function for this :
import numpy as np
def find_closest_vertex(mesh, poi):
idx = np.argmin(np.linalg.norm(mesh.vertices-poi, 2))
return mesh.vertices[idx, :]
Upvotes: 0