Graphics Reference
In-Depth Information
This may appear too simple to you. Indeed, in an earlier edition of this topic,
the development of the transformation took several pages. But it's an example
of the power of proving one good theorem and writing the associated code.
The transformation can also be realized step-by-step. We can take the cam-
era's view volume and apply a sequence of transformations to it: translate it
so that P moves to the origin; rotate it several times around various coordi-
nate axes so that the uvw -axes align with the xyz -axes; scale in z so that the
far plane ends up at z =
f ; and scale in x and y to make
the view frustum have a width and height of 2. Letting P x , P y , and P z denote
the world coordinates of P , and similarly for u , v , and w , the matrix for the
transformation is then
1 instead of z =
1
f tan θ 2
u x u y u z 0
v x v y v z 0
w x w y w z 0
0001
1
P x
1
f tan θ 2
1
P y
M per =
.
P z
000 1
1
1
f
1
(13.13)
The rightmost matrix effects the translation; the middle one transforms u to e 1 ,
v to e 2 , and w to e 3 ; the leftmost scales each axis appropriately.
We present these merely for your interest and strongly advocate using the
PointsToPoints method instead, as it's far less prone to errors in order of
matrix multiplication, in copying of coordinates, etc.
At this point, it's easy to project points in the standard perspective view
volume onto the back plane, for instance, using the nonlinear transformation
( x , y , z )
z ,1 ) . This is more or less the process we followed when we
rendered the cube in Chapter 3: Our uvw basis was already aligned with the xyz -
axes, and our center of projection was chosen to be the center of our coordinate
system, so all we had to do was the projection step.
( x
/
/
z , y
Inline Exercise 13.2: Review the rendering code in Chapter 3 to verify that it
matches this description.
Rather than take that approach, however, we're going to apply two
transformations—the first to “open up” our pyramidal view volume into a rect-
angular parallelepiped, and the second to project along the z -axis. There are two
reasons for this.
• When we discuss “parallel” cameras and projections rather than the per-
spective cameras we've seen so far, the parallelepipedal volume will be a
more natural target than the pyramidal one.
• When we project along the z -axis, it's especially easy to determine which
objects obscure which other objects, that is, visibility testing becomes
trivial. This property is essential in the design of the so-called z -buffer
algorithm at the heart of most graphics hardware.
 
 
Search WWH ::




Custom Search