libigl-python-bindings icon indicating copy to clipboard operation
libigl-python-bindings copied to clipboard

The result of ray_mesh_intersect is problematic.

Open xchen-cs opened this issue 4 years ago • 1 comments

igl version: 2.2.0 The result of ray_mesh_intersect seems problematic. The following example computes the intersection between a box and a ray:

import igl
import numpy as np

v = np.array([[0., 0., 0.],[0., 0., 1.],[0., 1., 0.],[0., 1., 1.],[1., 0., 0.],[1., 0., 1.],[1., 1., 0.],[1., 1., 1.]])
f = np.array([[0, 6, 4],[0, 2, 6],[0, 3, 2],[0, 1, 3],[2, 7, 6],[2, 3, 7],[4, 6, 7],[4, 7, 5],[0, 4, 5],[0, 5, 1],[1, 5, 7],[1, 7, 3]], dtype=int)
ray_o = np.array([0.5, 0.1, 10.])
ray_d = np.array([0., 0., -1.])
hits = igl.ray_mesh_intersect(ray_o,ray_d,v,f)
print(hits)

The result is [(10, -1, 0.4000000059604645, 0.10000000149011612, 9.0), (8, -1, 0.10000000149011612, 0.5, 9.5)], where the second hit with t=9.5 is clearly incorrect.

xchen-cs avatar Dec 23 '20 14:12 xchen-cs

Trimesh also encounters issues with embree ray intersection results. They bypass the issue by treating embree as "just" an intersection detector (yes/no intersection of ray w/ geometry), retrieve the face_idx, and manually compute the surface & ray intersection location using python.

aluo-x avatar Feb 20 '21 02:02 aluo-x

Should be fixed https://github.com/libigl/libigl-python-bindings/issues/106#issuecomment-1733713515

alecjacobson avatar Sep 25 '23 13:09 alecjacobson