Computer Graphics & Linear Algebra: Gabrien Clark May 5, 2010
Computer Graphics & Linear Algebra: Gabrien Clark May 5, 2010
Gabrien Clark
May 5, 2010
Computer Graphics
1 Introduction
The area of computer graphics is a vast and ever expanding field. In the
simplest sense computer graphics are images viewable on a computer screen.
Applications extend into such processes as engineering design programs and
almost any type of media. The images are generated using computers and
likewise, are manipulated by computers. Underlying the representation of
the images on the computer screen is the mathematics of Linear Algebra.
We will explore the fundamentals of how computers use linear algebra to
create these images, and branch off into basic manipulation of these images.
2 2-Dimensional Graphics
Examples of computer graphics are those of which belong to 2 dimensions.
Common 2D graphics include text. For example the vertices of the letter H
can be represented by the following data matrix D:
" #
0 0 0 1 1 1
D=
0 1 2 0 1 2
2.1 Scaling
There are many types of transformations that these graphics can undergo,
the first one we will consider is scaling. A point in the xy plane coordinates
1
" #
X
are given by (x,y) or A= .
Y
" #
C1 0
The scaling transformation is given by the matrix S= . Where
0 C2
the Ci s are scalars. The scaling transforms the coordinates (x,y) into (C1 x,
C2 y). In mathematical terms the transformation is given by the multiplica-
tion of the matrices S and A:
Example: Now let’s examine how scaling affects our example H. Let C1 =2
and C2 =2, our new coordinates for D are:
0 0 0 2 2 2
D= 0 2 4 0 2 4
0 0 0 0 0 0
The new H is now twice as long in the X-direction and twice as long in the
Y-direction.
Now that we have examined the scaling transformation, let’s move on to
the other two basic transformations that underly the movement of a figure
on a computer screen, translating and rotating.
2.2 Translation
X
Let’s revisit our example matrix A with coordinates (X,Y,1) or Y . The
1
post-translational
h i coordinates of A can be obtained by multiplying A by the
matrix I T , where I represents the I3 Identity Matrix, and T represents
the column vector containing the translation coordinates for A. Mathemat-
ically speaking
translation
is represented
by:
h i X 1 0 X0 X X+X0
I T Y = 0 1 Y0 Y = Y +Y0
1 0 0 1 1 1
Example: Let us now revisit our example letter and H and show how it is
affected by an arbitrary
translation. Let us setour arbitrary translational
2 h i 1 0 2
vector to T= 3 , then I T = 0 1 3 , and the final matrix can
1 0 0 1
be given by:
2
h ih i2 2 2 3 3 3
I T D = 3 4 5 3 4 5
0 0 0 0 0 0
Our examle letter H has now moved 2 units in the positve X-direction
and 3 units in the positive Y-direction.
2.3 Rotation
Next, we have the transformation of rotation. A more complex transfor-
mation, rotation changes the orientation of the image about some axis,
in our case
either X or Y. Clockwise
rotations have the rotational matrix
cos(θ) −sin(θ) 0
R(−θ) = sin(θ) cos(θ) 0 , but all rotational matrices are given in a
0 0 1
variation
of the form of the rotational
matrix for counter-clockwise rotation
cos(θ) −sin(θ) 0
R(θ) = sin(θ) cos(θ) 0 . The counter-clockwise rotation of matrix
0 0 1
A is given by:
h ih i cos(θ) −sin(θ) 0 X
R(θ) A = sin(θ) cos(θ) 0 Y
0 0 1 1
XCos(θ) − Y Sin(θ)
= XSin(θ) + Y Cos(θ)
1
3
0 −1 −2 0 −1 −2
0 0 0 1 1 1
0 0 0 0 0 0
If we refer to both the earlier visualization and mathematical display we
see that letter H has been rotated 90◦ about the origin.
3 3-Dimensional Graphics
Now that we’ve effectively explored the region of 2-Dimensional, we can be-
gin to explore the region of 3-Dimensional graphics. 3-Dimensional graphics
live in R3 versus 2-Dimensional graphics which live in R2 . 3-Dimensional
graphics have a vast deal more applications in comparison to 2-Dimensional
graphics, and are, likewise, more complicated. We will now work with the
variable Z, in addition to X and Y, to fully represent coordinates on the X,
Y, and Z axes, or simply space.
4
can not be added or multiplied by scalars. In R3 they may only be multi-
plied by 4x4 matrices.) If H6= 0, then :
x
• X= H
y
• Y = H
z
• Z= H
Solution:
Refer to our earlier equations for finding the coordinates (x,y,z). Let’s
show two solutions for the question.
Solution 1: Let H = 21 :
4 2 7
x= 1 = 8, y = 1 = 4, z = 1 = 14
2 2 2
4 2 7
x= 2 = 2, y = 2 = 1, z = 2 = 3.5
3.1 Visualization
5
(x2 , y2 , z2 ), (x3 , y3 , z3 ), ..., (xn , yn , zn ). These line segments and co-
ordinates are placed in the memory of a computer. The corresponding
coordinate matrix can be represented by:
X1 X2 . . . Xn
P= Y1 Y2 . . . Yn
Z1 Z2 . . . Zn
1
Solution: If we scale the coordinates by 1− dz , then (x, y, z, 1)−→ (x 1− z ,
d
y
1− z , 0, 1)
d
x 1 0 0 0 x x
y 0 1 0 0 y y
P = =
z 0 0 0 0
z 0
1 0 0 −1 10 1 1 1 1− z
d
3.2 Scaling
6
C1 0 0
S= 0 C2 0
0 0 C3
Example: Give
the matrix for a scaled cube with original coordinates
0 0 0 0 2 2 2 2
given by A= 0 2 2 0 0 2 2 0 , and the scaling matrix is
0 0 −2 −2 0 0 −2 −2
1 0 0
given by S= 0 2 0
0 0 3
Solution:
h ih i 1 0 0 0 0 0 0 2 2 2 2
S A = 0 2 0 0 2 2 0 0 2 2 0
0 0 3 0 0 −2 −2 0 0 −2 −2
0 0 0 0 2 2 2 2
= 0 4 4 0 0 4 4 0
0 0 −6 −6 0 0 −6 −6
From calculating the new matrix we can see that the cube isn’t scaled in the
X-direction, scaled to twice it’s size in the positive Y-direction, and scaled
to triple it’s size in the negative Z-direction.
3.3 Translation
7
in 3-dimensions
is represented by
the matrix multiplication of the transla-
1 0 0 X0 X
0 1 0 Y Y
0
tion vector T= , and the coordinate matrix A= .
0 0 1 Z0 Z
0 0 0 1 1
Mathematically speaking we can represent the 3-Dimensional translation
transformation with:
1 0 0 X0 X X+X0
0 1 Y
0 Y0 Y +Y0
h ih i
T A = =
0 0 1 Z0 Z Z+Z0
0 0 0 1 1 1
Example: Give the matrix for the translation of a point (5, 3, -8, 1) by
the vector p=(-4, -6, 3)
Y, Z, 1) −→ (X
Solution: The matrixthat maps (X, − 4, Y − 6, Z + 3, 1) is
1 0 0 −4 5
h i 0 1 0 −6 3
given by I T = , A= , so :
0 0 1 3 −8
0 0 0 1 1
1 0 0 −4 5 1
h ih i 0 1 0 −6 3
−3
I T A = =
0 0 1 3 −8 −5
0 0 0 1 1 1
3.4 Rotation
1 0 0
• R(θ)X = 0 Cos(θ) −Sin(θ)
0 Sin(θ) Cos(θ)
8
Cos(θ) 0 Sin(θ)
• R(θ)Y = 0 1 0
−Sin(θ) 0 Cos(θ)
Cos(θ) −Sin(θ) 0
• R(θ)Z = Sin(θ) Cos(θ) 0
0 0 1
Example: Give the final Rotational Matrix, R, for an image that is first
rotated about the X-axis 47◦ , then about the Y-axis 52◦ , and then about
the Z-axis -30◦ .
9
4 Conclusion
Today we have only scratched the surface of the world of computer graphics.
The advancement of computer grahics has made technology more functional
and user-friendly. Mainstream applications of computer graphics can be seen
in every type of media including animation, movies, and video games. The
breadth of computer graphics range from basic pixel art and vector graphics
to the incredibly realistic animation of high end 3D gaming programs, such
as games typically played on Microsoft
Xbox
c 360. Applications of these
graphics also extend into the world of science. Currently biologists are using
computer grapchis for molecular modeling. Through these crucial visualiza-
tions scientists are able to make advances in drug and cancer research, that
otherwise would not be possible. A major future application of computer
graphics lies in the domain of virtual reality. In vitual reality one is able to
experience a synthesized computer environment just as if it were a natural
environment. It would appear that "the sky is the limit" for the world of
computer graphics, but at the basis of it all lies the mathematics of linear
algebra.
5 References
Lay, David C. Linear Algebra and Its Applications. Boston: Addison Wesley,
2003. Print.
Anton, Howard. Elementary Linear Algebra. New York: John Wiley, 1994.
657-65. Print.
Wikipedia contributors. "Computer graphics." Wikipedia, The Free Ency-
clopedia. Wikipedia, The Free Encyclopedia, 3 May. 2010. Web. 4 May.
2010.
Wikipedia contributors. "Rotation matrix." Wikipedia, The Free Encyclo-
pedia. Wikipedia, The Free Encyclopedia, 2 May. 2010. Web. 4 May.
2010.
Jordon, H. Rep. Web. Apr.-May 2010.
<http://math.illinoisstate.edu/akmanf/newwebsite/linearalgebra/computergraphics.pdf>.
10