Graphics Reference
In-Depth Information
Note that closest points between two objects can sometimes be maintained incre-
mentally at low cost, facilitating fast collision testing. Incremental computation of
closest points is further explored in Chapter 9, in the context of collision between
convex objects.
5.1.1 Closest Point on Plane to Point
Given a plane
π
, defined by a point P and a normal n , all points X on the plane satisfy
·
=
the equation n
0 (that is, the vector from P to X is perpendicular to n ).
Now let Q be an arbitrary point in space. The closest point R on the plane to Q is the
orthogonal projection of Q onto the plane, obtained by moving Q perpendicularly
(with respect to n ) toward the plane. That is, R
( X
P )
t n for some value of t ,as
illustrated in Figure 5.1. Inserting this expression for R into the plane equation and
solving for t gives:
=
Q
n
·
(( Q
t n )
P )
=
0
(inserting R for X in plane equation)
n
·
Q
t ( n
·
n )
n
·
P
=
0
(expanding dot product)
n
·
( Q
P )
=
t ( n
·
n )
(gathering similar terms and moving t expression to RHS)
t
=
n
·
( Q
P )/( n
·
n )
(dividing both sides by n
·
n )
=
Substituting this expression for t in R
Q
t n gives the projection point R as
R
=
Q
( n
·
( Q
P )/( n
·
n )) n .
When n is of unit length, t simplifies to t
=
n
·
( Q
P ), giving R as simply
R
=
Q
( n
·
( Q
P )) n . From this equation it is easy to see that for an arbitrary point
Q , t
P ) corresponds to the signed distance of Q from the plane in units of
the length of n .If t is positive, Q is in front of the plane (and if negative, Q is behind
the plane).
When the plane is given in the four-component form n
=
n
·
( Q
·
X
=
d , the corresponding
expression for t is t
n ). The code for computing the closest point
on the plane to a point therefore becomes:
=
(( n
·
Q )
d )/( n
·
Point ClosestPtPointPlane(Point q, Plane p)
{
float t = (Dot(p.n, q) - p.d) / Dot(p.n, p.n);
returnq-t*p.n;
}
 
Search WWH ::




Custom Search