A Strategy Based on Vector Geometry
For Deriving 3D Affine Transformations
Recall:
- An affine transformation on an arbitrary affine point,
Q, can be expressed as:
X(Q) = MQ + t
where M is a 3x3 matrix, and t is a 3D translation vector.
- The way affine transformations are applied to vectors depends
on how the vector is used. More precisely, it depends on what relationship among a set
of points is encoded by the vector, and hence what relationship must be preserved. For
now, we are focusing on vectors that capture the offset between two points. For an
arbitrary vector, e (which we imagine to be defined as the difference between
some pair of affine points), we apply the affine transformation to e as:
X(e) = Me
(Note we are assuming a "polymorphic X".)
- It is frequently desirable to store the affine transformation as
a single 4x4 matrix (say, M4x4).
When doing so, the M above is the upper left 3x3 sub-matrix of
M4x4; t goes into the top three rows of the fourth column of
M4x4; and the fourth row of M4x4 is (0, 0, 0, 1).
OpenGL
We will require many affine transformations in our OpenGL programs. They are used to perform the
model coordinate to eye coordinate transformation, implement dynamic rotation, panning, and scaling
of models in our 3D scenes, and for many other purposes. (In fact, "scaleTrans" in our
initial 2D programs was just a simplified representation of (M, t) that is adequate for
simple 2D scenes.)
In order to use affine transformations in our OpenGL programs, we need to know how to create
the matrix and translation vector for any desired affine transformation.
We will be learning how to do this for several common affine transformations
using a strategy motivated in part by #2 above. It may not be obvious now, but it turns
out that it is usually easiest to characterize how a vector between two points is affected by a
given transformation. Once we have that characterization, it will be straightforward
to write down the matrix, M, that encodes it. Finally, computing t will be
mechanical.
A Strategy
Given the parameters specifying some affine transformation,
our strategy will be:
- Determine how an arbitrary vector, e, representing the offset between two points is affected by the
transformation.
- Encode the resulting symbolic expression as a matrix operation
on the vector, e: Me, thus revealing what the "M" part of the affine
transformation is.
- Mechanically determine t. We will generally use one of the
following schemes, the latter being a very common special case of the former:
- If there is at least one point (say, G) for which
we know X(G) a priori (say, G′), we can compute t as follows:
X(G) = G′ = MG + t
⇒
t = G′
- MG
Can you think of an example we have already seen of an affine transformation for which you know such a
(G, G′) pair?
- If we know a fixed point of the transformation
(a fixed point is some point, F, for which X(F) = F),
then:
X(F) = F = MF + t
⇒
t = F
- MF
Can you think of an example of an affine transformation for which you would know such a
fixed point? (Hint: for many common affine transformations, there are an infinite number
of fixed points.)