Graphics Reference
In-Depth Information
is undefined. In general, with the same transformation operator M and the same
vertex position V
=(
x
,
y
,
z
)
, the results from pre- and post-multiplication will be
different, or:
V r = xyz M
= x r y r z r ,
and
x
y
z
x c
y c
z c
=
.
=
V c
M
Then, in general,
V c or x r y r z r = x c y c z c .
V r
=
When programming with graphics APIs, we as the programmer can choose to
work with either row- or column-vector representation. Because the results of the
two approaches are not interchangeable, it is important that we choose one and
be consistent throughout our programming. One important and dangerous caveat
is that most modern graphics APIs represent row and column vectors with the
same data structure (e.g., a three-element array, or a three-element vector class)
and typically support both pre- and post-vector/matrix multiplication with that
same data structure. As programmers, we must be extremely careful with coding
vector-matrix multiplication.
It is interesting that D3D chose pre-multiplication, wheras OpenGL supports
post-multiplication. Because most of the tutorials in this topic are based on D3D,
we will follow the pre-multiplication convention.
8.5.4
Homogeneous Coordinate Representation
It is interesting that the mathematics required to support 3D graphics operations
are in four dimensions. We have already seen that the fourth dimension of the
4
4 matrix encodes translation information. In addition, the fourth dimension of
the matrix is needed for encoding perspective projection. Perspective projection
is the mathematical foundation for displaying 3D objects on 2D displays.
Because the underlying matrices are defined in four dimensions, mathemati-
cally, the vectors representing coordinate positions must also be defined in four
dimensions. The homogeneous coordinate system represents a point,
×
V a =(
x a ,
y a ,
z a ) ,
Search WWH ::




Custom Search