Game Development Reference
In-Depth Information
}
e l s e {
minD
+=
n . z max . z ;
maxD
+=
n . z min . z ;
}
/ /
Check
i f
c o m p l e t e l y
on
t h e
f r o n t
s i d e
o f
t h e
p l a n e
i f
( minD > =
d )
{
r e t u r n
+ 1 ;
}
/ /
Check
i f
c o m p l e t e l y
on
t h e
back
s i d e
o f
t h e
p l a n e
i f
( maxD < =
d )
{
r e t u r n
1;
}
/ / We
s t r a d d l e
t h e
p l a n e
r e t u r n
0 ;
}
Listing A.2
Detecting static intersection of AABB and plane
A dynamic test is just one step further. Let's consider the plane to be
stationary (recall from Section A.6 that it is simpler to view the test from
the frame of reference of one of the moving objects). The displacement of
the box will be defined by a unit vector d and a length l. As before, we first
locate the corner points with the minimum and maximum dot products and
check for an intersection at t = 0. If the box is not initially intersecting the
plane, then it must first strike the plane at the corner point closest to the
plane. This will be one of the two corner points identified in the first step.
If we are interested only in colliding with the “front” of the plane, then we
can always use the corner with the minimum dot product value. Once we
have determined which corner will strike the plane, we use the ray-plane
intersection test in Section A.9.
A.11
Intersection of Three Planes
In 3D, three planes intersect at a point, as shown in Figure A.7.
Let the three planes be defined implicitly as
p n 1 = d 1 ,
p n 2 = d 2 ,
p n 3 = d 3 .
Although we usually use unit vectors for the plane normals, in this case it
is not necessary that n i be of unit length. These three plane equations give
us a system of linear equations with three equations and three unknowns
(the x-, y-, and z-coordinates of the point of intersection). Solving this
system of equations yields the following result, from Goldman [24]:
p = d 1 ( n 2
× n 3 ) + d 2 ( n 3
× n 1 ) + d 3 ( n 1
× n 2 )
Three planes intersect at
a point
.
( n 1 × n 2 ) n 3
Search WWH ::




Custom Search