Game Development Reference
In-Depth Information
Figure 7.7 Line segment pointing away from the plane (a) and parallel to the
plane (b).
Also notice how if the dot product between and is zero, an illegal division by
zero will occur. Recall that a dot product of zero means the two vectors are per-
pendicular. In this particular case, this means that is parallel to the plane and
therefore cannot intersect with it, as in Figure 7.7(b) . The only exception to this
would be if the line segment is on the plane itself. In any event, this possibility
must be taken into account to prevent division by zero.
As an added bonus, if the line segment and plane do intersect, we can simply sub-
stitute the t value to get the actual point of intersection, as shown in Listing 7.3 .
Listing 7.3 Line Segment vs. Plane Intersection
Click here to view code image
// Return value is this struct
struct LSPlaneReturn
bool intersects
Vector3 point
end
// Remember "ray cast" actually refers to a line
segment!
Search WWH ::




Custom Search