• Study Resource
• Explore

# Download x - College of Computer and Information Science

Survey
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
```CS U540
Computer Graphics
Prof. Harriet Fell
Spring 2009
Lecture 11 – January 28, 2009
May 7, 2017
©College of Computer and Information Science, Northeastern University
1
Today’s Topics
• Linear Algebra Review
 Matrices
 Transformations
• New Linear Algebra
 Homogeneous Coordinates
May 7, 2017
©College of Computer and Information Science, Northeastern University
2
Matrices
 a11 a12 
A 

a
a
 21 22 
 b11 b12
B  b21 b22

b31 b32
b13 
b23 

b33 
 c11 c12
c
c22
21

C
 c31 c32

 c41 c42
c13 c14 
c23 c24 

c33 c34 

c43 c44 
• We use 2x2, 3x3, and 4x4 matrices in computer
graphics.
• We’ll start with a review of 2D matrices and
transformations.
May 7, 2017
©College of Computer and Information Science, Northeastern University
3
Basic 2D Linear Transforms
 a11
a
 21
a12   x   a11 x  a12 y 




a22   y  a21 x  a22 y 
 a11 a12  1  a11 
 
a



 21 a22  0 a21 
May 7, 2017
 a11 a12  0  a12 
 
a



 21 a22  1 a22 
©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)
May 7, 2017
©College of Computer and Information Science, Northeastern University
5
Scaling by .5
y
y
0.5 0 
 0 0.5


x
May 7, 2017
©College of Computer and Information Science, Northeastern University
x
6
General Scaling
y
y
 sxs 00 1  sx0
 0 x s   0   
  0 ysy 01  0sy 


 
x
May 7, 2017
©College of Computer and Information Science, Northeastern University
x
7
General Scaling
y
y
scale  sx , s y  
1
 sx
0

x
1
May 7, 2017
sy
0
s y 
x
sx
©College of Computer and Information Science, Northeastern University
8
Rotation
rot   
cos    sin   


 sin   cos   
 sin()
cos()
-sin()
 cos()
May 7, 2017
©College of Computer and Information Science, Northeastern University
9
Rotation
y
rot   
y
cos    sin   


 sin   cos   

x
May 7, 2017
©College of Computer and Information Science, Northeastern University
x
10
Reflection in y-axis
reflect-y 
 1 0 
 0 1


May 7, 2017
©College of Computer and Information Science, Northeastern University
11
Reflection in y-axis
y
reflect-y 
y
 1 0 
 0 1


x
May 7, 2017
©College of Computer and Information Science, Northeastern University
x
12
Reflection in x-axis
reflect-x 
1 0 
0 1


May 7, 2017
©College of Computer and Information Science, Northeastern University
13
Reflection in x-axis
y
y
reflect-x 
1 0 
0 1


x
May 7, 2017
©College of Computer and Information Science, Northeastern University
x
14
Shear-x
shear-x  s  
1 s 
 0 1


s
May 7, 2017
©College of Computer and Information Science, Northeastern University
15
Shear x
y
y
1 s 
 0 1


x
May 7, 2017
©College of Computer and Information Science, Northeastern University
x
16
Shear-y
shear-y  s  
1 0 
 s 1


s
May 7, 2017
©College of Computer and Information Science, Northeastern University
17
Shear y
y
y
1 0
 s 1


x
May 7, 2017
©College of Computer and Information Science, Northeastern University
x
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)
May 7, 2017
©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)
May 7, 2017
©College of Computer and Information Science, Northeastern University
20
Arbitrary Line (through the origin)
y
y
x
May 7, 2017
©College of Computer and Information Science, Northeastern University
x
21
Reflection as a Composition
y
x
May 7, 2017
©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
May 7, 2017
©College of Computer and Information Science, Northeastern University
23
an Arbitrary Point
y
y


x
x
This is not a linear transformation. The origin moves.
May 7, 2017
©College of Computer and Information Science, Northeastern University
24
Translation
(x, y)(x+a,y+b)
y
y
(a, b)
x
x
This is not a linear transformation. The origin moves.
May 7, 2017
©College of Computer and Information Science, Northeastern University
25
Homogeneous Coordinates
y
y
Embed the xy-plane in R3 at z = 1.
(x, y)  (x, y, 1)
x
x
z
May 7, 2017
©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




a
a
x

a
y
22 
 21 22   y   21
or a 3x3 matrix
 a11 a12 0  x   a11 x  a12 y 
a
  y   a x  a y 
a
0
22 
 21 22
    21
0 1  1  
1
 0

May 7, 2017
©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 
This is a 3D shear that acts as a
translation on the plane z = 1.
May 7, 2017
©College of Computer and Information Science, Northeastern University
28
Translation as a Shear
y
y
x
x
z
May 7, 2017
©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.
May 7, 2017
©College of Computer and Information Science, Northeastern University
30
an Arbitrary Point
y
y


x
May 7, 2017
©College of Computer and Information Science, Northeastern University
x
31
an Arbitrary Point
y
T(cx, cy) R()T(-cx, -cy)


May 7, 2017
x
©College of Computer and Information Science, Northeastern University
32
Windowing Transforms
(A,B)
(a,b)
translate
(A-a,B-b)
scale
(C,D)
(C-c,D-d)
translate (c,d)
May 7, 2017
©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
a
a
 21 22
 a31 a32
May 7, 2017
 a11 a12
a13 
a
a22
21


a23 

 a31 a32
a33 

0
0
a13 0
a22 0

a33 0

0 1
©College of Computer and Information Science, Northeastern University
34
3D Affine Transformations
 sx
0
scale  sx , s y , sz   
0

0
0
sy
0
0
0
0
sz
0
0
0

0

1
1
0
translate  t x , t y , tz   
0

0
May 7, 2017
0
1
0
0
0 tx 
0 ty 

1 tz 

0 1
©College of Computer and Information Science, Northeastern University
35
3D Rotations
0
0
1
0 cos    sin  
rotate x    
0 sin   cos  

0
0
0
rotatez   
May 7, 2017
0
0

0

1
 cos  

0

rotate y   
  sin  

cos    sin   0 0
0



sin

cos

0
0









0
0
0
0
0 sin   0

1
0
0
0 cos   0

0
0
1
1 0

0 1
©College of Computer and Information Science, Northeastern University
36
```
Related documents