Graphics Programs Reference
In-Depth Information
3. The screen and the far plane now define a truncated pyramid, called the
viewing
volume
or
frustum
(Latin for a piece broken off). Those parts of the image that are
outside it are either irrelevant or invisible to the viewer and should not be displayed.
Imagine a picture made up of points connected with straight lines. Before displaying
the picture, the software should determine which points are outside the viewing volume.
Those points should not be displayed but should not be ignored either. Figure 3.39b
shows four points connected to form a rectangle. Notice how some of the lines connecting
the points should not be displayed and others should be
clipped
. In general, only those
parts of the image that are inside the viewing volume should be displayed.
It is easy to determine if a point
P
=(
x, y, z
) is inside the viewing volume. We
assume that the screen is a square that is
W
units on a side. Figure 3.39c shows two
of the four lines that bound the pyramid. It is easy to see that tan
α
=(
W/
2)
/k
=
W/
(2
k
). This is also the slope of line
L
1
.The
x
-intercept of the line is
W/
2, so the
line's equation is
x
=(
W/
2
k
)
z
+
W/
2=(
W/
2)(
z/k
+ 1).
The equation of
L
2
is,
similarly,
x
=
(
W/
2)(
z/k
+ 1). Since the diagram is symmetric with respect to
x
and
y
,weconcludethatpoint
P
is located inside the pyramid if its coordinates satisfy
|
−
x
|
,
|
y
|≤
(
W/
2)(
z/k
+1).
Exercise 3.29:
Assume that the distance
k
of the viewer from the screen equals the
size
W
of the screen. What will be the width of the field of view of the viewer?
Let's assume that two points,
P
and
Q
, are part of the total image and are to be
connected with a straight line. The first step is to determine, for each point, whether it
is located inside or outside the viewing volume. (If a point is located on the edge of the
viewing volume, it is considered to be inside.) In the second step, three cases should be
distinguished:
1. Both points are inside the viewing volume. The line connecting them is com-
pletely inside the volume and should be fully displayed. This is because the viewing
volume is convex. (It is a convex polyhedron.)
2. One point is inside and the other is outside the viewing volume. The line
connecting them intercepts the volume at exactly one point. (This, again, is a result
of the convexity of the viewing volume.) The interception point should be determined
and the line should be clipped.
3. Both points are outside. The line connecting them is either completely outside
(and should therefore be ignored) or it intercepts the viewing volume at two points.
Both interception points should be calculated and the line segment connecting them
should be displayed. (There is also the degenerate case where both interception points
are identical; the line is tangent to the viewing volume. In such a case, the line can be
ignored or just one pixel displayed.)
3.10.1 Application: Flight Simulation
People have been fascinated by flight since the dawn of history. It is therefore not
surprising that simple, inexpensive flight simulators for personal computers appeared
as soon as these computers became fast and powerful enough to complete the necessary
computations in real time. A flight simulator, even a simple one, is a complex program
because it has to simulate the behavior of an airplane and display both the interior
Search WWH ::
Custom Search