Game Development Reference
In-Depth Information
t value:
t =
d
(
q
−
p
org
)
d
.
A.3
Closest Point on a Plane
Consider a plane P defined in the standard implicit manner as all points
p
that satisfy
p
n
= d,
′
where
n
is a unit vector. Given a point
q
, we wish to find the point
q
,
′
which is the result of projecting
q
onto P. Point
q
is the closest point to
q
on P.
We showed how to compute the distance from a point to a plane in
Section 9.5.4. To compute
q
′
, we simply displace
q
by this distance, parallel
to
n
.
Computing the closest
point on a plane
′
q
=
q
+ (d −
q
n
)
n
Notice that this is the same as Equation (A.1), which computes the closest
point to an implicit line in 2D.
A.4
Closest Point on a Circle or Sphere
Imagine a 2D point
q
and a cir-
cle with center
c
and radius r.
(The following discussion also
applies to a sphere in 3D.) We
wish to find
q
′
, which is the
closest point on the circle to
q
.
Let
d
be the vector from
q
to
c
. This vector intersects the
circle at
q
′
. Let
b
be the vec-
tor from
q
to
q
′
, as shown in
Figure A.3
Finding the closest point on a circle
Figure A.3.
Now, clearly,
b
=
d
−r.
Therefore,
d
− r
b
=
d
.
d
Search WWH ::
Custom Search