Chapter 4: Introduction to Matrices

Slides:



Advertisements
Similar presentations
Chapter 12: Mechanics 2: Linear & Rotational Dynamics Ian Parberry University of North Texas Fletcher Dunn Valve Software 3D Math Primer for Graphics &
Advertisements

Chapter 11: Mechanics 1: Linear Kinematics & Calculus Ian Parberry University of North Texas Fletcher Dunn Valve Software 3D Math Primer for Graphics &
Chapter 13: Curves in 3D Ian Parberry University of North Texas Fletcher Dunn Valve Software 3D Math Primer for Graphics & Game Development.
CS 450: COMPUTER GRAPHICS LINEAR ALGEBRA REVIEW SPRING 2015 DR. MICHAEL J. REALE.
Chapter 7 Polar Coordinate Systems
Chapter 6 More on Matrices
Chapter 5 Matrices & Linear Transforms
2D Geometric Transformations
Chapter 4.1 Mathematical Concepts
Chapter 4.1 Mathematical Concepts. 2 Applied Trigonometry Trigonometric functions Defined using right triangle  x y h.
Now Playing: My Mathematical Mind Spoon From Gimme Fiction Released May 10, 2005.
Chapter 3 Determinants and Matrices
6 1 Linear Transformations. 6 2 Hopfield Network Questions.
Chapter 2: Vectors Ian Parberry University of North Texas Fletcher Dunn Valve Software 3D Math Primer for Graphics and Game Development.
Computer Graphics (Fall 2005) COMS 4160, Lecture 2: Review of Basic Math
CS 450: Computer Graphics 2D TRANSFORMATIONS
Matrices MSU CSE 260.
CE 311 K - Introduction to Computer Methods Daene C. McKinney
Week 4 - Monday.  What did we talk about last time?  Vectors.
Chapter 7 Matrix Mathematics Matrix Operations Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
ME451 Kinematics and Dynamics of Machine Systems Review of Matrix Algebra – 2.2 September 13, 2011 Dan Negrut University of Wisconsin-Madison © Dan Negrut,
Foundations of Computer Graphics (Fall 2012) CS 184, Lecture 2: Review of Basic Math
Compiled By Raj G. Tiwari
Graphics CSE 581 – Interactive Computer Graphics Mathematics for Computer Graphics CSE 581 – Roger Crawfis (slides developed from Korea University slides)
6.837 Linear Algebra Review Patrick Nichols Thursday, September 18, 2003.
1 February 24 Matrices 3.2 Matrices; Row reduction Standard form of a set of linear equations: Chapter 3 Linear Algebra Matrix of coefficients: Augmented.
ECON 1150 Matrix Operations Special Matrices
Matrix Algebra. Quick Review Quick Review Solutions.
Chapter 2 – Linear Transformations
Digital Image Processing, 3rd ed. © 1992–2008 R. C. Gonzalez & R. E. Woods Gonzalez & Woods Matrices and Vectors Objective.
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
Shivkumar Kalyanaraman Rensselaer Polytechnic Institute 1 : “shiv rpi” Linear Algebra A gentle introduction Linear Algebra has become as basic and as applicable.
Algebra 3: Section 5.5 Objectives of this Section Find the Sum and Difference of Two Matrices Find Scalar Multiples of a Matrix Find the Product of Two.
Matrices. Definitions  A matrix is an m x n array of scalars, arranged conceptually as m rows and n columns.  m is referred to as the row dimension.
Matrices, Transformations and the 3D Pipeline Matthew Rusch Paul Keet.
Matrices A matrix is a table or array of numbers arranged in rows and columns The order of a matrix is given by stating its dimensions. This is known as.
Chapter 6 Systems of Linear Equations and Matrices Sections 6.3 – 6.5.
Meeting 18 Matrix Operations. Matrix If A is an m x n matrix - that is, a matrix with m rows and n columns – then the scalar entry in the i th row and.
2 2.1 © 2012 Pearson Education, Inc. Matrix Algebra MATRIX OPERATIONS.
Introduction to Linear Algebra Mark Goldman Emily Mackevicius.
Copyright © Cengage Learning. All rights reserved. 2 SYSTEMS OF LINEAR EQUATIONS AND MATRICES.
Computer Graphics Matrices
CSCE 552 Fall 2012 Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
1 Objective To provide background material in support of topics in Digital Image Processing that are based on matrices and/or vectors. Review Matrices.
If A and B are both m × n matrices then the sum of A and B, denoted A + B, is a matrix obtained by adding corresponding elements of A and B. add these.
Matrices. Variety of engineering problems lead to the need to solve systems of linear equations matrixcolumn vectors.
Graphics Graphics Korea University kucg.korea.ac.kr Mathematics for Computer Graphics 고려대학교 컴퓨터 그래픽스 연구실.
Lecture 1 Linear algebra Vectors, matrices. Linear algebra Encyclopedia Britannica:“a branch of mathematics that is concerned with mathematical structures.
2.1 Matrix Operations 2. Matrix Algebra. j -th column i -th row Diagonal entries Diagonal matrix : a square matrix whose nondiagonal entries are zero.
MTH108 Business Math I Lecture 20.
CSE 167 [Win 17], Lecture 2: Review of Basic Math Ravi Ramamoorthi
Matrix Algebra MATRIX OPERATIONS © 2012 Pearson Education, Inc.
Week 4 - Monday CS361.
Linear Algebra Lecture 2.
Chapter 7 Matrix Mathematics
2D Transformations with Matrices
Review: Transformations
Finding the Inverse of a Matrix
Matrix Algebra MATRIX OPERATIONS © 2012 Pearson Education, Inc.
Matrices and Vectors Review Objective
Section 7.4 Matrix Algebra.
COMP 175: Computer Graphics February 9, 2016
Matrix Algebra.
2. Matrix Algebra 2.1 Matrix Operations.
Objective To provide background material in support of topics in Digital Image Processing that are based on matrices and/or vectors.
Matrix Algebra.
Linear Algebra A gentle introduction
Math review - scalars, vectors, and matrices
Matrix Algebra MATRIX OPERATIONS © 2012 Pearson Education, Inc.
Presentation transcript:

Chapter 4: Introduction to Matrices Fletcher Dunn Valve Software Ian Parberry University of North Texas 3D Math Primer for Graphics and Game Development

What You’ll See in This Chapter This chapter introduces matrices. It is divided into three sections. Section 4.1 discusses some of the basic properties and operations of matrices strictly from a mathematical perspective. Section 4.2 explains how to interpret these properties and operations geometrically. Section 4.3 puts the use of matrices in this book in context within the larger field of linear algebra, and is not covered in these notes. Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

3D Math Primer for Graphics & Game Dev Word Cloud Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

Section 4.1: Matrix: An Algebraic Definition Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

3D Math Primer for Graphics & Game Dev Definitions Algebraic definition of a matrix: a table of scalars in square brackets. Matrix dimension is the width and height of the table, w x h. Typically we use dimensions 2 x 2 for 2D work, and 3 x 3 for 3D work. We’ll find a use for 4 x 4 matrices also. It’s a kluge. More later. Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

3D Math Primer for Graphics & Game Dev Matrix Components Entries are numbered by row and column, eg. mij is the entry in row i, column j. Start numbering at 1, not 0. Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

3D Math Primer for Graphics & Game Dev Square Matrices Same number as rows as columns. Entries mii are called the diagonal entries. The others are called nondiagonal entries Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

3D Math Primer for Graphics & Game Dev Diagonal Matrices A diagonal matrix is a square matrix whose nondiagonal elements are zero. Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

3D Math Primer for Graphics & Game Dev The Identity Matrix The identity matrix of dimension n, denoted In, is the n x n matrix with 1s on the diagonal and 0s elsewhere. Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

3D Math Primer for Graphics & Game Dev Vectors as Matrices A row vector is a 1 x n matrix. A column vector is an n x 1 matrix. They were pretty much interchangeable in the lecture on Vectors. They’re not once you start treating them as matrices. Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

3D Math Primer for Graphics & Game Dev Transpose of a Matrix The transpose of an r x c matrix M is a c x r matrix called MT. Take every row and rewrite it as a column. Equivalently, flip about the diagonal Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

3D Math Primer for Graphics & Game Dev Facts About Transpose Transpose is its own inverse: (MT)T = M for all matrices M. DT = D for all diagonal matrices D (including the identity matrix I). Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

3D Math Primer for Graphics & Game Dev Transpose of a Vector If v is a row vector, vT is a column vector and vice-versa Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

Multiplying By a Scalar Can multiply a matrix by a scalar. Result is a matrix of the same dimension. To multiply a matrix by a scalar, multiply each component by the scalar. Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

Matrix Multiplication Multiplying an r x n matrix A by an n x c matrix B gives an r x c result AB. Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

Multiplication: Result Multiply an r x n matrix A by an n x c matrix B to give an r x c result C = AB. Then C = [cij], where cij is the dot product of the ith row of A with the jth column of B. That is: Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

3D Math Primer for Graphics & Game Dev Example Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

Another Way of Looking at It Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

3D Math Primer for Graphics & Game Dev 2 x 2 Case Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

3D Math Primer for Graphics & Game Dev 2 x 2 Example Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

3D Math Primer for Graphics & Game Dev 3 x 3 Case Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

3D Math Primer for Graphics & Game Dev 3 x 3 Example Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

3D Math Primer for Graphics & Game Dev Identity Matrix Recall that the identity matrix I (or In) is a diagonal matrix whose diagonal entries are all 1. Now that we’ve seen the definition of matrix multiplication, we can say that IM = MI = M for all matrices M (dimensions appropriate) Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

Matrix Multiplication Facts Not commutative: in general AB  BA. Associative: (AB)C = A(BC) Associates with scalar multiplication: k(AB) = (kA)B =A(kB) (AB)T = BTAT (M1M2M3…Mn)T = MnT …M3TM2TM1T Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

Row Vector Times Matrix Multiplication Can multiply a row vector times a matrix Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

Matrix Times Column Vector Multiplication Can multiply a matrix times a column vector. Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

3D Math Primer for Graphics & Game Dev Row vs. Column Vectors Row vs. column vector matters now. Here’s why: Let v be a row vector, M a matrix. vM is legal, Mv is undefined MvT is legal, vTM is undefined DirectX uses row vectors. OpenGL uses column vectors. Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

3D Math Primer for Graphics & Game Dev Common Mistake MvT  (vM)T, but MvT = (vMT)T – compare the following two results: Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

Vector-Matrix Multiplication Facts 1 Associates with vector multiplication. Let v be a row vector: v(AB) = (vA)B Let v be a column vector: (AB)v = A(Bv) Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

Vector-Matrix Multiplication Facts 2 Vector-matrix multiplication distributes over vector addition: (v + w)M = vM + wM That was for row vectors v, w. Similarly for column vectors. Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

Section 4.2: Matrix – a Geometric Interpretation Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

3D Math Primer for Graphics & Game Dev Matrices and Geometry A square matrix can perform any linear transformation. What’s that? Preserves straight lines Preserves parallel lines. No translation: the axes do not move. Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

Linear Transformations Rotation Scaling Orthographic projection Reflection Shearing More about these in the next chapter. Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

3D Math Primer for Graphics & Game Dev A Movie Quote “Unfortunately, no-one can be told what The Matrix is – you have to see it for yourself.” Actually, it’s all about basis vectors. Look back to Chapter 3 if you’ve forgotten about those. Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

3D Math Primer for Graphics & Game Dev Axial Displacements Can rewrite any vector v = [x y z] as a sum of axial displacements. V = [x y z] = [x 0 0] + [0 y 0] + [0 0 z] = x [1 0 0] + y [0 1 0] + z [0 0 1] Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

3D Math Primer for Graphics & Game Dev Basis Vectors Define three unit vectors along the axes: p = [1 0 0] q = [0 1 0] r = [0 0 1]. Then we can rewrite the axial displacement equation as v = xp +yq +zr p, q, r are known as basis vectors Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

Arbitrary Basis Vectors Can use any three linearly independent vectors p = [px py pz] q = [qx qy qz] r = [rx ry rz] Linearly independent means that there do not exist scalars a,b,c such that: ap + bq + cr = 0 Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

Orthonormal Basis Vectors Best to use an orthonormal basis Orthonormal means unit vectors that are pairwise orthogonal: p.q = q.r = r.p = 0 Otherwise things can get weird. Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

Matrix From Basis Vectors Construct a matrix M using p, q, r as the rows of the matrix: Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

What Does This Matrix Do? Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

Transformation by a Matrix If we interpret the rows of a matrix as the basis vectors of a coordinate space, then multiplication by the matrix performs a coordinate space transformation. If aM = b, we say that vector a is transformed by the matrix M into vector b. Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

3D Math Primer for Graphics & Game Dev Conversely See what M does to the original basis vectors [1 0 0], [0 1 0], [0 0 1]. Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

3D Math Primer for Graphics & Game Dev Visualize The Matrix Each row of a matrix is a basis vector after transformation. Given an arbitrary matrix, visualize the transformation by its effect on the standard basis vectors – the rows of the matrix. Given an arbitrary linear transformation, create the matrix by visualizing what it does to the standard basis vectors and using that for the rows of the matrix. Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

3D Math Primer for Graphics & Game Dev 2D Matrix Example What does the following 2D matrix do? Extract the basis vectors (the rows of M) p = [2 1] q = [-1,2] Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

3D Math Primer for Graphics & Game Dev Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

What’s the Transformation? It moves the unit axes [1, 0] and [0, 1] to the new axes. It does the same thing to all vectors. Visualize a box being transformed from one coordinate system to the other. This is called a skew box. Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

3D Math Primer for Graphics & Game Dev Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

3D Math Primer for Graphics & Game Dev Before After Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

3D Math Primer for Graphics & Game Dev So What Does It Do? Rotates objects counterclockwise by a small amount. Scales them up by a factor of two. Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

3D Transformation Example After Before Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

3D Math Primer for Graphics & Game Dev Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

3D Math Primer for Graphics & Game Dev What’s the Matrix? Get rows of matrix from new basis vectors. So what does it do? Rotates objects clockwise by 45°. Scales them up along the y axis. Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

Constructing & Deconstructing Matrices By interpreting the rows of a matrix as basis vectors, we have a tool for deconstructing a matrix. But we also have a tool for constructing one! Given a desired transformation (e.g. rotation, scale, etc.), we can derive a matrix which represents that transformation. All we have to do is figure out what the transformation does to basis vectors, and then place those transformed basis vectors into the rows of a matrix. We'll use this tool repeatedly in Chapter 5 to derive the matrices to perform the linear basic transformations such as rotation, scale, shear, and reflection that we mentioned earlier. Chapter 4 Notes 3D Math Primer for Graphics & Game Dev

3D Math Primer for Graphics & Game Dev That concludes Chapter 4. Next, Chapter 5: Matrices and Linear Transformations Chapter 4 Notes 3D Math Primer for Graphics & Game Dev