Graphics Reference
In-Depth Information
gives both implicit and parametric descriptions for spheres and ellipsoids, and
parametric descriptions of several other common shapes like cylinders, cones, and
toruses. These, and more general implicit surfaces, are discussed in Chapter 24.
14.5.2.1 Ray-Tracing Implicit Surfaces
Implicit surface models are useful for ray casting and other intersection-based
operations. For ray tracing, we take the parametric form of the ray with origin A
and direction
v
,
g ( t )= A + t
,
(14.5)
v
and solve for the point at which it intersects the plane by substituting into the
plane's implicit form and finding the roots of the resultant expression. We want to
find a value t for which f ( g ( t )) = 0. That means
( g ( t )
Q )
·
n = 0, i.e.,
(14.6)
( A + t
v
Q )
·
n = 0, so
(14.7)
t = ( Q
A )
·
n
.
(14.8)
v ·
n
We can follow the same process for any surface whose equation admits an
efficient closed-form solution after substituting the ray's parametric form.
For a sphere of radius r about the point Q , we can use the implicit form f ( P )=
2
r 2 . Substituting the parametric form for the ray, and setting to zero,
Q
P
we get
2
r 2
0 =
( A +
t )
Q
(14.9)
v
r 2 =
2
( A
Q )+
t
(14.10)
v
r 2 =
2 + 2 t ( A
2 t 2
( A
Q
Q )
· v
+
v
(14.11)
2
r 2 )+ 2 t ( A
2 t 2 .
0 =(
( A
Q
Q )
· v
+
v
(14.12)
This is a quadratic equation in t , at 2 + bt + c = 0, where a =
v
2 , b =
( A
r 2 . It can be solved with the quadratic formula
to find all intersections of the ray with the sphere.
Q )
· v
, and c =
( A
Q
2
Inline Exercise 14.1:
(a) Write out the solutions using the quadratic formula, and simplify.
(b) What does it mean if one of the roots of the quadratic equation is at a value
t
0? What about t = 0?
(c) In general, if b 2
<
4 ac = 0 in a quadratic equation, there's only a single
root. What does this correspond to geometrically in the ray-sphere intersection
problem?
More general quadratics can be used to determine intersections with ellipsoids
or hyperboloids, while higher-order polynomials arise in determining the intersec-
tion of a ray with a torus, for example, and for more general shapes, the equation
we must solve can be very complicated. Multiple roots of the equation that results
from substituting the parametric line form into the function defining the implicit
surface indicate multiple potential intersections. See Chapter 15 for further dis-
cussion of ray casting and interpreting its results.
 
 
Search WWH ::




Custom Search