johnmccutchan/vector_math — pull request #43 by AMagill (2013-11-14 11:11:19+00:00)
Title: Loosened tolerances of Ray::intersectsWithTriangle() a hair.

I'm trying to compute ray intersections through polygons in a closed, manifold mesh, and I've found and solved two problems in vector_math.

First, Ray::intersectsWithTriangle() was rejecting an intersection I was certain was valid (see screenshot). I found it was computing 'a' as 0.00007322, and rejected the intersection because it interpreted that as meaning the ray and triangle are perfectly parallel. EPSILON = 10e-5 rejects too many such glancing intersections and needs to be made smaller.

Second, I found problems where rays could pass through along the edge of two adjacent triangles and fail to detect an intersection with either one. It seems the culprit here is rounding error in computing the intersection's barycentric coordinates; both intersections were computed to be just slightly outside their borders. Expanding them infinitesimally solves this.

![image](https://f.cloud.github.com/assets/1924184/1540120/abb4e8ca-4d19-11e3-9e33-69f813d8f3a1.png)