i
i
i
i
i
i
i
i
746 16. Intersection Test Methods
In terms of code, this routine is fast, but it has the disadvantage of not
being able to return the intersection distance.
16.7.3 Ray Slope Method
In 2007 Eisemann et al. [301] presented a method of intersecting boxes that
appears to be faster than previous methods. Instead of a three-dimensional
test, the ray is tested against three projections of the box in two dimensions.
The key idea is that for each two-dimensional test, there are two box corners
that define the extreme extents of what the ray “sees,” akin to the silhouette
edges of a model. To intersect this projection of the box, the slope of the
ray must be between the two slopes defined by the ray’s origin and these
two points. If this test passes for all three projections, the ray must hit
the box. The method is extremely fast because some of the comparison
terms rely entirely on the ray’s values. By computing these terms once,
the ray can then efficiently be compared against a large number of boxes.
This method can return just whether the box was hit, or can also return
the intersection distance, at a little additional cost.
16.8 Ray/Triangle Intersection
In real-time graphics libraries and APIs, triangle geometry is usually stored
as a set of vertices with associated normals, and each triangle is defined
by three such vertices. The normal of the plane in which the triangle lies
is often not stored, in which case it must be computed if needed. There
exist many different ray/triangle intersection tests, and many of them first
compute the intersection point between the ray and the triangle’s plane.
Thereafter, the intersection point and the triangle vertices are projected
on the axis-aligned plane (xy, yz,orxz) where the area of the triangle
is maximized. By doing this, we reduce the problem to two dimensions,
and we need only decide whether the (two-dimensional) point is inside
the (two-dimensional) triangle. Several such methods exist, and they have
been reviewed and compared by Haines [482], with code available on the
web. See Section 16.9 for one popular algorithm using this technique. A
wealth of algorithms have been evaluated for different CPU architectures,
compilers, and hit ratios [803], and it could not be concluded that there is
a single best test in all cases.
Here, the focus will be on an algorithm that does not presume that nor-
mals are precomputed. For triangle meshes, this can amount to significant
memory savings, and for dynamic geometry, we do not need to recompute
any extra data, such as the plane equation of the triangle every frame. This
algorithm, along with optimizations, was discussed by M¨oller and Trum-