Graphics Programs Reference
In-Depth Information
The same principle applies to a three-dimensional image. Such an image consists of
one or more three-dimensional objects that can be transformed individually, following
which the entire image should be projected on the two-dimensional screen (or other
output device). We first take a look at the mathematics of two-dimensional transfor-
mations.
We use the notation P =( x, y ) for a point and P =( x ,y ) for the transformed
point. We are looking for a simple, fast transformation rule, so it is natural to try a linear
transformation (i.e., a mathematical rule that does not use functions more complicated
than x ). The simplest linear transformation is x = ax + cy and y = bx + dy ,in
which each of the new coordinates is a linear combination of the two old ones. This
transformation can be written P = PT ,where T is the 2
cd .Thus,the
transformation depends on just four parameters, which makes it easy to analyze and
fully understand it.
To understand the effect of each of the four matrix elements, we start by setting
b = c = 0. The transformation becomes x = ax , y = dy . Such a transformation is
called scaling . Ifappliedtoallthepointsofanobject,allthe x dimensions are scaled
by a factor of a and all the y dimensions are scaled by a factor of d . Note that a and d
can also be less than 1, which causes shrinking of the object. If a or d (or both) equal
2 matrix ab
×
1, the transformation is a reflection . Any other negative values result in both scaling
and reflection.
Note that scaling an object by factors of a and d changes its area by a factor of
0 d .
Here are examples of scaling and reflection. In A ,the y coordinates are scaled by
afactorof2. In B ,the x coordinates are reflected. In C ,the x dimensions are shrunk
to 0 . 001 of their original values. In D , the figure is shrunk to a vertical line.
A = 10
02
d and that this factor is also the value of the determinant of the scaling matrix a 0
a
×
,
B = 10
01
,
C = 0 . 001 0
01
,
D = 00
01
.
Exercise 1.4: What scaling transformation changes a circle to an ellipse?
The next step is to set a =1and d = 1 (no scaling or reflection) and explore the
effect of matrix elements b and c . The transformation becomes x = x + cy , y = bx + y .
We first set b =1and c =0andlookathowmatrix 1 01 transforms the four points (1 , 0),
(3 , 0), (1 , 1), and (3 , 1). They are transformed to (1 , 1), (3 , 3), (1 , 2), and (3 , 4). When we
plot the original and the transformed points (Figure 1.2a), it becomes obvious that the
original rectangle has been sheared vertically and was transformed into a parallelogram.
A similar shearing effect results from matrix 1 11 . The quantities b and c are therefore
responsible for shearing . Figure 1.2b shows the connection between shearing and the
operation of scissors. This is the reason for the name shearing.
Exercise 1.5: Apply the shearing transformation 1 1
01 to the four points (1 , 0), (3 , 0),
(1 , 1), and (3 , 1). What are the transformed points? What geometrical figure do they
represent?
The next important transformation is rotation . Figure 1.3 shows a point P rotated
clockwise about the origin through an angle θ to become P . Simple trigonometry yields
Search WWH ::




Custom Search