Graphics Programs Reference
In-Depth Information
y
y
1
P 3
P 4
5
3/4
P 3
4
1/2
P 4
3
2
1/4
P 1
1
P 1
P 2
P 2
x
x
1
1/4
1/2
3/4
1
2
3
4
5
6
(a)
(b)
Figure 1.5: A Two-Dimensional Projection of a Square.
In general, matrix multiplication is noncommutative, reflecting the fact that geo-
metric transformations are also noncommutative. It is easy to convince yourself that,
for example, a rotation about the origin followed by a translation is not the same as a
translation followed by a rotation about the origin.
Note that all the transformations discussed earlier are performed about the origin.
Figure 1.6a shows an object rotated 40 clockwise. It is easy to see that the center
of rotation is the origin. If, for example, we want to rotate an object about a point
P , we have to translate both the object and the point such that P goes to the origin
(Figure 1.6b), then rotate the object, and finally translate back (Figure 1.6c). Similarly,
to reflect an object through an arbitrary line, we have to (1) translate the line (and the
object) until it passes through the origin, (2) rotate the line (and the object) until it
coincides with one of the coordinate axes, (3) reflect through that axis, (4) rotate back,
and (5) translate back.
(Transformations are usually done about the origin. See Exercise 3.10 for an ex-
ample on how this affects scaling in three dimensions.)
Exercise 1.12: Derive the rotation matrix for a two-dimensional rotation about a point
( x 0 ,y 0 ) using just trigonometry (i.e., without using translation).
Example: Reflection through the line y = x + 1 . This line has a slope of 1
(i.e., it makes an angle of 45 with the x axis) and it intercepts the y axis at y =1.
We first translate down one unit, then rotate clockwise by 45 , then reflect through the
x axis, rotate back, and translate back. The result is ( α stands for both sin 45 and
cos 45 )
100
010
0
α
α 0
αα 0
001
100
0
αα 0
100
010
011
T =
10
001
αα 0
001
11
0 α 2
1
010
100
=
=
2 α 2
00
2 α 2
11
111
Search WWH ::




Custom Search