Game Development Reference
In-Depth Information
Figure A.7
Three planes intersect at a point
in 3D
If any pair of planes is parallel, then the point of intersection either does not
exist or is not unique. In either case, the triple product in the denominator
is zero.
A.12
Intersection of Ray and a Circle or Sphere
This section discusses how to compute the intersection of a ray and a circle
in 2D. This also works for computing the intersection of a ray and a sphere
in 3D, since we can operate in the plane that contains the ray and the center
of the circle and turn the 3D problem into a 2D one. (If the ray lies on a
line that passes through the center of the sphere, the plane is not uniquely
defined. This not a problem, however, because any of the infinitely many
planes that pass through the ray and the center of the sphere can be used.)
We will use a construction inspired by Hultquist [36]; see Figure A.8.
The sphere is defined by its center c and radius r, and the ray is defined by
p (t) = p 0 + t d .
In this case, we use a unit vector d and vary t from 0 to l, where l is the
length of the ray.
We are solving for the value of t at the point of intersection. Clearly,
t = a − f. We can compute a as follows. Let e be the vector from p 0 to c :
e = c p 0 .
 
Search WWH ::




Custom Search