Graphics Reference
In-Depth Information
these are always treated as points in 4-space. If you specified a vertex with
glVertex2f(x,y) , then the point ( x , y , 0, 1) was used. If you specified a ver-
tex with glVertex3f(x,y,z) then the point ( x , y , z , 1) was used. And if you
specified a vector with glVertex4f(x,y,z,w) , but the 3D point you specified
was really ( x/w , y/w , z/w , 1). For example, the homogeneous points (1, 2, 3, 1),
(2, 4, 6, 2), and (−1, −2, −3, −1) all represent the same (1, 2, 3) 3D point.
This apparent confusion between 3D and 4D space, and the apparently
arbitrary decision to always want a unit value for w seem awkward; why do
it this way? One reason is that it allows for perspective division within the
matrix mechanism. The OpenGL call
glFrustum( left, right, bottom, top, near, far )
creates this matrix:
near
right
2
right
+
left
0
0
left
right
left
x
y
z
w
x
y
z
near
top bottom
2
*
+
−+
top bottom
top bottom
farnear
far
0
0
=
.
(
)
2
farnear
farnear
**
0
0
1
near
0
0
1
0
This gives w ' = - z , which is the necessary divisor for perspective.
This approach also gives us a way to work with a more general geom-
etry than simple 3D space. As another way of thinking about homogeneous
coordinates, consider the four homogeneous points (1, 2, 3, 1), (1, 2, 3, 0.1),
(1, 2, 3, 0.01), and (1, 2, 3, 0.001). In standard form, these points are (1, 2, 3, 1),
(10, 20, 30, 1), (100, 200, 300, 1), and (1000, 2000, 3000, 1). In mathematical terms,
the homogeneous coordinates of a point in 4-space are the representation in
three-dimensional projective space of the line through the point and the origin,
and the point (1, 2, 3, 0) is the “point at infinity” in the (1, 2, 3) direction.
We will sometimes find it important to consider vectors defined by their
two endpoints, and we often think of these as being defined by simply doing
a vector subtraction of the coordinates of the endpoints. This is not exactly the
case for vertices in 4-space, or more specifically, for vertices in homogeneous
coordinates. In this case, as well as addition in homogeneous coordinates, we
must think a litle more carefully about the question.
To compute the difference between two points in 3-space when they are
represented in 4-space, we start with the vectors in 4-space, convert them to
Search WWH ::




Custom Search