Transformations are central in computer graphics. They are used to map from one space to another along the graphics pipeline;
A very good source for affine maps in Gerald Farin's book [Far93], ``Curves and Surfaces for CAGD: A Practical Approach.'' Some of this introductory material comes from Farin's text.
Let
be two points in three dimensional
Euclidean space
E3.
Their difference
Points be subtracted, but addition and scalar multiplication
of points is not defined.
Points can have a vector added to them to form another point:
Points determine position; vectors determine direction and magnitude.
For any two points a and b there is but one vector
from a to b.
However, given
there are infinitely many pairs of points that
determine
.
Indeed, if
and
is any vector, then
Now let
be n+1 points in
E3.
And let
be n+1
real numbers (weights) that sum to 1.
We define the
barycentric (or affine) combination of these points to be
An important special case of barycentric combinations are
convex combinations.
Here we require that the weighs be non-negative (
)
as well as sum to 1.
Note that a weighted sum of points is a vector when the weights add up to zero.
A map A that maps
E3 into itself is called
affine if it leaves barycentric
combinations invariant.
That is, pretend
To be more specific, let's think of point p with coordinates
.
An affine map can be represented in the familiar form
Note that we write point-matrix multiplication with the point
on the left of the matrix: This seems common practice
in the computer graphics literature.
Placing the point on the right is more common in mathematical
writing. It is easy to change from one form to the other
via the transpose operation.
We will write
We will see that the useful tranformations: translations, scale, rotation, shear, and parallel projection are all affine maps.
A particularly useful barycentric combination is linear interpolation.
Let
be two points and let
the weights be 1-t and t for some real number (parameter) t.
Then the points
Matrices are the basic tool that transform (map) points from
E3 into
E3.
A matrix is an
array with n rows and m columns.
You need to know how to perform matrix multiplication.
Most of our matrices will be
,
but they'll start
out as
.
Pretending that matrix multiplication is a collection
inner products
is useful since it provides a geometric interpretation.
That is, the
element in the product AB is the
inner product of the i-th row of A with the j-th column of B.
If you are uncertain about inner products,
you'll want to read about them.
A row
Scaling alters the size of an object.
Pretend you are given a point
which is an object vertex,
and let
be scale factors
in
,
respectively.
Then the point can be scaled to a new point by the matrix
Note that the origin
is unchanged by
a scale (it is still the origin).
There is always one fixed point for any scaling operation.
By default the fixed point is the origin
,
but we can select an arbitrary fixed point
by the following three step process,
which will be more completely defined below.
As long as we do not scale by zero, a scale can always be inverted (undone) by the matrix
Rotations alter the orientation of an object: They are a little more complex than scales. Starting in two dimensional rotations is easiest.
A rotation moves a point along a cirular path centered at the
origin (the pivot).
It is a simple trigonometry problem to show that rotating
counter-clockwise by
radians produces a new point
given by
Of course, we can express the rotation in matrix form
By default the pivot point is the origin
,
but we can arrange for an arbitrary pivot
by using a three
step process similar to the one for scaling about an arbitrary fixed point
described about.
In three dimensions points are rotated about an axis, which is a line in three dimensional space. There are three principle axes: the x, y, and z axes. We assume a right-handed coordinate system, with the convention that positive rotation is counter-clockwise.
Rotating
about the z-axis by
radians
produces a new point
where
Rotating
about the x-axis by
radians
produces a new point
where
Rotating
about the y-axis by
radians
produces a new point
where
Consider an axis through the origin determined by a unit length
direction vector
,
(the completely arbitrary case will be easily handled after translations
are introduced).
We can arrange to rotate by theta radians about this axis using a five step process
You should verify that this matrix reduces to rotations about z,
x, and y for appropriate choices of the direction vector
Below, we'll see that there are better ways to derive this matrix.
The inverse of a rotation by
radians can be created by rotating
by
radians, but this is not the best way to view it.
Consider the trigonometic identities
Translations change the position of an object.
A pure (three dimensional) translation can not be implemented
using a
matrix: It is an
affine map.
We must alter our notion of a point to accommodate translations.
A three dimensional point
will be embedded
in
three dimensional homogeneous space
and represented as a 4-tuple
.
For now, the homogeneous coordinate w will have the fixed value 1.
This allows us to implement translations using
matrices,
in particular, the matrix
To undo a translation by
use the matrix
We can now complete scaling about an arbitrary fixed point and rotation about
an arbitrary pivot.
To scale about
use the composition of matrices
| = | ![]() |
(2) | |
| = | (3) |
In a similar manner you can determine that rotation about a pivot
results in
Now is a good time to mention the fact that it is more efficient, in general, to form one composite transform than to pass a sequence of points through one transform, then another, and another, and so on.
Let's see why this is.
Multiplying one point (a 4-tuple) by a transformation (
matrix)
costs 16 multiplies and 12 additions.
Therefore, transforming an object with n vertices by one transform
costs 16n multiplies and 12n additions.
On the other hand, multiplying two
matrices costs
64 multiplies and 48 additions.
So compositing m
matrices together costs
64(m-1) multiplies and 48(m-1) additions.
So consider the alternatives:
Objects defined in model space can be scaled, translated, and rotated into world space and then viewed from any position. The map from model to world to view is most often concatenated into one single tranform so we map from a model directly into view space without every stopping in the world.
Next we map objects from view space into perspective space. This involves projections: either parallel or perspective. Note that we must stop in view space to compute the illumination that lights bring to our view.
From perspective to clip space and from clip space through normalized space to device space are fairly straight forward scales and translations -- we just need to be careful not to introduce distortions by our scaling of the objects.
Here we want to describe perspective transforms. They are non-linear, that is, lines do not map into lines. (To be completed)