![Page 1: Mathematics for Computer Graphicsweb.cse.ohio-state.edu/.../math_background.pdf · Mathematics for Computer Graphics. Outline – Linear Algebra topics • Scalars • Vector Space](https://reader030.vdocuments.mx/reader030/viewer/2022041023/5ed5da46e5cfb841bf32320d/html5/thumbnails/1.jpg)
Mathematics for Computer Graphics
![Page 2: Mathematics for Computer Graphicsweb.cse.ohio-state.edu/.../math_background.pdf · Mathematics for Computer Graphics. Outline – Linear Algebra topics • Scalars • Vector Space](https://reader030.vdocuments.mx/reader030/viewer/2022041023/5ed5da46e5cfb841bf32320d/html5/thumbnails/2.jpg)
Outline – Linear Algebra topicsOutline Linear Algebra topics
• Scalars• Vector Space– Scalars and vectors
• Affine Space– Scalars, vectors, and points
• Euclidean Space• Euclidean Space– Scalars, vectors, points– Distance metric
• Projections• Matrix representations and operations
![Page 3: Mathematics for Computer Graphicsweb.cse.ohio-state.edu/.../math_background.pdf · Mathematics for Computer Graphics. Outline – Linear Algebra topics • Scalars • Vector Space](https://reader030.vdocuments.mx/reader030/viewer/2022041023/5ed5da46e5cfb841bf32320d/html5/thumbnails/3.jpg)
Scalars• Scalar – a number
Ex: the scale weight or magnitude of something– Ex: the scale, weight, or magnitude of something
• Two Fundamental Operationsdd d l l– Addition and multiplication
SSS , ,,
Commutative
Associative
Distributive
![Page 4: Mathematics for Computer Graphicsweb.cse.ohio-state.edu/.../math_background.pdf · Mathematics for Computer Graphics. Outline – Linear Algebra topics • Scalars • Vector Space](https://reader030.vdocuments.mx/reader030/viewer/2022041023/5ed5da46e5cfb841bf32320d/html5/thumbnails/4.jpg)
Scalars• Two Special Scalars
Additi id tit 0 lti li ti id tit 1– Additive identity: 0, multiplicative identity: 1
00 11
– Additive inverse 0
–Multiplicative inverse 1 11
![Page 5: Mathematics for Computer Graphicsweb.cse.ohio-state.edu/.../math_background.pdf · Mathematics for Computer Graphics. Outline – Linear Algebra topics • Scalars • Vector Space](https://reader030.vdocuments.mx/reader030/viewer/2022041023/5ed5da46e5cfb841bf32320d/html5/thumbnails/5.jpg)
2D scalar field2D scalar field
2D array of scalar values2D array of scalar values
In C# the data structureIn C#, the data structure might look something like this:
float [,] temps;[,] p ;temps = new float[50,50];// (allocate after declaring)// (allocate after declaring)
http://upload.wikimedia.org/wikipedia/commons/a/a8/Scalar_field.png
![Page 6: Mathematics for Computer Graphicsweb.cse.ohio-state.edu/.../math_background.pdf · Mathematics for Computer Graphics. Outline – Linear Algebra topics • Scalars • Vector Space](https://reader030.vdocuments.mx/reader030/viewer/2022041023/5ed5da46e5cfb841bf32320d/html5/thumbnails/6.jpg)
Vector spaceVector space
• Two Entities: Scalars and VectorsTwo Entities: Scalars and Vectors• Vectors
Di t d li t– Directed line segments– n‐tuples of scalars– Two operations• vector‐vector addition
l t lti li ti• scalar‐vector multiplication
• Zero Vector0
Directed line segments 00
vv
vv
![Page 7: Mathematics for Computer Graphicsweb.cse.ohio-state.edu/.../math_background.pdf · Mathematics for Computer Graphics. Outline – Linear Algebra topics • Scalars • Vector Space](https://reader030.vdocuments.mx/reader030/viewer/2022041023/5ed5da46e5cfb841bf32320d/html5/thumbnails/7.jpg)
Vector spaceVector space
• In vector space two vectors are equal if they areIn vector space, two vectors are equal if they are represented with the same n‐tuple
Ex: (1 2 3) = (1 2 3)– Ex: (1,2,3) = (1,2,3)(1,2,3) ≠ (3,2,1)
• A vector, by itself, does not have a starting position– Visually you can think of a vector starting at (0,0,0)
![Page 8: Mathematics for Computer Graphicsweb.cse.ohio-state.edu/.../math_background.pdf · Mathematics for Computer Graphics. Outline – Linear Algebra topics • Scalars • Vector Space](https://reader030.vdocuments.mx/reader030/viewer/2022041023/5ed5da46e5cfb841bf32320d/html5/thumbnails/8.jpg)
Vector space operationsVector space operations
• Vectors = n‐tuples vvvvVectors = n tuples– Vector‐vector addition
110 ,,, nvvvv
111100
110110
,,,,,,,,,
nn
nn
vuvuvuvvvuuuvu
– Scalar‐vector multiplication
– Vector decomposition 110 ,,, nvvvv
111100 nn uuuu
![Page 9: Mathematics for Computer Graphicsweb.cse.ohio-state.edu/.../math_background.pdf · Mathematics for Computer Graphics. Outline – Linear Algebra topics • Scalars • Vector Space](https://reader030.vdocuments.mx/reader030/viewer/2022041023/5ed5da46e5cfb841bf32320d/html5/thumbnails/9.jpg)
Vector space operations
• Scalar‐Vector Multiplicationu and v: vectors, α and β: scalars
vuvu
Scalar-vector multi.
uuu
• Vector Vector Addition• Vector‐Vector Addition– Visualize using head‐to‐tail axiom
Head-to-tail axiom
![Page 10: Mathematics for Computer Graphicsweb.cse.ohio-state.edu/.../math_background.pdf · Mathematics for Computer Graphics. Outline – Linear Algebra topics • Scalars • Vector Space](https://reader030.vdocuments.mx/reader030/viewer/2022041023/5ed5da46e5cfb841bf32320d/html5/thumbnails/10.jpg)
Vector space limitations
• Vector space has no geometric concept– Vectors indicate magnitude anddirection, not position
• Coordinate SystemId ti l t
y– Origin: a particular reference point
Identical vectors
Arbitraryplacementof basis
Basisvectorslocated
of basisvectors
at theorigin
![Page 11: Mathematics for Computer Graphicsweb.cse.ohio-state.edu/.../math_background.pdf · Mathematics for Computer Graphics. Outline – Linear Algebra topics • Scalars • Vector Space](https://reader030.vdocuments.mx/reader030/viewer/2022041023/5ed5da46e5cfb841bf32320d/html5/thumbnails/11.jpg)
Coordinate systemCoordinate system
d k l 2 3 diBoardwork examples: 1D, 2D, 3D coordinate axes
Unity uses left‐handed coordinate system with +x being right and +y being upg g y g p
![Page 12: Mathematics for Computer Graphicsweb.cse.ohio-state.edu/.../math_background.pdf · Mathematics for Computer Graphics. Outline – Linear Algebra topics • Scalars • Vector Space](https://reader030.vdocuments.mx/reader030/viewer/2022041023/5ed5da46e5cfb841bf32320d/html5/thumbnails/12.jpg)
Affine SpacesAffine Spaces• Scalars, vectors, and points• A point is represented as an n‐tuple
• Operations [P and Q are points, v is a vector]– Point‐point subtraction operation
• Vector point addition operation
QPv
• Vector‐point addition operation
QvP Head-to-tail axiom for points
RPRQQP
• Frame: a Point and a Set of Vectors– All vectors and points in the space are defined relative to these
0P 110 ,,, nvvv
V t
1111000
111100
nn
nn
vvvPPvvvv
Vector
Point
![Page 13: Mathematics for Computer Graphicsweb.cse.ohio-state.edu/.../math_background.pdf · Mathematics for Computer Graphics. Outline – Linear Algebra topics • Scalars • Vector Space](https://reader030.vdocuments.mx/reader030/viewer/2022041023/5ed5da46e5cfb841bf32320d/html5/thumbnails/13.jpg)
Euclidean SpacesEuclidean Spaces• Affine space does not include an operation or metric for distance between points
• Create a new operation: Inner (dot) Product• Create a new operation: Inner (dot) Product– Input: two vectors Output: scalar– α, β : scalars u, v, w : vectors
– Properties we want:
wvwuwvu
uvvu
0 if 0
000vvv
wvwuwvu
For orthogonal vectors0 00
0 vu
![Page 14: Mathematics for Computer Graphicsweb.cse.ohio-state.edu/.../math_background.pdf · Mathematics for Computer Graphics. Outline – Linear Algebra topics • Scalars • Vector Space](https://reader030.vdocuments.mx/reader030/viewer/2022041023/5ed5da46e5cfb841bf32320d/html5/thumbnails/14.jpg)
Euclidean Spaces – dot productEuclidean Spaces dot product• If we can multiply two n‐tuples, this implies
– Magnitude (length) of a vector vvv
– Distance between two points QPQPQP
– Measure of the angle between two vectors• cosθ = 0 orthogonal
cosvuvu
• cosθ = 1 parallel
• Computation of dot productp p
111100
1
0...
nn
n
iii vuvuvuvuvu
![Page 15: Mathematics for Computer Graphicsweb.cse.ohio-state.edu/.../math_background.pdf · Mathematics for Computer Graphics. Outline – Linear Algebra topics • Scalars • Vector Space](https://reader030.vdocuments.mx/reader030/viewer/2022041023/5ed5da46e5cfb841bf32320d/html5/thumbnails/15.jpg)
Projections• We can determine if two points are “close” to each other, what about vectors?,
• How much of w is in the same direction as v?• Given vectors v and w, decompose w into two parts,Given vectors v and w, decompose w into two parts, one parallel to v and one orthogonal to v
uvw
vvvuvvvw
Projection of onevector onto anothervv
vw
vvvvwwvwu
![Page 16: Mathematics for Computer Graphicsweb.cse.ohio-state.edu/.../math_background.pdf · Mathematics for Computer Graphics. Outline – Linear Algebra topics • Scalars • Vector Space](https://reader030.vdocuments.mx/reader030/viewer/2022041023/5ed5da46e5cfb841bf32320d/html5/thumbnails/16.jpg)
MatricesMatrices
• DefinitionsDefinitions• Matrix Operations
d C l i• Row and Column Matrices• Change of Representation• Relating matrices and vectors
![Page 17: Mathematics for Computer Graphicsweb.cse.ohio-state.edu/.../math_background.pdf · Mathematics for Computer Graphics. Outline – Linear Algebra topics • Scalars • Vector Space](https://reader030.vdocuments.mx/reader030/viewer/2022041023/5ed5da46e5cfb841bf32320d/html5/thumbnails/17.jpg)
What is a Matrix?What is a Matrix?• A matrix is a set of elements, organized into rows and columns
b
rows
dcba
columns
dc
![Page 18: Mathematics for Computer Graphicsweb.cse.ohio-state.edu/.../math_background.pdf · Mathematics for Computer Graphics. Outline – Linear Algebra topics • Scalars • Vector Space](https://reader030.vdocuments.mx/reader030/viewer/2022041023/5ed5da46e5cfb841bf32320d/html5/thumbnails/18.jpg)
DefinitionsDefinitions• n x m Array of Scalars (n Rows and m Columns)– n: row dimension of a matrix, m: column dimension– m = n square matrix of dimension n– Element 1010 mjniaElement
T i h i h d l f i
1,,0 ,1,,0 , mjnia ij ijaA
– Transpose: interchanging the rows and columns of a matrix
jiT aA
b• Column Matrices and Row Matrices– Column matrix (n x 1 matrix):Row matrix (1 x matrix)
1
0
i
bb
b
b– Row matrix (1 x n matrix):
1nb
110 ... nT bbbb
![Page 19: Mathematics for Computer Graphicsweb.cse.ohio-state.edu/.../math_background.pdf · Mathematics for Computer Graphics. Outline – Linear Algebra topics • Scalars • Vector Space](https://reader030.vdocuments.mx/reader030/viewer/2022041023/5ed5da46e5cfb841bf32320d/html5/thumbnails/19.jpg)
Matrix OperationsMatrix Operations
• Scalar‐Matrix Multiplication a AScalar Matrix Multiplication–Multiply every element by the scalar
• Matrix Matrix Addition
ijaA
ba BAC• Matrix‐Matrix Addition– Add elements with same index
ijij ba BAC
• Matrix‐Matrix Multiplication– A: n x l matrix, B: l x m C: n x m matrix
1l
ijcABC cij = the sum of multiplying elements in row i of matrix a
1
0
l
kkjikij bac times elements in column j of
matrix b
![Page 20: Mathematics for Computer Graphicsweb.cse.ohio-state.edu/.../math_background.pdf · Mathematics for Computer Graphics. Outline – Linear Algebra topics • Scalars • Vector Space](https://reader030.vdocuments.mx/reader030/viewer/2022041023/5ed5da46e5cfb841bf32320d/html5/thumbnails/20.jpg)
Matrix Operation ExamplesMatrix Operation Examples
fbeafeba
hdgcf
hgf
dc
hdfbea
hfe
dba
hdgchgdc
dhcfdgcebhafbgae
hgfe
dcba
dhcfdgcehgdc
![Page 21: Mathematics for Computer Graphicsweb.cse.ohio-state.edu/.../math_background.pdf · Mathematics for Computer Graphics. Outline – Linear Algebra topics • Scalars • Vector Space](https://reader030.vdocuments.mx/reader030/viewer/2022041023/5ed5da46e5cfb841bf32320d/html5/thumbnails/21.jpg)
Matrix OperationsMatrix Operations
• Properties of Scalar‐Matrix Multiplication AA
p p
• Properties of Matrix‐Matrix Addition
AA
ABBA– Commutative:– Associative:
• Properties of Matrix‐Matrix Multiplication
ABBA CBACBA
p p
BAAB
CABBCA
• Identity Matrix I (Square Matrix)
BAAB
if1 ji AAI 0001
otherwise 0if 1
,ji
aa ijijIBIBAAI
1000010000100001
![Page 22: Mathematics for Computer Graphicsweb.cse.ohio-state.edu/.../math_background.pdf · Mathematics for Computer Graphics. Outline – Linear Algebra topics • Scalars • Vector Space](https://reader030.vdocuments.mx/reader030/viewer/2022041023/5ed5da46e5cfb841bf32320d/html5/thumbnails/22.jpg)
Matrix Multiplication OrderMatrix Multiplication Order
• Is AB = BA? Maybe but maybe not!Is AB = BA? Maybe, but maybe not!
...bgaefeba
...fceabafe
......hgdc
......dchg
• In general, matrix multiplication is NOT commutative!
• The order of matrix multiplications is important!important!
![Page 23: Mathematics for Computer Graphicsweb.cse.ohio-state.edu/.../math_background.pdf · Mathematics for Computer Graphics. Outline – Linear Algebra topics • Scalars • Vector Space](https://reader030.vdocuments.mx/reader030/viewer/2022041023/5ed5da46e5cfb841bf32320d/html5/thumbnails/23.jpg)
Row and Column Matrices + pointsRow and Column Matrices + points
• Column Matrix
x By convention
we will useColumn Matrix
zyp we will use
column matrices for points
– Row matrix
C t ti zyxT p
• Concatenations– Associative ABCpp
App
• By Row Matrix TTT ABAB TTTTT ABCpp
![Page 24: Mathematics for Computer Graphicsweb.cse.ohio-state.edu/.../math_background.pdf · Mathematics for Computer Graphics. Outline – Linear Algebra topics • Scalars • Vector Space](https://reader030.vdocuments.mx/reader030/viewer/2022041023/5ed5da46e5cfb841bf32320d/html5/thumbnails/24.jpg)
Vector OperationsVector Operations
• Vector: 1 x N matrix
Vector: 1 x N matrix• Interpretation: a line in N dimensional
ba
in N dimensional spaceD P d d
cbv
• Dot Product and Magnitude
i
cyoperations y
v
x
![Page 25: Mathematics for Computer Graphicsweb.cse.ohio-state.edu/.../math_background.pdf · Mathematics for Computer Graphics. Outline – Linear Algebra topics • Scalars • Vector Space](https://reader030.vdocuments.mx/reader030/viewer/2022041023/5ed5da46e5cfb841bf32320d/html5/thumbnails/25.jpg)
Vectors: Dot ProductVectors: Dot Product
d Thi k f th d t cfbead
fed
cbaabba T
Think of the dot product as a matrix multiplication
bbT 2The magnitude is the dot
d t f t ithccbbaaaaa T product of a vector with itself
)cos(baba
If a and b are both length one, the angle between them is the cos-1 of their dot product
![Page 26: Mathematics for Computer Graphicsweb.cse.ohio-state.edu/.../math_background.pdf · Mathematics for Computer Graphics. Outline – Linear Algebra topics • Scalars • Vector Space](https://reader030.vdocuments.mx/reader030/viewer/2022041023/5ed5da46e5cfb841bf32320d/html5/thumbnails/26.jpg)
Inverse of a MatrixInverse of a Matrix
• Identity matrix: 001Identity matrix: AI = A
• Some matrices have an
010001
I• Some matrices have an inverse, such that:AA‐1 = I
100
AA 1 = I
101 101
110101
A
110101
1A 100
100
![Page 27: Mathematics for Computer Graphicsweb.cse.ohio-state.edu/.../math_background.pdf · Mathematics for Computer Graphics. Outline – Linear Algebra topics • Scalars • Vector Space](https://reader030.vdocuments.mx/reader030/viewer/2022041023/5ed5da46e5cfb841bf32320d/html5/thumbnails/27.jpg)
Inverse of a MatrixInverse of a Matrix
• Some matrices do not have an inverseSome matrices do not have an inverse
000
cba
100010A
ihfedA 1
100 ihg
AA‐100 = 0 * a + 0 * d + 0 * g = 0 ≠ 1
![Page 28: Mathematics for Computer Graphicsweb.cse.ohio-state.edu/.../math_background.pdf · Mathematics for Computer Graphics. Outline – Linear Algebra topics • Scalars • Vector Space](https://reader030.vdocuments.mx/reader030/viewer/2022041023/5ed5da46e5cfb841bf32320d/html5/thumbnails/28.jpg)
Inverse of Matrix ConcatenationInverse of Matrix Concatenation
• Inversion of concatenationsInversion of concatenations(ABC)‐1 = C‐1B‐1A‐1
A * B * C * X = IA * B * C * C 1 A * BA * B * C * C‐1 = A * B
A * B * B‐1 = AA * A‐1 = I
Order is important so X = C‐1B‐1A‐1Order is important, so X C B A
![Page 29: Mathematics for Computer Graphicsweb.cse.ohio-state.edu/.../math_background.pdf · Mathematics for Computer Graphics. Outline – Linear Algebra topics • Scalars • Vector Space](https://reader030.vdocuments.mx/reader030/viewer/2022041023/5ed5da46e5cfb841bf32320d/html5/thumbnails/29.jpg)
SummarySummary
• Primitives: scalars, vectors, points
• Operations: addition and multiplication
• Matrix representation and operationsMatrix representation and operations