Imagine playing a video game. As you press a button, figures and objects on the screen start moving around; they shift their positions, they rotate, they zoom in or out. As you see this kind of motion, the game software must carry out quite a few transformations. In Figure 6.1, they have been applied to a familiar face in gaming. These computations are implementations of affine maps, the subject of this chapter.
In Section 4.1 the focus was on constructing a linear map that takes a vector v in the [e1, e2]-system,
to a vector v′ in the [a1, a2]-system
Recall that this latter system describes a parallelogram (skew) target box with lower-left corner at the origin. In this chapter, we want to construct this skew target box anywhere, and we want to map points rather than vectors, as illustrated by Sketch 6.1.
Now we will describe a skew target box by a point p and two vectors a1, a2. A point x is mapped to a point x′ by
as illustrated by Sketch 6.1. This simply states that we duplicate the [e1, e2]-geometry in the [a1, a2]-system: x′ has the same coordinates in the new system as x did in the old one. Technically, the linear map A in (6.2) is applied to the vector x − o, so it should be written as
where o is the origin of x’s coordinate system. In most cases, we will have the familiar
and then we will simply drop the “−o” part, as in (6.2).
Affine maps are the basic tools to move and orient objects. All are of the form given in (6.3) and thus have two parts: a translation, given by p, and a linear map, given by A.
Let’s try representing the coordinate transformation of Section 1.1 as an affine map. The point u lives in the [e1, e2]-system, and we wish to find x in the [a1, a2]-system. Recall that the extents of the target box defined Δ1 = max1 − min1 and Δ2 = max2 − min2, so we set
The affine map is defined as
and we recover (1.3) and (1.4).
Of course we are not restricted to target boxes that are parallel to the [e1, e2]-coordinate axes. Let’s look at such an example.
Let
define a new coordinate system, and let
be a point in the [e1, e2]-system. In the new coordinate system, the [a1, a2]-system, the coordinates of x define a new point x′. What is this point with respect to the [e1, e2]-system? The solution:
Thus, x′ has coordinates
with respect to the [a1, a2]-system; with respect to the [e1, e2]-system, it has coordinates
.
(See Sketch 6.2 for an illustration.)
And now an example of a skew target box. Let’s revisit Example 5.1 from Section 5.1, and add an affine aspect to it by translating our target box.
Sketch 6.3 illustrates the given geometry,
and the point
with respect to the [e1, e2]-system. We may ask, what are the coordinates of r with respect to the [a1, a2]-system? This was the topic of Chapter 5; we simply set up the linear system, Au = (r − p), or
Using Cramer’s rule or Gauss elimination from Chapter 5, we find that .
A map of the form v′ = Av is called a linear map because it preserves linear combinations of vectors. This idea is expressed in (4.11) and illustrated in Sketch 4.4. A very fundamental property of linear maps has to do with ratios, which are defined in Section 2.5. What happens to the ratio of three collinear points when we map them by an affine map? The answer to this question is fairly fundamental to all of geometry, and it is: nothing. In other words, affine maps leave ratios unchanged, or invariant. To see this, let
and let an affine map be defined by
The step from the first to the second equation may seem a bit contrived; yet it is the one that makes crucial use of the fact that we are combining points using barycentric combinations: (1 − t) + t = 1.
The last equation shows that the linear (1 − t), t relationship among three points is not changed by affine maps—meaning that their ratio is invariant, as is illustrated in Sketch 6.4. In particular, the midpoint of two points will be mapped to the midpoint of the image points.
The other basic property of affine maps is this: they map parallel lines to parallel lines. If two lines do not intersect before they are mapped, then they will not intersect afterward either. Conversely, two lines that intersect before the map will also do so afterward. Figure 6.2 shows how two families of parallel lines are mapped to two families of parallel lines. The two families intersect before and after the affine map. The map uses the matrix
If an object is moved without changing its orientation, then it is translated. See Figure 6.3 in which points on a circle have been translated by a fixed amount.
How is this action covered by the general affine map in (6.3)? Recall the identity matrix from Section 5.9, which has no effect whatsoever on any vector: we always have
which you should be able to verify without effort.
A translation is thus written in the context of (6.3) as
One property of translations is that they do not change areas; the two circles in Figure 6.3 have the same area. A translation causes a rigid, body motion. Recall that rotations are also of this type.
In this section, we present two very common geometric problems that demand affine maps. It is one thing to say “every affine map is of the form Ax + p,” but it is not always clear what A and p should be for a given problem. Sometimes a more constructive approach is called for, as is the case with Problem 2 in this section.
Problem 1: Let r be some point around which you would like to rotate some other point x by a degrees, as shown in Sketch 6.5. Let x′ be the rotated point.
Rotations have been defined only around the origin, not around arbitrary points. Hence, we translate our given geometry (the two points r and x) such that r moves to the origin. This is easy:
Now we rotate the vector around the origin by α degrees:
The matrix A would be taken directly from (4.16). Finally, we translate back to the center r of rotation:
Let’s reformulate this in terms of the given information. This is achieved by replacing by its definition:
Let
and a = 90°. We obtain
See Sketch 6.6 for an illustration.
Problem 2: Let l be a line and x be a point. You want to reflect x across l, with result x′, as shown in Sketch 6.7. This problem could be solved using the following affine maps. Find the intersection r of l with the e1-axis. Find the cosine of the angle between l and e1. Rotate x around r such that l is mapped to the e1-axis. Reflect the rotated x across the e1-axis, and finally undo the rotation. Complicated!
It is much easier to employ the “foot of a point” algorithm that finds the closest point p on a line l to a point x, which was developed in Section 3.7. Then p must be the midpoint of x and x′:
from which we conclude
While this does not have the standard affine map form, it is equivalent to it, yet computationally much less complex.
Affine maps may be viewed as combinations of linear maps and translations. Another flavor of affine maps is described in this section; it draws from concepts in Chapter 5.
This other flavor arises like this: given a (source) triangle T with vertices a1, a2, a3, and a (target) triangle T′ with vertices a′1, a′2, a′3, what affine map takes T to T′? More precisely, if x is a point inside T, it will be mapped to a point x′ inside T′: how do we find x′? For starters, see Sketch 6.8.
Our desired affine map will be of the form
thus we need to find the matrix A. (We have chosen a1 and a′1) arbitrarily as the origins in the two coordinate systems.) We define
and
We know
These two vector equations may be combined into one matrix equation:
We multiply both sides of this equation by V’s inverse V−1 and obtain A as
This is the matrix we derived in Section 5.10, “Defining a Map.”
Triangle T is defined by the vertices
and triangle T′ is defined by the vertices
The matrices V and V′ are then defined as
The inverse of the matrix V is
thus the linear map A is defined as
Do you recognize the map?
Let’s try a sample point
in T. This point is mapped to
in T′.
Note that V’s inverse V−1 might not exist; this is the case when v2 and v3 are linearly dependent and thus |V| = 0.
Linear maps are an important theoretical tool, but ultimately we are interested in affine maps; they map objects that are defined by points to other such objects.
If an affine map is given by
nothing keeps us from applying it twice, resulting in x″:
This may be repeated several times—for interesting choices of A and p, interesting images will result.
For Figure 6.4 (left), the affine map is defined by
In Figure 6.4 (right), a translation was added:
For both images, the linear map is a composition of a scale and a rotation. In the left image, each successive iteration is applied to geometry that is centered about the origin. In the right image, the translation steps away from the origin, thus the rotation action moves the geometry in the e2-direction even though the translation is strictly in e1.
For Figure 6.5 (left), the affine map is
In Figure 6.5 (right), a translation was added:
For both images, the linear map is a composition of a shear, scale, and rotation. In the left image, each successive iteration is applied to geometry that is centered about the origin. In the right image, the translation steps away from the origin, thus the rotation action moves the geometry in the e2-direction even though the translation is strictly in e1. Same idea as in Example 6.5, but a very different affine map! One interesting artifact of this map: We expect a circle to be mapped to an ellipse, but by iteratively applying the shear and rotation, the ellipse is stretched just right to morph back to a circle!
Rotations can also be made more interesting. In Figure 6.6, you see the letter S rotated several times around the origin, which is near the lower left of the letter.
Adding scaling and rotation results in Figure 6.7. The basic affine map for this case is given by
where R rotates by −20°, S scales nonuniformly, and p translates:
We finish this chapter with Figure 6.8 by the Dutch artist, M.C. Escher [5], who in a very unique way mixed complex geometric issues with a unique style. The figure plays with reflections, which are affine maps.
Figure 6.8 is itself a 2D object, and so may be subjected to affine maps. Figure 6.9 gives an example. The matrix used here is
No translation is applied.
For Exercises 1 and 2 let an affine map be defined by
Let
and q = (1/3)r + (2/3)s. Compute r′, s′, q′ ; e.g., r′ = Ar + p. Show that q′ = (1/3) r′ + (2/3)s′.
Let
Compute t′ and m′. Sketch the lines defined by t, m and t′, m′. Do the same for r and s from Exercise 1. What does this illustrate?
Map the three collinear points
to points by the affine map Ax + p, where
What is the ratio of the xi? at is the ratio of the ?
Rotate the point
by 90° around the point
Define the matrix and point for this affine map.
by 45° around the point p0. Define the affine map needed here in terms of a matrix and a point. Hint: Note that the points are evenly spaced so some economy in calculation is possible.
Reflect the point about the line
Reflect the points
about the line l(t) = p0 + tv, where
Hint: Note that the points are evenly spaced so some economy in calculation is possible.
Given a triangle T with vertices
and T′ with vertices
what is the affine map that maps T to T′ What are the coordinates of the point x′ corresponding to x = [1/2 1/2]T ?
Given a triangle T with vertices
and T′ with vertices
suppose that the triangle T has been mapped to T′ via an affine map. What are the coordinates of the point x′ corresponding to
Let’s revisit the coordinate transformation from Exercise 10 in Chapter 1. Construct the affine map which takes a 2D point x in NDC coordinates to the 2D point x′ in a viewport. Recall that the extents of the NDC system are defined by the lower-left and upper-right points
respectively. Suppose we want to map to a viewport with extents
After constructing the affine map, find the points in the viewport associated with the NDC points
18.218.137.93