Game Development Reference
In-Depth Information
( a . max . y < b . min . y ) || ( b . max . y <
a . min . y )
return ! test
end
It's worth mentioning that AABB-AABB intersection is actually a very special
application of an algorithm known as the separating axis theorem. In the general
form, this theorem can actually be used on any type of convex polygon, though the
details of it are beyond the scope of this topic.
Line Segment versus Plane Intersection
Checking whether a line segment collides with a plane is a relatively common col-
lision test in games. In order to understand how the algorithm for this works, it is
useful to derive the formula using some linear algebra. First, we have the separate
equations of a line segment and a plane:
We want to find out if there is a value t such that R ( t ) is a point on the plane. In
other words, we want to determine if there is a possible value of t where R ( t ) sat-
isfies the P part of the plane equation. This can be done by substituting R (t) for P :
Then it is just a matter of solving for t :
Remember that for a line segment, the start point corresponds to t = 0, whereas the
end point corresponds to t = 1. So when we solve for t , if we get a value that's out-
side of that range, it should be ignored. Specifically, a negative value means that
the line segment is actually pointing away from the plane, as in Figure 7.7(a) .
Search WWH ::




Custom Search