Professional Documents
Culture Documents
Computer Graphics
Prof. Harriet Fell
Fall 2012
Lecture 11 – September 27, 2012
September 30, 2019 ©College of Computer and Information Science, Northeastern University 1
Today’s Topics
• Linear Algebra Review
Matrices
Transformations
• New Linear Algebra
Homogeneous Coordinates
September 30, 2019 ©College of Computer and Information Science, Northeastern University 2
Matrices
c11 c12 c13 c14
b11 b12 b13 c
a11 a12 c23 c24
B b21 b22 b23
c22
A C 21
c31 c32 c33 c34
21 22
a a
b31 b32 b33
c41 c42 c43 c44
September 30, 2019 ©College of Computer and Information Science, Northeastern University 3
Basic 2D Linear Transforms
September 30, 2019 ©College of Computer and Information Science, Northeastern University 4
Scale by .5
scale .5,.5
.5 0
0 .5
(1, 0) (0.5, 0)
(0, 1)
(0, 0.5)
September 30, 2019 ©College of Computer and Information Science, Northeastern University 5
Scaling by .5
y y
0.5 0
0 0.5
x x
September 30, 2019 ©College of Computer and Information Science, Northeastern University 6
General Scaling
y y
x x
September 30, 2019 ©College of Computer and Information Science, Northeastern University 7
General Scaling
y y
scale sx , s y
1
sy
sx 0
0 s y
x x
1 sx
September 30, 2019 ©College of Computer and Information Science, Northeastern University 8
Rotation
rot
cos sin
sin cos
φ sin(φ)
cos(φ)
-sin(φ)
φ cos(φ)
September 30, 2019 ©College of Computer and Information Science, Northeastern University 9
Rotation
y
rot
y
cos sin
sin cos
φ
x x
September 30, 2019 ©College of Computer and Information Science, Northeastern University 10
Reflection in y-axis
reflect-y
1 0
0 1
September 30, 2019 ©College of Computer and Information Science, Northeastern University 11
Reflection in y-axis
y y
reflect-y
1 0
0 1
x x
September 30, 2019 ©College of Computer and Information Science, Northeastern University 12
Reflection in x-axis
reflect-x
1 0
0 1
September 30, 2019 ©College of Computer and Information Science, Northeastern University 13
Reflection in x-axis
y y
reflect-x
1 0
0 1
x x
September 30, 2019 ©College of Computer and Information Science, Northeastern University 14
Shear-x
shear-x s
1 s
0 1
September 30, 2019 ©College of Computer and Information Science, Northeastern University 15
Shear x
y y
1 s
0 1
x x
September 30, 2019 ©College of Computer and Information Science, Northeastern University 16
Shear-y
shear-y s
1 0
s 1
s
September 30, 2019 ©College of Computer and Information Science, Northeastern University 17
Shear y
y y
1 0
s 1
x x
September 30, 2019 ©College of Computer and Information Science, Northeastern University 18
Linear Transformations
• Scale, Reflection, Rotation, and Shear are
all linear transformations
• They satisfy: T(au + bv) = aT(u) + bT(v)
u and v are vectors
a and b are scalars
• If T is a linear transformation
T((0, 0)) = (0, 0)
September 30, 2019 ©College of Computer and Information Science, Northeastern University 19
Composing Linear
Transformations
• If T1 and T2 are transformations
T2 T1(v) =def T2( T1(v))
• If T1 and T2 are linear and are represented
by matrices M1 and M2
T2 T1 is represented by M2 M1
T2 T1(v) = T2( T1(v)) = (M2 M1)(v)
September 30, 2019 ©College of Computer and Information Science, Northeastern University 20
Reflection About an
Arbitrary Line (through the origin)
y y
x x
September 30, 2019 ©College of Computer and Information Science, Northeastern University 21
Reflection as a Composition
y
September 30, 2019 ©College of Computer and Information Science, Northeastern University 22
Decomposing
Linear Transformations
• Any 2D Linear Transformation can be
decomposed into the product of a rotation,
a scale, and a rotation if the scale can
have negative numbers.
• M = R1SR2
September 30, 2019 ©College of Computer and Information Science, Northeastern University 23
Rotation about
an Arbitrary Point
y y
φ φ
x x
y (x, y)(x+a,y+b) y
(a, b)
x x
September 30, 2019 ©College of Computer and Information Science, Northeastern University 26
2D Linear Transformations
as 3D Matrices
Any 2D linear transformation can be
represented by a 2x2 matrix
a11 a12 x a11 x a12 y
a
21 22 y 21
a a x a 22
y
or a 3x3 matrix
a11 a12 0 x a11 x a12 y
a a 0 y a x a y
21 22 21 22
0 0 1 1 1
September 30, 2019 ©College of Computer and Information Science, Northeastern University 27
2D Linear Translations
as 3D Matrices
Any 2D translation can be represented by
a 3x3 matrix.
1 0 a x x a
0 1 b y y b
0 0 1 1 1
September 30, 2019 ©College of Computer and Information Science, Northeastern University 28
Translation as a Shear
y
September 30, 2019 ©College of Computer and Information Science, Northeastern University 29
2D Affine Transformations
• An affine transformation is any transformation
that preserves co-linearity (i.e., all points lying on
a line initially still lie on a line after
transformation) and ratios of distances (e.g., the
midpoint of a line segment remains the midpoint
after transformation).
• With homogeneous coordinates, we can
represent all 2D affine transformations as 3D
linear transformations.
• We can then use matrix multiplication to
transform objects.
September 30, 2019 ©College of Computer and Information Science, Northeastern University 30
Rotation about
an Arbitrary Point
y y
φ φ
x x
September 30, 2019 ©College of Computer and Information Science, Northeastern University 31
Rotation about
an Arbitrary Point
y
T(cx, cy) R(φ)T(-cx, -cy)
φφ
φφ
x
September 30, 2019 ©College of Computer and Information Science, Northeastern University 32
Windowing Transforms
(A,B)
scale
(C,D)
(C-c,D-d)
translate (c,d)
September 30, 2019 ©College of Computer and Information Science, Northeastern University 33
3D Transformations
Remember: x
x y
y
z
z
1
A 3D linear transformation can be represented by a
3x3 matrix.
a11 a12 a13 0
a11 a12 a13 a
a a22 a22 0
a a23 21
21 22 a31 a32 a33 0
a31 a32 a33
0 0 0 1
September 30, 2019 ©College of Computer and Information Science, Northeastern University 34
3D Affine Transformations
sx 0 0 0
0 0
scale sx , s y , sz
sy 0
0 0 sz 0
0 0 0 1
1 0 0 tx
0 0 ty
translate t x , t y , t z
1
0 0 1 tz
0 0 0 1
September 30, 2019 ©College of Computer and Information Science, Northeastern University 35
3D Rotations
1 0 0 0
0 cos sin 0
rotate x
0 sin cos 0
cos
0 sin 0
0 0 0 1
0 1 0 0
rotate y
sin 0 cos 0
cos sin 0 0
0 0 0 1
rotatez sin cos 0 0
0 0 1 0
0 0 0 1
September 30, 2019 ©College of Computer and Information Science, Northeastern University 36