








Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The essential procedures for rendering surfaces via ray tracing in computer graphics: computing surface normals and calculating ray-surface intersections. Four standard ways to represent surfaces are presented, including implicit equations, parametric equations, deformations of known surfaces, and specialized procedures. The focus is on parametric surfaces and their intersection with rays.
Typology: Study notes
1 / 14
This page cannot be seen from the preview
Don't miss anything!









Lecture 18: Surfaces I -- The General Theory
Thou hast set all the borders of the earth: Psalm 74:
1. Surface Representations
Recursive ray tracing is a technique for displaying realistic images of objects bordered by
surfaces. To render surfaces via ray tracing, we require two essential procedures: we must be able
to compute surface normals and we need to calculate ray-surface intersections.
There are four standard ways to represent surfaces in Computer Graphics: implicit equations,
parametric equations, deformations of known surfaces, and specialized procedures. In this lecture
we shall review each of these general surface types and in each case explain how to compute surface
normals and how to calculate ray-surface intersections. To facilitate further analysis, at the end of
this lecture we shall also provide explicit formulas for mean and Gaussian curvature.
1.1 Implicit Surfaces. Planes, spheres, cylinders, and tori are examples of implicit surfaces. An
implicit surface is the collection of all points P satisfying an implicit equation of the form
Typically, the function F is a polynomial in the coordinates
x , y , z of the points P. For example, a
sphere can be represented by the implicit equation
F ( x , y , z ) ≡ x
2
2
2 − 1 = 0.
Generating lots of points along an implicit surface may be difficult because for complicated
expressions F it may be hard to find points
P for which
F ( P ) = 0. On the other hand, determining
if a point
P lies on an implicit surface is easy, since we need only check if
F ( P ) = 0. Moreover
points on different sides of an implicit surface are distinguished by the sign of F ; for closed
surfaces
F ( P ) < 0 may indicate points on the inside, whereas
F ( P ) > 0 may indicate points on the
outside. This ability to distinguish inside from outside is important in solid modeling applications.
1.2 Parametric Surfaces. Planes, spheres, cylinders, and tori are also examples of parametric
surfaces. A parametric surface is a surface represented by parametric equations -- that is, to each
point P on the surface, we assign a pair of parameter values
s , t so that there is a formula
P = P ( s , t )
for computing points along the surface. In terms of rectangular coordinates, the equation
P = P ( s , t ) is equivalent to three parametric equations for the coordinates:
x = p 1
( s , t ), y = p 2
( s , t ), z = p 3
( s , t ). In Computer Graphics, the functions
p 1
( s , t ), p 2
( s , t ), p 3
( s , t )
are typically either polynomials or rational functions -- ratios of polynomials -- in the parameters
s , t. For example, a sphere can be represented by the parametric equations
x ( s , t ) =
2 s
1 + s
2
2
y ( s , t ) =
2 t
1 + s
2
2
z ( s , t ) =
1 − s
2 − t
2
1 + s
2
2
since it is easy to verify that
x
2 ( s , t ) + y
2 ( s , t ) + z
2 ( s , t ) = 1.
Generating lots of points along a parametric surface is straightforward: simply substitute lots
of different parameter values
s , t into the expression
P = P ( s , t ). Thus parametric surfaces are easy
to display, so parametric surfaces are a natural choice for Computer Graphics. However,
determining if a point
P is on a parametric surface is not so simple, since it may be difficult to
determine whether or not there are parameters
s , t for which
P = P ( s , t ).
1.3 Deformed Surfaces. An ellipsoid is a deformed sphere; an elliptical cone is a deformed
circular cone. Any surface generated by deforming another surface is called a deformed surface.
The advantage of deformed surfaces is that deformations often permit us to represent complicated
surfaces in terms of simpler surfaces. This device can lead to easier analysis algorithms for
complicated shapes. For example, we shall see in the next lecture that ray tracing an ellipsoid can
be reduced to ray tracing a sphere.
If the original surface has an implicit representation
old
( P ) = 0 or a parametric representation
old
( s , t ) , then the deformed surface also has an implicit representation
new
( P ) = 0 or a
parametric representation
new
( s , t ) ; moreover, we can compute
new
( P ) and
new
( s , t ) from
old
( P ) and
old
( s , t ). In fact, if M is a nonsingular transformation matrix that maps the original
surface into the deformed surface, then
new
old
− 1 ) (1.1)
new
( s , t ) = S old
( s , t ) ∗ M. (1.2)
Equation (1.2) is easy to understand because M maps points on
old
to points on
new
Equation (1.1) follows because P is a point on the deformed surface if and only if
− 1 is a
point on the original surface. Thus
new
old
− 1 ) = 0.
Equations (1.1) and (1.2) are valid for any affine transformation M of the original surface.
Thus the map M can be a rigid motion -- a translation or a rotation -- so we can use Equations (1.1)
and (1.2) to reposition as well as to deform a surface.
1.4 Procedural Surfaces. Fractal surfaces are examples of procedural surfaces. Typically
fractals are not represented by explicit formulas; instead fractals are represented either by recursive
procedures or by iterated function systems. Any surface represented by a procedure instead of a
formula is called a procedural surface. Often surfaces that blend between other surfaces are
is a curve on the surface
P ( s , t ), and the tangent to this curve is given by
∂ s
∂ x
∂ s
∂ y
∂ s
∂ z
∂ s
Similarly, if we fix
s = s 0
, then
P ( t ) = P ( s 0
, t ) = x ( s 0
, t ), y ( s 0
, t ), z ( s 0
is another curve on the surface
P ( s , t ), and the tangent to this curve is given by
∂ t
∂ x
∂ t
∂ y
∂ t
∂ z
∂ t
Since the normal to the surface is orthogonal to the surface, the normal vector must be
perpendicular to the tangent vector for every curve on the surface. Therefore, since the cross
product of two vectors is orthogonal to the two vectors,
∂ s
∂ t
∂ x
∂ s
∂ y
∂ s
∂ z
∂ s
∂ x
∂ t
∂ y
∂ t
∂ z
∂ t
2.3. Deformed Surfaces. Consider a surface
new
that is the image of another surface
old
under a nonsingular
4 × 4 affine transformation matrix M. Recall that if
u
w 1
then only the upper
3 × 3 linear transformation matrix
u
affects tangent vectors to the surface,
since vectors are unaffected by translation. Thus if
v old
is tangent to
old
, then the corresponding
tangent
v new
to the surface
new
is given by
v new
= v old
u
For rotations normal vectors transform in the same way as tangent vectors, since rigid motions
preserve orthogonality. Similarly, uniform scaling preserves orthogonality, since uniform scaling
preserves angles even though scaling does not preserve length. Thus for all conformal
transformations -- that is, for all composites of rotation, translation, and uniform scaling -- the
normal vector transforms in the same way as the tangent vector. Hence, for conformal maps
v new
= v old
u
new
old
u
Nevertheless, perhaps surprisingly, the general transformation rule for normal vectors is
different from the general transformation rule for tangent vectors, since non-conformal maps such
as non-uniform scaling do not preserve orthogonality (see Figure 1). For arbitrary transformations
M , if we know the normal vector
old
to the surface
old
, then we can compute the corresponding
normal vector
new
to the surface
new
by the formula
new
old
u
− T .
For rotations the transpose is equivalent to the inverse, so for rotations
u
− T = M u
. Similarly, if
u
is uniform scaling by the scale factor s , then
u
− T is uniform scaling by the scale factor
1 / s.
However, for arbitrary transformations,
u
− T can be very different from
u
Figure 1: A circle with its normal vectors, and the circle transformed into an ellipse by scaling
non-uniformly by the factor 1/2 along the minor axis. Notice that, in general, non-uniform scaling
does not map normal vectors to the circle to normal vectors to the ellipse.
The general transformation formula for the normal vector is a consequence of the following
observations. Since
old
is orthogonal to
old
, we know that the normal vector
old
is
perpendicular to the tangent vector
v old
. Therefore by the properties of the dot product,
v old
old
T = v old
old
Now we seek a vector
new
such that
v new
new
T = v new
new
But we can easily verify that if
new
old
u
− T , then
v new
new
T = 0 because
v new
new
T = v old
old
u
− T
T
= v old
u
− 1 ∗ N old
T
= v old
old
T = 0.
To summarize: using affine coordinates, points and tangent vectors transform by the same
rule:
new
old
( v new
,0) = ( v old
but tangent vectors and normal vectors transform by different rules:
3.2 Parametric Surfaces. Ray tracing parametric surfaces is more difficult than ray tracing
implicit surfaces. Let
L ( t ) = P + t v
be the parametric equation of a line. The line and the surface intersect whenever there are parameter
values
t , u , v for which
S ( u , v ) = L ( t ). This equation really represents three equations -- one for
each coordinate -- in three unknowns --
t , u , v. Thus to find the intersection points of the line and
the surface, we must solve three equations in three unknowns. Substituting the solutions in t into
the parametric equation
L ( t ) = P + t v for the line or the solutions in
u , v into the parametric
equations
we have the following intersection algorithm.
Ray-Surface Intersection Algorithm -- Parametric Surfaces
S ( u , v ) = L ( t ) for the parameters
t , u , v. That is, solve the three simultaneous equations:
x ( u , v ) = p 1
y ( u , v ) = p 2
z ( u , v ) = p 3
The roots
t = t 1
,K, t n
are the parameter values along the line of the actual intersection points.
i
= L ( t i
) = P + t i
v ,
i = 1 ,K, n , or equivalently
i
= S ( u i
, v i
i = 1 ,K, n.
The values
1
n
are the actual intersection points of the line and the surface.
The bottleneck in this algorithm is again clearly step 1, since the simultaneous equations
S ( u , v ) = L ( t ) may be difficult to solve. We can simplify from three equations in three unknown to
two equations in two unknowns in the following fashion. Let
1
2
be two linearly independent
vectors perpendicular to v. Then
v • N 1
= v • N 2
= 0. Therefore dotting the equation
S ( u , v ) = L ( t ),
with
1
2
eliminates t , the coefficient of v. We are left with two equations in two unknowns:
1
2
which we now must solve for
u , v. Even with this simplification, however, we must still solve two
non-linear equations in two unknowns. Thus, typically ray tracing for parametric surfaces, even for
parametric polynomial surfaces, requires more sophisticated numerical root finding techniques than
ray tracing for implicit surfaces.
3.3 Deformed Surfaces. Ray tracing deformed surfaces is often easy because the deformed
surface is usually the image of a simple surface which we already know how to ray trace. Suppose
that
new
is the image under a nonsingular transformation matrix M of the surface
old
-- that is,
new
old
∗ M. For ray tracing the key observation is that intersecting a line L with the surface
new
is equivalent to intersecting the line
− 1 with the surface
new
− 1 = S old
. More
precisely, a line L and the surface S new
intersect at a point P if and only if the line
− 1 and the
surface
new
− 1 = S old
intersect at the point
− 1 Thus for deformed surfaces, we have the
following intersection algorithm.
Ray-Surface Intersection Algorithm -- Deformed Surfaces
− 1 .
If
L ( t ) = P + t v , then
L ( t )∗ M
− 1 = P ∗ M
− 1
− 1 ).
1
n
and the corresponding parameter values
t = t 1
,K, t n
of
the intersection of the line
− 1 and the surface
old
i
= L ( t i
) = P + t i
v ,
i = 1 ,K, n or equivalently
i
i
i = 1 ,K, n.
The values
1
n
are the actual intersection points of the line L and the surface
new
and
t = t 1
,K, t n
are the corresponding parameter values along the line L.
The main difficulty in this algorithm is step 2, since we must know how to find the
intersections of an arbitrary line with the surface
old
. This intersection algorithm works well
whenever the surface
old
is easy to ray trace.
4. Mean and Gaussian Curvature
To fully analyze surfaces, in addition to expressions for the normal vectors, curvature formulas
are often required. For easy reference we present here without proof formulas for the mean and
Gaussian curvatures of implicit and parametric surfaces. Rigorous definitions and derivations are
beyond the scope of this lecture. Formal mathematical foundations for surface curvature can be
found in most classical books on differential geometry.
4.1 Implicit Surfaces. For an implicit surface
F ( x , y , z ) = 0 , let
∇ F denote the gradient and
hess ( F ) denote the hessian of F -- that is, let
∂ x
∂ y
∂ z
hess ( F ) =
2 F
∂ x
2
2 F
∂ x ∂ y
2 F
∂ x ∂ z
2 F
∂ x ∂ y
2 F
∂ y
2
2 F
∂ y ∂ z
2 F
∂ x ∂ z
2 F
∂ y ∂ z
2 F
∂ z
2
Trace ( I ∗ II
∗ )
2 Det ( I )
where
∗ is the adjoint of
4.3 Deformed Surfaces. If M is a nonsingular transformation matrix that maps some original
surface in implicit or parametric form into a deformed surface, then by Equations (1.1) and (1.2)
new
old
− 1 )
new
( u , v ) = S old
( u , v ) ∗ M.
Since we already have formulas for the mean and Gaussian curvatures both for implicit and for
parametric surfaces, we can calculate the mean and Gaussian curvature of deformed surfaces from
their implicit or parametric equations -- that is, from
new
or
new
5. Summary
The three most common types for surfaces in Computer Graphics are implicit, parametric, and
deformed surfaces. For each of these surface representations we have explicit formulas for the
normal vectors and curvatures as well as straightforward algorithms for calculating ray-surface
intersections. For easy reference we summarize these formulas and algorithms below.
5.1 Implicit Surfaces.
Surface Representation
F ( x , y , z ) = 0
Normal Vector
∂ x
∂ y
∂ z
Hessian
hess ( F ) =
2 F
∂ x
2
2 F
∂ x ∂ y
2 F
∂ x ∂ z
2 F
∂ x ∂ y
2 F
∂ y
2
2 F
∂ y ∂ z
2 F
∂ x ∂ z
2 F
∂ y ∂ z
2 F
∂ z
2
Gaussian Curvature
∇ F ∗ hess
∗ ( F ) ∗∇ F
T
4
Det
hess ( F ) ∇ F
T
4
Mean Curvature
2
T
3
Ray-Surface Intersection Algorithm
The roots
t = t 1
,K, t n
are the parameter values along the line of the actual intersection points.
i
= L ( t i
) = P + t i
v ,
i = 1 ,K, n.
The values
1
n
are the actual intersection points of the line and the surface.
5.2 Parametric Surfaces.
Surface Representation
Normal Vector
∂ s
∂ t
∂ x
∂ s
∂ y
∂ s
∂ z
∂ s
∂ x
∂ t
∂ y
∂ t
∂ z
∂ t
First Fundamental Form
∂ s
∂ s
∂ s
∂ t
∂ P
∂ s
∂ t
∂ t
∂ t
Second Fundamental Form
2 P
∂ s
2
2 P
∂ s ∂ t
2 P
∂ s ∂ t
2 P
∂ t
2
Gaussian Curvature
Det ( II )
Det ( I )
i
= L ( t i
) = P + t i
v ,
i = 1 ,K, n or equivalently
i
i
i = 1 ,K, n.
The values
1
n
are the actual intersection points of the line L and the surface
new
or
new
, and
t = t 1
,K, t n
are the corresponding parameter values along the line L.
Exercises:
3 × 3 matrix. Show that for all
u , v , M
( u × v )∗ M
( u ∗ M ) × ( v ∗ M )
Det ( M )
(Hint: Compute the dot product of both sides with
Explain why this result is plausible geometrically.
3 × 3 matrix, and let
∗ denote the adjoint of M.
a. Give an example to show that
( u × v )∗ M ≠ ( u ∗ M ) × ( v ∗ M )
b. Show that
i.
∗ = Det ( M ) M
− T .
ii.
∗* = Det ( M ) M.
c. Conclude from Exercise 1 and part b that
i.
∗ = ( u ∗ M ) × ( v ∗ M ).
ii.
( u ∗ M
∗ ) × ( v ∗ M
∗ )
Det ( M )
v = ( v 1
, v 2
, v 3
) be a fixed vector in 3-space not in the plane of
D ( s ). The parametric surface:
C ( s , t ) = D ( s ) + t v ,
is called the generalized cylinder over the curve
D ( s ). Compute the normal
N ( s , t ) at an arbitrary
point on the cylinder
C ( s , t ).
Q = ( q 1
, q 2
, q 3
) be a fixed point in 3-space not in the plane of
D ( s ). The parametric surface:
C ( s , t ) = ( 1 − t ) D ( s ) + t Q ,
is called the generalized cone over the curve
D ( s ). Compute the normal
N ( s , t ) at an arbitrary point
on the cone C ( s , t ).
1
( s ), U 2
( s ) be two curves in 3-space. The parametric surface
R ( s , t ) = ( 1 − t ) U 1
( s ) + t U 2
( s )
is called the ruled surface generated by the curves
1
( s ), U 2
( s ). Compute the normal
N ( s , t ) at an
arbitrary point on the ruled surface
R ( s , t ).
xyz − 1 = 0.
a. Find the normal vector to this surface at the point
b. Find the implicit equation of this surface after rotating the surface by
π / 6 radians around
the z -axis and then translating the surface by the vector
v = ( 1 , 3 ,2).
and
2
Derive these curvature formulas in two ways:
i. From the implicit equation
x
2
2
2 − R
2 = 0.
ii. From the parametric equations
x ( s , t ) =
2 R s
1 + s
2
2
y ( s , t ) =
2 R t
1 + s
2
2
z ( s , t ) =
R ( 1 − s
2 − t
2 )
1 + s
2
2