- Contents
- Transformations
- Affine Transforms
- Matrices
- Where Are Transformations Used?
- Non-linear transforms
- Conclusions
- Bibliography

Transformations are central in computer graphics. They are used to map from one space to another along the graphics pipeline;

Affine Transforms

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
**E**^{3}.
Their *difference*

is the

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:

This is a

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
**E**^{3}.
And let
be *n*+1
real numbers (*weights*) that sum to 1.
We define the
*barycentric (or affine) combination* of these points to be

This looks like we've invalidated our statement that points can not be added, but the fact that the weights add to one allow us to write the barycentric combination as a point plus the sum of vectors. That is,

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
**E**^{3} into itself is called
*affine* if it leaves barycentric
combinations invariant.
That is, pretend

is a barycentric combination of points

and

is a barycentric combination of points.

To be more specific, let's think of point *p* with coordinates
.
An affine map can be represented in the familiar form

where

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

This is equivalent to

Thus the major difference is: we write points (and vectors) as rows, others write them as columns.

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

is called the

Matrices are the basic tool that transform (map) points from
**E**^{3} into
**E**^{3}.
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

should be thought of as a point (using our notational conventions). A column

should be thought of as a plane. The inner (or dot, scalar, matrix) product of them

is a scalar (real number). If the value is zero, the point lies in the plane.

Scales

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

In particular,

To scale (enlarge or shrink) the size of an object, each object vertex is multiplied by the scale 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.

- 1.
- Translate to
- 2.
- Scale by
- 3.
- Translate to

As long as we do not scale by zero, a scale can always be inverted (undone) by the matrix

The product

Rotations

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

For example, pretend and . Then , which you should agree correctly matches the description.

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.

- 1.
- Translate to
- 2.
- Rotate by
- 3.
- Translate to

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

or in matrix notation

The notations

Rotating
about the *x*-axis by
radians
produces a new point
where

or in matrix notation

Rotating
about the *y*-axis by
radians
produces a new point
where

or in matrix notation

Angles of rotation about the principle axes are called

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

- 1.
- Rotate
into the
*xz*plane, call the result - 2.
- Rotate
into the
*z*axis - 3.
- Rotate about the
*z*axis by radians - 4.
- Invert the rotation of
into the
*z*axis - 5.
- Invert the rotation of into

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

If you plug these into the arbitrary rotation from equation (1), you'll see that the inverse of

Translations

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

translated the point into the point .

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

which when multiplied out yields

So a scaled point becomes

= | (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 16*n* multiplies and 12*n* 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:

- 1.
- Multiply
*n*vertices through a sequence of*m*transformations at a cost of 16*n*multiplies and 12*n*adds per transform. The total cost will be

- 2.
- Form on composite matrix and pass
*n*vertices through it. The total cost will be

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)

- There are some things to practice.

**Far93**-
Gerald Farin.
*Curves and Surfaces for Computer Aided Geometric Design*.

Academic Press, third edition, 1993.

2002-03-04