10 CHAPTER 1 Subdivision: Functions as Fractals
One interesting feature of affine transformations in the plane is that once the
value of an affine transformation
A is known at three noncollinear points p[[0]], p[[1]]
and p[[2]] the action of A on an arbitrary point v can be computed using equation 1.3.
The trick is to express the point
v as an affine combination of the points p[[0]], p[[1]],
and
p[[2]]; that is, v == α
0
p[[0]] +α
1
p[[1]] +α
2
p[[2]], where α
0
+α
1
+α
2
== 1. Given these
weights
α
i
, the value A [v] of the affine transformation
A satisfies
A [v] = α
0
A [p[[0]]] + α
1
A [p[[1]]] + α
2
A [p[[2]]]
due to equation 1.3. These affine weights are the barycentric coordinates of v with
respect to the base triangle
p and can be computed as the ratio of the areas of
various triangles defined by
v and the vertices of p,
{α
0
, α
1
, α
2
}=
{area[v, p[[1]], p[[2]]], area[p[[0]], v, p[[2]]], area[p[[0]], p[[1]] , v]}
area[p[[0]], p[[1]], p[[2]]]
.
(1.4)
Given this observation, all that remains is to specify the behavior of A at the vertices
of
p. One simple solution is to express the position of points A[p[[i]]] in terms of
their barycentric coordinates with respect to the triangle
p. These three sets of
coordinates can be collected into a
3 × 3 matrix S whose rows are the barycentric
coordinates for
A [p[[0]]], A [p[[1]]], and A [p[[2]]] with respect to the triangle p. Given a
point
v with barycentric coordinates {α
0
, α
1
, α
2
} with respect to the triangle p, the
barycentric coordinates of
A [v] with respect to points A [p[[0]]], A [ p[[1]]], and A [p[[2]]]
are the vector/matrix product {α
0
, α
1
, α
2
}S.
To illustrate this method, we next construct the matrix
S that represents the
affine transformation mapping a base triangle
p to an image triangle q. These two
triangles themselves are represented as a column vector consisting of three points in
the plane; that is, a
3×2 matrix, where each row contains the Cartesian coordinates
of the vertices of the triangle. For our example, we let
p and q be the triangles
p =
⎛
⎜
⎝
00
20
11
⎞
⎟
⎠
, q =
⎛
⎜
⎝
00
10
1
2
1
2
⎞
⎟
⎠
.
As observed, the rows of the matrix S are the barycentric coordinates of the vertices
of
q with respect to the base triangle p. Because q[[0]] == p[[0]], the first row of S
is simply {1, 0, 0}. Similarly, q[[1]] is the midpoint of the edge from p[[0]] to p[[1]].
Therefore, the second row of
S is {
1
2
,
1
2
, 0}. Finally, q[[2]] is the midpoint of the edge