Game Development Reference
In-Depth Information
Figure 13: The point q on the plane (
n d ) near-
est to p . Observe that the shortest signed dis-
tance k from p to the plane is positive, since p
is in the positive half-space of (
n d ). If p was
behind the plane, then k <0.
From Figure 13 we can see that q = p +(- k n ), where k is the shortest
signed distance from p to the plane, which is also the shortest signed
distance between the points p and q . Recall that if the plane's normal
vector n is of unit length, then n p + d gives the shortest signed dis-
tance from the plane to the point p .
Rays (Optional)
Suppose a player in a game that we are working on fires his gun at an
enemy. How would we determine whether the bullet starting from a
particular position and aimed in a direction hit the target? One approach
would be to model the bullet with a ray and model the enemy with a
bounding sphere. (A bounding sphere is simply a sphere that tightly
surrounds an object, thus roughly approximating its volume. Bounding
spheres are explained more in Chapter 11.) Then mathematically we
can determine whether the ray hit the sphere and where. In this sec-
tion we learn how to model rays mathematically.
Rays
A ray can be described with an origin and a direction. The parametric
equation of a ray is:
(9)
p
t
0
p
t
u
Figure 14: A ray described by an origin p 0
and direction u . We can generate points
on the ray by plugging in scalars for t that
are greater than or equal to zero.
Search WWH ::




Custom Search