CS 450: COMPUTER GRAPHICS TRANSFORMATIONS SPRING 2015 DR. MICHAEL J. REALE
INTRODUCTION TO MATRICES
ENTER THE MATRIX Matrix = (p X q) 2D array of numbers (scalars) p = number of rows, q = number of columns Used here to manipulate vectors and points used to transform vectors/points Given matrix M, another notation for a matrix is [m ij ] In computer graphics, most matrices will be 2x2, 3x3, or 4x4 In the slides that follow (for the most part): Capital letters matrices Lowercase letters scalar numbers c.br/wallpapers/codigo- matrix_2283_1280x1024.jpg
IDENTITY MATRIX Identity matrix = square matrix with 1’s on the diagonal and 0’s everywhere else Effectively the matrix equivalent of the number one multiplying by the identity matrix gives you the same matrix back M = I*M
MATRIX ADDITION To add two matrices, just add the corresponding components Same rules as with vectors Both matrices must have the same dimensions! Resulting matrix same dimensions as original matrices
RULES OF MATRIX ADDITION Note: 0 = matrix filled with zeros
MULTIPLY A MATRIX BY A SCALAR To multiple a matrix M by a scalar (single number) a, just multiply a by the individual components Again, same as with vectors Not surprisingly, resulting matrix same size as original
RULES OF SCALAR-MATRIX MULTIPLICATION
TRANSPOSE OF A MATRIX Transpose of matrix M = rows become columns and columns become rows Notation: M T If M is (p X q) M T is (q x p)
RULES OF THE TRANSPOSE MATRIX
TRACE OF A MATRIX Trace of matrix = just the sum of the diagonal elements of a square matrix Notation: tr(M)
MATRIX-MATRIX MULTIPLICATION When multiplying two matrix M and N like this T = MN Size of M must be (p X q) Size of N must be (q x r) Result T will be (p x r) ORDER MATTERS!!! 2 x 3 3 x2 x22
MATRIX-MATRIX MULTIPLICATION T = MN For each value in T t ij get the dot product of the row i of M and the column j of N
MATRIX-MATRIX MULTIPLICATION
EXAMPLE: MATRIX-MATRIX MULTIPLICATION
RULES OF MATRIX-MATRIX MULTIPLICATION We will use this for combining transformations I = identity matrix This is true in general, even if dimensions are the same!
MULTIPLYING A MATRIX BY A VECTOR We will be using column vectors here Column vector = (q x 1) matrix Multiplying a (q x 1) vector by a matrix (p x q) will give us a new vector (p x 1) For our transformations later, usually p = q so that w has the same size as v w i = dot product of v with row i of M