Parametric Surfaces and Ray-Surface Intersections in Computer Graphics, Study notes of Computer Graphics

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

Pre 2010

Uploaded on 08/18/2009

koofers-user-fbn-1
koofers-user-fbn-1 🇺🇸

9 documents

1 / 14

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Lecture 18: Surfaces I -- The General Theory
Thou hast set all the borders of the earth: Psalm 74:17
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
F(P)=0.
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)x2+y2+z21=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
is equivalent to three parametric equations for the coordinates:
x=p1(s,t), y=p2(s,t), z=p3(s,t)
. In Computer Graphics, the functions
p1(s,t), p2(s,t), p3(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)=2s
1+s2+t2 y(s,t)=2t
1+s2+t2 z(s,t)=1s2t2
1+s2+t2
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe

Partial preview of the text

Download Parametric Surfaces and Ray-Surface Intersections in Computer Graphics and more Study notes Computer Graphics in PDF only on Docsity!

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

F ( P ) = 0.

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

  • y

2

  • z

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

  • t

2

y ( s , t ) =

2 t

1 + s

2

  • t

2

z ( s , t ) =

1 − s

2 − t

2

1 + s

2

  • t

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

F

old

( P ) = 0 or a parametric representation

P = S

old

( s , t ) , then the deformed surface also has an implicit representation

F

new

( P ) = 0 or a

parametric representation

P = S

new

( s , t ) ; moreover, we can compute

F

new

( P ) and

S

new

( s , t ) from

F

old

( P ) and

S

old

( s , t ). In fact, if M is a nonsingular transformation matrix that maps the original

surface into the deformed surface, then

F

new

( P ) = F

old

( P ∗ M

− 1 ) (1.1)

S

new

( s , t ) = S old

( s , t ) ∗ M. (1.2)

Equation (1.2) is easy to understand because M maps points on

S

old

to points on

S

new

Equation (1.1) follows because P is a point on the deformed surface if and only if

P ∗ M

− 1 is a

point on the original surface. Thus

F

new

( P ) = 0 ⇔ F

old

( P ∗ M

− 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

∂ P

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

( , t ))

is another curve on the surface

P ( s , t ), and the tangent to this curve is given by

∂ P

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,

N =

∂ P

s

×

∂ P

t

x

s

y

s

z

s

 ×

x

t

y

t

z

t

2.3. Deformed Surfaces. Consider a surface

S

new

that is the image of another surface

S

old

under a nonsingular

4 × 4 affine transformation matrix M. Recall that if

M =

M

u

w 1

then only the upper

3 × 3 linear transformation matrix

M

u

affects tangent vectors to the surface,

since vectors are unaffected by translation. Thus if

v old

is tangent to

S

old

, then the corresponding

tangent

v new

to the surface

S

new

is given by

v new

= v old

∗ M

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

∗ M

u

N

new

= N

old

∗ M

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

N

old

to the surface

S

old

, then we can compute the corresponding

normal vector

N

new

to the surface

S

new

by the formula

N

new

= N

old

∗ M

u

T .

For rotations the transpose is equivalent to the inverse, so for rotations

M

u

T = M u

. Similarly, if

M

u

is uniform scaling by the scale factor s , then

M

u

T is uniform scaling by the scale factor

1 / s.

However, for arbitrary transformations,

M

u

T can be very different from

M

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

N

old

is orthogonal to

S

old

, we know that the normal vector

N

old

is

perpendicular to the tangent vector

v old

. Therefore by the properties of the dot product,

v old

∗ N

old

T = v old

• N

old

Now we seek a vector

N

new

such that

v new

∗ N

new

T = v new

• N

new

But we can easily verify that if

N

new

= N

old

∗ M

u

T , then

v new

∗ N

new

T = 0 because

v new

∗ N

new

T = v old

∗ M

( u )

∗ N

old

∗ M

u

T

T

= v old

∗ M

( u )

∗ M

u

− 1 ∗ N old

T

= v old

∗ N

old

T = 0.

To summarize: using affine coordinates, points and tangent vectors transform by the same

rule:

( P

new

, 1 ) = ( P

old

, 1 ) ∗ M

( v new

,0) = ( v old

,0)∗ M ,

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

S ( u , v ) = ( x ( u , v ), y ( u , v ), z ( u , v )) be a parametric surface, and 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

S ( u , v ) = ( x ( u , v ), y ( u , v ), z ( u , v )) of the surface yields the actual intersection points. Thus

we have the following intersection algorithm.

Ray-Surface Intersection Algorithm -- Parametric Surfaces

  1. Solve

S ( u , v ) = L ( t ) for the parameters

t , u , v. That is, solve the three simultaneous equations:

x ( u , v ) = p 1

  • t v 1

y ( u , v ) = p 2

  • t v 2

z ( u , v ) = p 3

  • t v 3

The roots

t = t 1

,K, t n

are the parameter values along the line of the actual intersection points.

  1. Compute

R

i

= L ( t i

) = P + t i

v ,

i = 1 ,K, n , or equivalently

R

i

= S ( u i

, v i

i = 1 ,K, n.

The values

R

1

,K, R

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

N

1

, N

2

be two linearly independent

vectors perpendicular to v. Then

vN 1

= vN 2

= 0. Therefore dotting the equation

S ( u , v ) = L ( t ),

with

N

1

, N

2

eliminates t , the coefficient of v. We are left with two equations in two unknowns:

(^ S ( u , v )^ −^ P ) •^ N

1

(^ S ( u , v )^ −^ P ) •^ N

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

S

new

is the image under a nonsingular transformation matrix M of the surface

S

old

-- that is,

S

new

= S

old

M. For ray tracing the key observation is that intersecting a line L with the surface

S

new

is equivalent to intersecting the line

L ∗ M

− 1 with the surface

S

new

∗ M

− 1 = S old

. More

precisely, a line L and the surface S new

intersect at a point P if and only if the line

L ∗ M

− 1 and the

surface

S

new

∗ M

− 1 = S old

intersect at the point

P ∗ M

− 1 Thus for deformed surfaces, we have the

following intersection algorithm.

Ray-Surface Intersection Algorithm -- Deformed Surfaces

  1. Transform the line L by the matrix

M

− 1 .

If

L ( t ) = P + t v , then

L ( t )∗ M

− 1 = PM

− 1

  • t ( vM

− 1 ).

  1. Find the intersection points

Q

1

,K, Q

n

and the corresponding parameter values

t = t 1

,K, t n

of

the intersection of the line

L ∗ M

− 1 and the surface

S

old

  1. Compute

R

i

= L ( t i

) = P + t i

v ,

i = 1 ,K, n or equivalently

R

i

= Q

i

∗ M ,

i = 1 ,K, n.

The values

R

1

,K, R

n

are the actual intersection points of the line L and the surface

S

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

S

old

. This intersection algorithm works well

whenever the surface

S

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

∇ F =

∂ F

x

∂ F

y

∂ F

z

hess ( F ) =

2 F

x

2

2 F

xy

2 F

xz

2 F

xy

2 F

y

2

2 F

yz

2 F

xz

2 F

yz

2 F

z

2

H =

Trace ( III

∗ )

2 Det ( I )

where

II

∗ is the adjoint of

II.

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)

F

new

( P ) = F

old

( P ∗ M

− 1 )

S

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

F

new

or

S

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

N = ∇ F =

∂ F

x

∂ F

y

∂ F

z

Hessian

hess ( F ) =

2 F

x

2

2 F

xy

2 F

xz

2 F

xy

2 F

y

2

2 F

yz

2 F

xz

2 F

yz

2 F

z

2

Gaussian Curvature

K =

Fhess

∗ ( F ) ∗∇ F

T

∇ F

4

Det

hess ( F ) ∇ F

T

∇ F 0

∇ F

4

Mean Curvature

H =

∇ F

2

Trace ( hess ( F )) − ∇ F ∗ hess ( F )∗ ∇ F

T

2 ∇ F

3

∇ F

∇ F

Ray-Surface Intersection Algorithm

  1. Solve

F ( L ( t )) = 0.

The roots

t = t 1

,K, t n

are the parameter values along the line of the actual intersection points.

  1. Compute

R

i

= L ( t i

) = P + t i

v ,

i = 1 ,K, n.

The values

R

1

,K, R

n

are the actual intersection points of the line and the surface.

5.2 Parametric Surfaces.

Surface Representation

P ( s , t ) = ( x ( s , t ), y ( s , t ), z ( s , t ))

Normal Vector

N =

∂ P

s

×

∂ P

t

x

s

y

s

z

s

 ×

x

t

y

t

z

t

First Fundamental Form

I =

∂ P

s

∂ P

s

∂ P

s

∂ P

t

P

s

∂ P

t

∂ P

t

∂ P

t

Second Fundamental Form

II =

2 P

s

2

• N

2 P

st

• N

2 P

st

• N

2 P

t

2

• N

Gaussian Curvature

K =

Det ( II )

Det ( I )

  1. Compute

R

i

= L ( t i

) = P + t i

v ,

i = 1 ,K, n or equivalently

R

i

= Q

i

∗ M ,

i = 1 ,K, n.

The values

R

1

,K, R

n

are the actual intersection points of the line L and the surface

F

new

or

S

new

, and

t = t 1

,K, t n

are the corresponding parameter values along the line L.

Exercises:

  1. Let M be a nonsingular

3 × 3 matrix. Show that for all

u , v , M

( u × v )∗ M

T

( uM ) × ( vM )

Det ( M )

(Hint: Compute the dot product of both sides with

u ∗ M , v ∗ M , ( u × v ) ∗ M .)

Explain why this result is plausible geometrically.

  1. Let M be a nonsingular

3 × 3 matrix, and let

M

∗ denote the adjoint of M.

a. Give an example to show that

( u × v )∗ M ≠ ( uM ) × ( vM )

b. Show that

i.

M

∗ = Det ( M ) M

T .

ii.

M

∗* = Det ( M ) M.

c. Conclude from Exercise 1 and part b that

i.

(^ u^ ×^ v )∗^ M

∗ = ( uM ) × ( vM ).

ii.

(^ u^ ×^ v )∗^ M^ =^

( uM

∗ ) × ( vM

∗ )

Det ( M )

  1. Let

D ( s ) = ( x ( s ), y ( s ), z ( s )) be a parametrized curve lying in a plane in 3-space, and let

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 ).

  1. Let

D ( s ) = ( x ( s ), y ( s ), z ( s )) be a parametrized curve lying in a plane in 3-space, and let

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. Let

U

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

U

1

( s ), U 2

( s ). Compute the normal

N ( s , t ) at an

arbitrary point on the ruled surface

R ( s , t ).

  1. Consider the surface defined by the implicit equation

xyz − 1 = 0.

a. Find the normal vector to this surface at the point

P = (2, 1 ,0.5).

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).

  1. Let S be a sphere of radius R. The mean and Gaussian curvature of S are given by

H =

R

and

K =

R

2

Derive these curvature formulas in two ways:

i. From the implicit equation

x

2

  • y

2

  • z

2 − R

2 = 0.

ii. From the parametric equations

x ( s , t ) =

2 R s

1 + s

2

  • t

2

y ( s , t ) =

2 R t

1 + s

2

  • t

2

z ( s , t ) =

R ( 1 − s

2 − t

2 )

1 + s

2

  • t

2