computer graphics csc 630 lecture 2- linear algebra
Post on 21-Dec-2015
229 views
TRANSCRIPT
![Page 1: Computer Graphics CSC 630 Lecture 2- Linear Algebra](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d555503460f94a31f8b/html5/thumbnails/1.jpg)
Computer GraphicsComputer GraphicsCSC 630CSC 630
Computer GraphicsComputer GraphicsCSC 630CSC 630
Lecture 2- Linear AlgebraLecture 2- Linear Algebra
![Page 2: Computer Graphics CSC 630 Lecture 2- Linear Algebra](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d555503460f94a31f8b/html5/thumbnails/2.jpg)
2
What is Computer Graphics?
• Using a computer to generate an image from a representation.
Model Imagecomputer
![Page 3: Computer Graphics CSC 630 Lecture 2- Linear Algebra](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d555503460f94a31f8b/html5/thumbnails/3.jpg)
3
Model Representations• How do we represent an object?
– Points – Mathematical Functions
• X2 + Y2 = R2
– Polygons (most commonly used)• Points• Connectivity
![Page 4: Computer Graphics CSC 630 Lecture 2- Linear Algebra](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d555503460f94a31f8b/html5/thumbnails/4.jpg)
4
Linear Algebra• Why study Linear Algebra?
– Deals with the representation and operations commonly used in Computer Graphics
![Page 5: Computer Graphics CSC 630 Lecture 2- Linear Algebra](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d555503460f94a31f8b/html5/thumbnails/5.jpg)
5
What is a Matrix?• A matrix is a set of elements,
organized into rows and columns
1110
0100
aa
aa
n columns
m rows
m×n matrix
![Page 6: Computer Graphics CSC 630 Lecture 2- Linear Algebra](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d555503460f94a31f8b/html5/thumbnails/6.jpg)
6
What is a Vector?• Vector: n×1
matrix
c
b
a
v
x
y
v
![Page 7: Computer Graphics CSC 630 Lecture 2- Linear Algebra](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d555503460f94a31f8b/html5/thumbnails/7.jpg)
7
Representing Points and Vectors
• A 3D point– Represents a
location with respect to some coordinate system
• A 3D vector – Represents a
displacement from a position
c
b
a
p
c
b
a
v
![Page 8: Computer Graphics CSC 630 Lecture 2- Linear Algebra](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d555503460f94a31f8b/html5/thumbnails/8.jpg)
8
Basic Operations• Transpose: Swap rows with columns
ihg
fed
cba
M
ifc
heb
gda
M T
z
y
x
V zyxV T
![Page 9: Computer Graphics CSC 630 Lecture 2- Linear Algebra](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d555503460f94a31f8b/html5/thumbnails/9.jpg)
9
Vector Addition• Given v = [x y z]T and w = [a b c]T
v + w = [x+a y+b z+c]T
• Properties of Vector addition– Commutative: v + w = w + v– Associative (u + v) + w = u + (v + w)– Additive Identity: v + 0 = v– Additive Inverse: v + (-v) = 0
![Page 10: Computer Graphics CSC 630 Lecture 2- Linear Algebra](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d555503460f94a31f8b/html5/thumbnails/10.jpg)
10
Parallelogram Rule• To visualize what a vector addition
is doing, here is a 2D example:
vw
v+w
![Page 11: Computer Graphics CSC 630 Lecture 2- Linear Algebra](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d555503460f94a31f8b/html5/thumbnails/11.jpg)
11
Vector Multiplication• Given v = [x y z]T and a Scalar s and t
– sv = [sx sy sz]T and tv = [tx ty tz]T
• Properties of Vector multiplication– Associative: (st)v = s(tv)– Multiplicative Identity: 1v = v– Scalar Distribution: (s+t)v = sv+tv– Vector Distribution: s (v+w) = sv+sw
![Page 12: Computer Graphics CSC 630 Lecture 2- Linear Algebra](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d555503460f94a31f8b/html5/thumbnails/12.jpg)
12
Vector Spaces• Consists of a set of elements,
called vectors.• The set is closed under vector
addition and vector multiplication.
![Page 13: Computer Graphics CSC 630 Lecture 2- Linear Algebra](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d555503460f94a31f8b/html5/thumbnails/13.jpg)
13
Dot Product and Distances
• Given u = [x y z] T and v = [a b c] T
– v•u = vTu = ax+by+cz
• The Euclidean distance of u from the origin is denoted by ||u|| and called norm or length– ||u|| = sqrt(x2+y2+z2)– Notice that ||u|| = sqrt(u •u)– Unit vector ||u|| = 1, zero vector denoted 0
• The Euclidean distance between u and v is sqrt((x-a) 2+(y-b) 2+(z-c) 2)) and is denoted by ||u-v||
![Page 14: Computer Graphics CSC 630 Lecture 2- Linear Algebra](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d555503460f94a31f8b/html5/thumbnails/14.jpg)
14
Properties of the Dot Product
• Given a vector u, v, w and scalar s– The result of a dot product is a
SCALAR value– Commutative: v•w = w•v– Non-degenerate: v•v=0 only when
v=0
![Page 15: Computer Graphics CSC 630 Lecture 2- Linear Algebra](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d555503460f94a31f8b/html5/thumbnails/15.jpg)
15
Angles and Projection• Alternative view of the dot product• v•w=||v|| ||w|| cos() where is
the angle between v and w
v
w
v
w v=w
If v and w have length 1…
v·w = 0 v·w = 1 v·w = cos θ
θ
![Page 16: Computer Graphics CSC 630 Lecture 2- Linear Algebra](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d555503460f94a31f8b/html5/thumbnails/16.jpg)
16
Angles and Projection• If v is a unit vector (||v|| = 1) then
if we perpendicularly project w onto v can call this newly projected vector u then
||u|| = v•ww
vu
![Page 17: Computer Graphics CSC 630 Lecture 2- Linear Algebra](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d555503460f94a31f8b/html5/thumbnails/17.jpg)
17
Cross Product Properties
• The Cross Product c of v and w is denoted by vw
• c Is a VECTOR, perpendicular to the plane defined by v and w
• The magnitude of c is proportional to the sin of the angle between v and w
• The direction of c follows the right hand rule.• ||vw||=||v|| ||w|| |sin|
is the angle between v and w
• vw=-(wv)
v
wvw
![Page 18: Computer Graphics CSC 630 Lecture 2- Linear Algebra](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d555503460f94a31f8b/html5/thumbnails/18.jpg)
18
Cross Product• Given 2 vectors v=[v1 v2 v3], w=[w1 w2 w3],
the cross product is defined to be the determinant of
where i,j,k are vectors
1221
3113
2332
321
321
wvwv
wvwv
wvwv
www
vvv
kji
![Page 19: Computer Graphics CSC 630 Lecture 2- Linear Algebra](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d555503460f94a31f8b/html5/thumbnails/19.jpg)
19
Matrices• A compact way of representing operations on
points and vectors• 3x3 Matrix A looks like
aij refers to the element of matrix A in ith row and jth column
333231
232221
131211
aaa
aaa
aaa
![Page 20: Computer Graphics CSC 630 Lecture 2- Linear Algebra](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d555503460f94a31f8b/html5/thumbnails/20.jpg)
20
Matrix Addition
hdgc
fbea
hg
fe
dc
ba
Just add elements
![Page 21: Computer Graphics CSC 630 Lecture 2- Linear Algebra](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d555503460f94a31f8b/html5/thumbnails/21.jpg)
21
Matrix Multiplication• If A is an nk matrix and B is a kp
then AB is a np matrix with entries cij
where cij= aisbsj
• Alternatively, if we took the rows of A and columns of B as individual vectors then cij = Ai•Bj where the subscript refers to the row and column, respectively
dhcfdgce
bhafbgae
hg
fe
dc
ba Multiply each row by each column
![Page 22: Computer Graphics CSC 630 Lecture 2- Linear Algebra](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d555503460f94a31f8b/html5/thumbnails/22.jpg)
22
Matrix Multiplication Properties
• Associative: (AB)C = A(BC)• Distributive: A(B+C) = AB+AC• Multiplicative Identity: I= diag(1)
(defined only for square matrix) • Identity matrix: AI = A• NOT commutative: ABBA
100
010
001
I
![Page 23: Computer Graphics CSC 630 Lecture 2- Linear Algebra](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d555503460f94a31f8b/html5/thumbnails/23.jpg)
23
Matrix Inverse• If A and B are nxn matrices and
AB=BA=I then B is the inverse of A, denoted by A-1
• (AB)-1=B-1A-1 same applies for transpose
• T
MM T 11
![Page 24: Computer Graphics CSC 630 Lecture 2- Linear Algebra](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d555503460f94a31f8b/html5/thumbnails/24.jpg)
24
Determinant of a Matrix
• Defined on a square matrix (nxn)• Used for inversion
• If det A = 0, then A has no inverse
dc
baA
bcadA )det(
![Page 25: Computer Graphics CSC 630 Lecture 2- Linear Algebra](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d555503460f94a31f8b/html5/thumbnails/25.jpg)
25
Determinant of a Matrix
• For a nxn matrix,
where A1i determinant of (n-1)x(n-1) submatrix A gotten by deleting the first row and the ith column
n
i ii
i AaAA1 1
11 )1(det
![Page 26: Computer Graphics CSC 630 Lecture 2- Linear Algebra](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d555503460f94a31f8b/html5/thumbnails/26.jpg)
26
Transformations• Why use transformations?
Create object in convenient coordinates
Reuse basic shape multiple times Hierarchical modeling System independent Virtual cameras
![Page 27: Computer Graphics CSC 630 Lecture 2- Linear Algebra](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d555503460f94a31f8b/html5/thumbnails/27.jpg)
27
Translation
z
y
x
z
y
x
t
t
t
= +
z
y
x
tttT zyx ),,(
z
y
x
z
y
x
t
t
t
= +
'
'
'
z
y
x
![Page 28: Computer Graphics CSC 630 Lecture 2- Linear Algebra](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d555503460f94a31f8b/html5/thumbnails/28.jpg)
28
Properties of Translation
v=v)0,0,0(T
=v),,(),,( zyxzyx tttTsssT
=
=v),,(1zyx tttT
v),,(),,( zyxzyx tttTsssT v),,(),,( zyxzyx sssTtttT
v),,( zzyyxx tststsT
v),,( zyx tttT
![Page 29: Computer Graphics CSC 630 Lecture 2- Linear Algebra](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d555503460f94a31f8b/html5/thumbnails/29.jpg)
29
Rotations (2D)
sin
cos
ry
rx
cos)sin(sin)cos('
sin)sin(cos)cos('
rry
rrx
)sin('
)cos('
ry
rx
cossinsincos)sin(
sinsincoscos)cos(
cossin'
sincos'
yxy
yxx
yx,
',' yx
x
y
![Page 30: Computer Graphics CSC 630 Lecture 2- Linear Algebra](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d555503460f94a31f8b/html5/thumbnails/30.jpg)
30
Rotations 2D• So in matrix notation
y
x
y
x
cossin
sincos'
'
![Page 31: Computer Graphics CSC 630 Lecture 2- Linear Algebra](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d555503460f94a31f8b/html5/thumbnails/31.jpg)
31
Rotations (3D)
100
0cossin
0sincos
)(
cos0sin
010
sin0cos
)(
cossin0
sincos0
001
)(
z
y
x
R
R
R
![Page 32: Computer Graphics CSC 630 Lecture 2- Linear Algebra](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d555503460f94a31f8b/html5/thumbnails/32.jpg)
32
Properties of RotationsIRa )0(
)()()()( aaaa RRRR
)()()( aaa RRR
)()()(1 Taaa RRR
)()()()( abba RRRR order matters!
![Page 33: Computer Graphics CSC 630 Lecture 2- Linear Algebra](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d555503460f94a31f8b/html5/thumbnails/33.jpg)
33
Combining Translation & Rotation
)1,1(T
)45( R
)45( R
)1,1(T
![Page 34: Computer Graphics CSC 630 Lecture 2- Linear Algebra](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d555503460f94a31f8b/html5/thumbnails/34.jpg)
34
Combining Translation & Rotation
Tvv'
RTR
TR
R
vv
vv
vv
''
)(''
'''
vv R'
TR
T
vv
vv
''
'''
![Page 35: Computer Graphics CSC 630 Lecture 2- Linear Algebra](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d555503460f94a31f8b/html5/thumbnails/35.jpg)
35
Scaling
zs
ys
xs
z
y
x
z
y
x
'
'
'
z
y
x
zyx
s
s
s
sssS
00
00
00
),,(
Uniform scaling iff zyx sss
![Page 36: Computer Graphics CSC 630 Lecture 2- Linear Algebra](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d555503460f94a31f8b/html5/thumbnails/36.jpg)
36
Homogeneous Coordinates
z
y
x
w
Z
Y
X
can be represented as
wherew
Zz
w
Yy
w
Xx ,,
![Page 37: Computer Graphics CSC 630 Lecture 2- Linear Algebra](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d555503460f94a31f8b/html5/thumbnails/37.jpg)
37
Translation Revisited
11000
100
010
001
),,(z
y
x
t
t
t
z
y
x
tttTz
y
x
zyx
![Page 38: Computer Graphics CSC 630 Lecture 2- Linear Algebra](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d555503460f94a31f8b/html5/thumbnails/38.jpg)
38
Rotation & Scaling Revisited
11000
000
000
000
),,(z
y
x
s
s
s
z
y
x
sssSz
y
x
zyx
11000
0cossin0
0sincos0
0001
)(z
y
x
z
y
x
Rx
![Page 39: Computer Graphics CSC 630 Lecture 2- Linear Algebra](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d555503460f94a31f8b/html5/thumbnails/39.jpg)
39
Combining Transformations
vv
vvvv
vvv
vv
M
TRSTRT
RSR
S
'''
''''''
'''
'
where TRSM
![Page 40: Computer Graphics CSC 630 Lecture 2- Linear Algebra](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d555503460f94a31f8b/html5/thumbnails/40.jpg)
40
Transforming Tangents
t
qp
qp
qpt
qpt
M
M
MM
)(
'''
![Page 41: Computer Graphics CSC 630 Lecture 2- Linear Algebra](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d555503460f94a31f8b/html5/thumbnails/41.jpg)
41
Transforming Normals
nnn
nn
nn
tntn
tn
tn
tn
TT
T
TT
TT
T
T
T
MM
M
M
M
M
11'
'
'
'
0'
0''
0