![Page 1: 1 Matrix Math ©Anthony Steed 1999. 2 Overview n To revise Vectors Matrices n New stuff Homogenous co-ordinates 3D transformations as matrices](https://reader036.vdocuments.us/reader036/viewer/2022082411/56649dd45503460f94acb570/html5/thumbnails/1.jpg)
1
Matrix Math
©Anthony Steed 1999
![Page 2: 1 Matrix Math ©Anthony Steed 1999. 2 Overview n To revise Vectors Matrices n New stuff Homogenous co-ordinates 3D transformations as matrices](https://reader036.vdocuments.us/reader036/viewer/2022082411/56649dd45503460f94acb570/html5/thumbnails/2.jpg)
2
Overview
To revise• Vectors • Matrices
New stuff• Homogenous co-ordinates• 3D transformations as matrices
![Page 3: 1 Matrix Math ©Anthony Steed 1999. 2 Overview n To revise Vectors Matrices n New stuff Homogenous co-ordinates 3D transformations as matrices](https://reader036.vdocuments.us/reader036/viewer/2022082411/56649dd45503460f94acb570/html5/thumbnails/3.jpg)
3
Vectors and Matrices
Matrix is an array of numbers with dimensions M (rows) by N (columns)• 3 by 6 matrix• element 2,3
is (3)
Vector can be considered a 1 x M matrix•
zyxv
100025114311212003
![Page 4: 1 Matrix Math ©Anthony Steed 1999. 2 Overview n To revise Vectors Matrices n New stuff Homogenous co-ordinates 3D transformations as matrices](https://reader036.vdocuments.us/reader036/viewer/2022082411/56649dd45503460f94acb570/html5/thumbnails/4.jpg)
4
Types of Matrix
Identity matrices - I
Diagonal
1001
1000010000100001
Symmetric
• Diagonal matrices are (of course) symmetric
• Identity matrices are (of course) diagonal
4000010000200001
fecedbcba
![Page 5: 1 Matrix Math ©Anthony Steed 1999. 2 Overview n To revise Vectors Matrices n New stuff Homogenous co-ordinates 3D transformations as matrices](https://reader036.vdocuments.us/reader036/viewer/2022082411/56649dd45503460f94acb570/html5/thumbnails/5.jpg)
5
Operation on Matrices
Addition• Done elementwise
Transpose• “Flip” (M by N becomes N by M)
s d r cq b p a
s rq p
d cb a
379724651
376825941
T
Anthony Steed:
EQ needs fixing
Anthony Steed:
EQ needs fixing
![Page 6: 1 Matrix Math ©Anthony Steed 1999. 2 Overview n To revise Vectors Matrices n New stuff Homogenous co-ordinates 3D transformations as matrices](https://reader036.vdocuments.us/reader036/viewer/2022082411/56649dd45503460f94acb570/html5/thumbnails/6.jpg)
6
Operations on Matrices
Multiplication• Only possible to multiply of dimensions– x1 by y1 and x2 by y2 iff y1 = x2
• resulting matrix is x1 by y2
– e.g. Matrix A is 2 by 3 and Matrix by 3 by 4• resulting matrix is 2 by 4
– Just because A x B is possible doesn’t mean B x A is possible!
![Page 7: 1 Matrix Math ©Anthony Steed 1999. 2 Overview n To revise Vectors Matrices n New stuff Homogenous co-ordinates 3D transformations as matrices](https://reader036.vdocuments.us/reader036/viewer/2022082411/56649dd45503460f94acb570/html5/thumbnails/7.jpg)
7
Matrix Multiplication Order
A is n by k , B is k by m
C = A x B defined by
BxA not necessarily equal to AxB
k
l
ljilij bac1
*
*****
*****
*.
*.*.*.*.*.
*****
*...
*.*.*.*.*.
*****.....
![Page 8: 1 Matrix Math ©Anthony Steed 1999. 2 Overview n To revise Vectors Matrices n New stuff Homogenous co-ordinates 3D transformations as matrices](https://reader036.vdocuments.us/reader036/viewer/2022082411/56649dd45503460f94acb570/html5/thumbnails/8.jpg)
8
Example Multiplications
____
____
1011
12
101132
__________________
010001100
111013322
![Page 9: 1 Matrix Math ©Anthony Steed 1999. 2 Overview n To revise Vectors Matrices n New stuff Homogenous co-ordinates 3D transformations as matrices](https://reader036.vdocuments.us/reader036/viewer/2022082411/56649dd45503460f94acb570/html5/thumbnails/9.jpg)
9
Inverse
If A x B = I and B x A = I then
A = B-1 and B = A-1
![Page 10: 1 Matrix Math ©Anthony Steed 1999. 2 Overview n To revise Vectors Matrices n New stuff Homogenous co-ordinates 3D transformations as matrices](https://reader036.vdocuments.us/reader036/viewer/2022082411/56649dd45503460f94acb570/html5/thumbnails/10.jpg)
10
3D Transforms
In 3-space vectors are transformed by 3 by 3 matrices
Example?
ziyfxczfyexbzgydxaihgfedcba
zyx
Anthony Steed:
EQ needs fixing
Anthony Steed:
EQ needs fixing
![Page 11: 1 Matrix Math ©Anthony Steed 1999. 2 Overview n To revise Vectors Matrices n New stuff Homogenous co-ordinates 3D transformations as matrices](https://reader036.vdocuments.us/reader036/viewer/2022082411/56649dd45503460f94acb570/html5/thumbnails/11.jpg)
11
Scale
Scale uses a diagonal matrix
Scale by 2 along x and -2 along z
zcybxac
ba
zyx
000000
1046200
010002
543
![Page 12: 1 Matrix Math ©Anthony Steed 1999. 2 Overview n To revise Vectors Matrices n New stuff Homogenous co-ordinates 3D transformations as matrices](https://reader036.vdocuments.us/reader036/viewer/2022082411/56649dd45503460f94acb570/html5/thumbnails/12.jpg)
12
Rotation
Rotation about z axis
Note z values remain the same whilst x and y change
1000)θcos()θsin(-0)θsin()θcos(
Y
X
θ yx
yθ cosxθ sin yθ sin-xθ cos
![Page 13: 1 Matrix Math ©Anthony Steed 1999. 2 Overview n To revise Vectors Matrices n New stuff Homogenous co-ordinates 3D transformations as matrices](https://reader036.vdocuments.us/reader036/viewer/2022082411/56649dd45503460f94acb570/html5/thumbnails/13.jpg)
13
Rotation X, Y and Scale
About X
About Y
Scale (should look familiar)
)θcos()θsin(0)θsin(-)θcos(0
001
)θcos(0)θsin(010
)θsin(-0)θcos(
cb
a
000000
![Page 14: 1 Matrix Math ©Anthony Steed 1999. 2 Overview n To revise Vectors Matrices n New stuff Homogenous co-ordinates 3D transformations as matrices](https://reader036.vdocuments.us/reader036/viewer/2022082411/56649dd45503460f94acb570/html5/thumbnails/14.jpg)
14
Homogenous Points
Add 1D, but constrain that to be equal to 1 (x,y,z,1)
Homogeneity means that any point in 3-space can be represented by an infinite variety of homogenous 4D points• (2 3 4 1) = (4 6 8 2) = (3 4.5 6 1.5)
Why?• 4D allows as to include 3D translation in matrix
form
![Page 15: 1 Matrix Math ©Anthony Steed 1999. 2 Overview n To revise Vectors Matrices n New stuff Homogenous co-ordinates 3D transformations as matrices](https://reader036.vdocuments.us/reader036/viewer/2022082411/56649dd45503460f94acb570/html5/thumbnails/15.jpg)
15
Homogenous Vectors
Vectors != Points Remember points can not be added If A and B are points A-B is a vector Vectors have form (x y z 0) Addition makes sense
![Page 16: 1 Matrix Math ©Anthony Steed 1999. 2 Overview n To revise Vectors Matrices n New stuff Homogenous co-ordinates 3D transformations as matrices](https://reader036.vdocuments.us/reader036/viewer/2022082411/56649dd45503460f94acb570/html5/thumbnails/16.jpg)
16
Translation in Homogenous Form
Note that the homogenous component is preserved (* * * 1), and aside from the translation the matrix is I
1
1010000100001
1 czbyax
cba
zyx
![Page 17: 1 Matrix Math ©Anthony Steed 1999. 2 Overview n To revise Vectors Matrices n New stuff Homogenous co-ordinates 3D transformations as matrices](https://reader036.vdocuments.us/reader036/viewer/2022082411/56649dd45503460f94acb570/html5/thumbnails/17.jpg)
17
Putting it Together
R is rotation and scale components T is translation component
1000
321
987
654
321
TTTRRRRRRRRR
![Page 18: 1 Matrix Math ©Anthony Steed 1999. 2 Overview n To revise Vectors Matrices n New stuff Homogenous co-ordinates 3D transformations as matrices](https://reader036.vdocuments.us/reader036/viewer/2022082411/56649dd45503460f94acb570/html5/thumbnails/18.jpg)
18
1432
1432010000100001
1
1432010000100001
1000001001000001
1
YZXYZXZYX
1442
1000011001000001
1442
1000001001000001
1432010000100001
1
YZXZYXZYX
Order Matters
Composition order of transforms matters• Remember that basic vectors change so
“direction” of translations changed
![Page 19: 1 Matrix Math ©Anthony Steed 1999. 2 Overview n To revise Vectors Matrices n New stuff Homogenous co-ordinates 3D transformations as matrices](https://reader036.vdocuments.us/reader036/viewer/2022082411/56649dd45503460f94acb570/html5/thumbnails/19.jpg)
19
Exercises
Show that rotation by/2 about X and then /2 about Y is equivalent to /2 about Y then /2 about X
Calculate the following matrix /2 about X then /2 about Y then /2 about Z (remember “then” means multiply on the right). What is a simpler form of this matrix?
Compose the following matrix translate 2 along X, rotate /2 about Y, translate -2 along X. Draw a figure with a few points (you will only need 2D) and then its translation under this transformation.
![Page 20: 1 Matrix Math ©Anthony Steed 1999. 2 Overview n To revise Vectors Matrices n New stuff Homogenous co-ordinates 3D transformations as matrices](https://reader036.vdocuments.us/reader036/viewer/2022082411/56649dd45503460f94acb570/html5/thumbnails/20.jpg)
20
Summary
Rotation, Scale, Translation Composition of transforms The homogenous form