Graphics Reference
In-Depth Information
of them) might be needlessly computationally expensive; fortunately, there's a
way around this expense: If A and B are vertices with an edge between them, and
we project A and B to points A and B in the drawing, then we can see that the
points between A and B will project to points on the line segment between A and
B . We could verify this geometrically, or simply rely on the familiar experience
that photographs of straight lines always appear straight. 4 So, instead of finding
many points on the edge and drawing them all, we'll simply compute A and B
and then draw a line segment between them.
Inline Exercise 3.4: The preceding paragraph suggests that we can say that
“Perspective projection from space to a plane takes lines to lines” or “takes
line segments to line segments.” Think carefully about the first claim and find
a counterexample. Hint: Is our perspective projection defined for every point
in space?
A word to the wise: The sorts of subtleties you discovered in this exercise are
not mere nitpicking! They are the kinds of things that lead to bugs in graphics
programs. Because graphics programs tend to operate on a great deal of data,
nearly every possible part of a program will often be tested in a sample execution.
Thus, bugs that might survive testing on a less demanding system will often reveal
themselves early in graphics programs.
For those who did not come up with counterexamples, we give them here.
First, for a line that passes through the eye, the perspective projection is not even
defined for the eyepoint. And the non-eyepoints of the line project to a single point
rather than to an entire line. If we agree to ignore points at which the projection is
undefined, there's a further problem: The eye is at location ( 0, 0, 0 ) , and the projec-
tion plane is parallel to the xy -plane. This means that any line segment that passes
through the z = 0 plane contains a point that cannot be projected. The projection
of such a segment will consist of two separate pieces. Convince yourself of this by
projecting the segment from ( 2 ,0,1 ) to ( 2 ,0,
1 ) onto the z = 1 plane by hand.
In the language of projective geometry, “perspective projection takes extended
lines to extended lines, except that it is undefined on the pencil of lines containing
the projection point.”
Returning to our program, we enhance our model of the cube to include a list
of edges, described by the vertex indices of their endpoints:
Index Endpoints
0
(0, 1)
1
(1, 2)
2
(2, 3)
3
(3, 0)
4
(0, 4)
5
(1, 5)
6
(2, 6)
7
(3, 7)
8
(4, 5)
9
(5, 6)
10
(6, 7)
11
(7, 4)
4. For cameras with high-quality, nondistorting lenses anyhow!
 
Search WWH ::




Custom Search