Archived

This topic is now archived and is closed to further replies.

Eddie_cz

Ray-Triangle Intersection failure on edge

Recommended Posts

Eddie_cz    122
I tried plenty of algorithms for ray-triangle intersection but all of them fail when intersection point lies on triangle edge. Does anybody know algorithm which works in such case? Thanks, Eddie

Share this post


Link to post
Share on other sites
janos    224
do an if before dividing by 0!!.
Or make sure that the intersection is inside before trying to compute the uv.

Share this post


Link to post
Share on other sites
Eddie_cz    122
I meant that those algorithms returns false in some cases when intersection point is on triangle edge...maybe there is problem with precision, although all computations are done in double precision.

Share this post


Link to post
Share on other sites
janos    224
it is a precision problem.
it cannot be solve whatever precision you choose.
Howver, you can have a seamless alogorithm in the sense that errors compensate, so that if two triangles share an edge, no rays will slip through the seam, and no rays will hit both triangles.

if you only test individual triangles, try adding an small edge around it

Share this post


Link to post
Share on other sites
shadow12345    100
typically you have to add a tolerance variable, which is equivalent to adding an ''edge'' to the triangle.

For example,
if you want to do the TWOPi method, where you sum angles and the angles must be TWOPI, well, they are rarely equal to TWOPI the closer you get to an edge.

Subsequently, your angle must be greater than TWOPI - Tolerance and less than TWOPI + Tolerance.

Share this post


Link to post
Share on other sites