fwilliams / point-cloud-utils

An easy-to-use Python library for processing and manipulating 3D point clouds and meshes.
https://www.fwilliams.info/point-cloud-utils/
MIT License
1.33k stars 107 forks source link

what's the difference between pcu.RayMeshIntersector and pcu.ray_mesh_intersection? I seemed to get different results using them both. #101

Open zhangzc19 opened 1 week ago

zhangzc19 commented 1 week ago

I ran the code below, but i got two different fid results. One result is -1 and the other is 663153. Is it possible that passing only one ray leads to this problem?

ply_area = trimesh.load(ply_path)
ray_origin = start_point
vector = end_point - start_point
ray_direction = vector / np.linalg.norm(vector)
v = treatment_area.vertices
f = treatment_area.faces
fid, bc, t = pcu.ray_mesh_intersection(v,f,ray_origin.reshape(1,3),ray_direction.reshape(1,3))
print(fid)
intersector = pcu.RayMeshIntersector(v, f)
fid, bc, t = intersector.intersect_rays(ray_origin.reshape(1,3),ray_direction.reshape(1,3))
print(fid)
zhangzc19 commented 1 week ago

I visualize intersection result and find the latter fid is right.