CS123 INTRODUCTION TO COMPUTER GRAPHICS. Linear Algebra /34

Similar documents
CS123 INTRODUCTION TO COMPUTER GRAPHICS. Linear Algebra 1/33

Linear Algebra V = T = ( 4 3 ).

Math Linear Algebra Final Exam Review Sheet

Elementary maths for GMT

Chapter 1: Systems of linear equations and matrices. Section 1.1: Introduction to systems of linear equations

Linear Algebra Homework and Study Guide

Matrix & Linear Algebra

Linear Algebra March 16, 2019

Topics. Vectors (column matrices): Vector addition and scalar multiplication The matrix of a linear function y Ax The elements of a matrix A : A ij

Finite Mathematics Chapter 2. where a, b, c, d, h, and k are real numbers and neither a and b nor c and d are both zero.

Final Review Sheet. B = (1, 1 + 3x, 1 + x 2 ) then 2 + 3x + 6x 2

Introduction to Matrix Algebra

Review: Linear and Vector Algebra

We could express the left side as a sum of vectors and obtain the Vector Form of a Linear System: a 12 a x n. a m2

Review of Linear Algebra

MATH.2720 Introduction to Programming with MATLAB Vector and Matrix Algebra

Linear Algebra. Ben Woodruff. Compiled July 17, 2010

GAUSSIAN ELIMINATION AND LU DECOMPOSITION (SUPPLEMENT FOR MA511)

Chapter 2. Matrix Arithmetic. Chapter 2

Linear Algebra. 1.1 Introduction to vectors 1.2 Lengths and dot products. January 28th, 2013 Math 301. Monday, January 28, 13

Linear Algebra: Lecture Notes. Dr Rachel Quinlan School of Mathematics, Statistics and Applied Mathematics NUI Galway

4 Elementary matrices, continued

Matrices and Matrix Algebra.

Chapter 2 Notes, Linear Algebra 5e Lay

4 Elementary matrices, continued

1300 Linear Algebra and Vector Geometry

Chapter 1. Vectors, Matrices, and Linear Spaces

Chapter 2: Matrices and Linear Systems

Appendix C Vector and matrix algebra

Matrices Gaussian elimination Determinants. Graphics 2009/2010, period 1. Lecture 4: matrices

ELEMENTARY LINEAR ALGEBRA

The geometry of least squares

System of Linear Equations

Linear Algebra I Lecture 8

MAC1105-College Algebra. Chapter 5-Systems of Equations & Matrices

Span and Linear Independence

Vector Geometry. Chapter 5

A matrix over a field F is a rectangular array of elements from F. The symbol

MATH Topics in Applied Mathematics Lecture 12: Evaluation of determinants. Cross product.

Math 4A Notes. Written by Victoria Kala Last updated June 11, 2017

Mathematics for Graphics and Vision

DM559 Linear and Integer Programming. Lecture 2 Systems of Linear Equations. Marco Chiarandini

is a 3 4 matrix. It has 3 rows and 4 columns. The first row is the horizontal row [ ]

Math 1314 Week #14 Notes

Math 54 HW 4 solutions

Matrices and systems of linear equations

Elementary Linear Algebra

Math Camp II. Basic Linear Algebra. Yiqing Xu. Aug 26, 2014 MIT

Linear equations in linear algebra

Systems of Linear Equations. By: Tri Atmojo Kusmayadi and Mardiyana Mathematics Education Sebelas Maret University

Review of Coordinate Systems

7.5 Operations with Matrices. Copyright Cengage Learning. All rights reserved.

a 11 x 1 + a 12 x a 1n x n = b 1 a 21 x 1 + a 22 x a 2n x n = b 2.

4.1 Distance and Length

Lecture 2 Systems of Linear Equations and Matrices, Continued

LECTURES 4/5: SYSTEMS OF LINEAR EQUATIONS

Linear Equations and Vectors

MATH 212 Linear Algebra I

3. Replace any row by the sum of that row and a constant multiple of any other row.

Review Packet 1 B 11 B 12 B 13 B = B 21 B 22 B 23 B 31 B 32 B 33 B 41 B 42 B 43

MAC Learning Objectives. Learning Objectives (Cont.) Module 10 System of Equations and Inequalities II

Introduction to Matrices

22A-2 SUMMER 2014 LECTURE 5

Introduction. Vectors and Matrices. Vectors [1] Vectors [2]

Math Bootcamp An p-dimensional vector is p numbers put together. Written as. x 1 x =. x p

Chapter 5: Matrices. Daniel Chan. Semester UNSW. Daniel Chan (UNSW) Chapter 5: Matrices Semester / 33

9.1 - Systems of Linear Equations: Two Variables

Matrix Arithmetic. j=1

Systems of Linear Equations and Matrices

Math 3C Lecture 20. John Douglas Moore

Systems of Linear Equations and Matrices

Inverting Matrices. 1 Properties of Transpose. 2 Matrix Algebra. P. Danziger 3.2, 3.3

1 - Systems of Linear Equations

MATH 20F: LINEAR ALGEBRA LECTURE B00 (T. KEMP)

Linear Algebra Highlights

Lecture Notes in Linear Algebra

Lecture 12: Solving Systems of Linear Equations by Gaussian Elimination

March 19 - Solving Linear Systems

Chapter 1: Linear Equations

7.6 The Inverse of a Square Matrix

Solving Systems of Linear Equations

Dot Products, Transposes, and Orthogonal Projections

Finite Math - J-term Section Systems of Linear Equations in Two Variables Example 1. Solve the system

MATH2210 Notebook 2 Spring 2018

MATRIX ALGEBRA AND SYSTEMS OF EQUATIONS. + + x 1 x 2. x n 8 (4) 3 4 2

CS 246 Review of Linear Algebra 01/17/19

Chapter 1: Linear Equations

Recall, we solved the system below in a previous section. Here, we learn another method. x + 4y = 14 5x + 3y = 2

Matrices. 1 a a2 1 b b 2 1 c c π

Linear Algebra. The analysis of many models in the social sciences reduces to the study of systems of equations.

is Use at most six elementary row operations. (Partial

Matrix-Vector Products and the Matrix Equation Ax = b

LINEAR SYSTEMS, MATRICES, AND VECTORS

If A is a 4 6 matrix and B is a 6 3 matrix then the dimension of AB is A. 4 6 B. 6 6 C. 4 3 D. 3 4 E. Undefined

DS-GA 1002 Lecture notes 0 Fall Linear Algebra. These notes provide a review of basic concepts in linear algebra.

Review of linear algebra

(arrows denote positive direction)

Appendix A: Matrices

Elementary Linear Algebra

1 Last time: inverses

Transcription:

Linear Algebra /34

Vectors A vector is a magnitude and a direction Magnitude = v Direction Also known as norm, length Represented by unit vectors (vectors with a length of 1 that point along distinct axes) Often denoted by a hat above the letter (x ) A vector is not a position A position is a distinct point A vector travels from one point to another 2/34

Vector addition Vector addition in ℛ1 Familiar addition of real numbers Vector addition in ℛ2 Component-wise addition Result, v1 + v2, plotted in ℛ2 is the new vector 3/34

Adding vectors visually v2 added to v1, using the parallelogram rule reposition v2 so that its tail is at the head of vector v1 define v1 + v2 as the head of the new vector Or equivalently, add v1 to v2 4/34

Vector subtraction Same as adding but one of the vectors is flipped Ex. Find (8, 9) - (2, 4) Flip (2, 4) so that the tail is at the head of (8, 9) Effectively (8, 9) + (-2, -4) = (6, 5) 5/34

Vector scalar multiplication Geometrically, think of scalar multiplication as scaling the vector Magnitude is multiplied Direction is not affected (unless zeroed or negated) Scaled vectors are always parallel Scaled components yield same slope 6/34

Linear dependence Set of all scalar multiples of a vector is a line through the origin Two vectors are linearly dependent when one is a multiple of the other On the same line Definition of dependence for three or more vectors is trickier Geometric intuition: In ℛ3 when on the same plane In ℛn when on the same n-dimensional hyperplane 7/34

Linear dependence Rotated to see the three vectors on same plane 8/34

Standard basis vectors The unit vectors (i.e. whose length is 1) on the x and y-axes are called the standard basis vectors The collection of scalar multiples of gives the first coordinate axis The collection of scalar multiples of gives the second coordinate axis 9/34

Basis vectors Any vector can be expressed as the sum of scalar multiples of the unit vectors: We call these two vectors basis vectors for ℛ2 because any other vector can be expressed in terms of them Very important concept Can you guess what the standard basis vectors for ℛ3 are? 10/34

Non-orthogonal basis vectors and are perpendicular. Is this necessary? Can we make any vector from scalar multiples of random vectors Is there a solution for all n, m to the following, where and? and are unknown? 11/34

Non-orthogonal basis vectors Is there a solution to the following, where and are unknown: Just a linear system of two equations. When is this unsolvable? How does it make sense geometrically? 12/34

Dot product Operation on two vectors Result is a scalar! Defined for vectors of any size Also known as scalar product or inner product Both vectors must have the same size Dot products instructions are used in SIMD registers 13/34

Calculating magnitude using dot product Let s find the magnitude of vector v from origin to house Use Pythagorean theorem (2D only) Use dot product (All dimensions!) 14/34

Find the angle between two vectors Let s find the angle between v and x-axis Angle between two vectors is θ, where Proof is omitted here but try it at home! For our problem it would be solving for θ in: 15/34

Determining right angles Angle between two vectors is θ, where If θ is a right angle(i.e. θ=90, π/2), cos(θ) = 0 So if a and b are perpendicular, 16/34

Projections Let s find projection of v onto x-axis 17/34

Projections Projections in general In mathematical terms, the projection of vector a onto vector b Length times unit vector in direction of b And the length of the projection Recall Use Cases? We ll use projections when we create a synthetic camera in our Camtrans lab for the Sceneview project 18/34

z Cross product Two vectors define a plane Output is a vector! x Operation on two 3D vectors y Follows right-hand rule Result is a vector perpendicular to plane defined by input vectors Its magnitude is equal to the area of the parallelogram formed by the two vectors In terms of vector components, the cross product is calculated Note: vectors can be any arbitrary non-collinear pair, don t have to be in xy plane Use Cases? Finding normals for our lighting model 19/34

Matrix A matrix is a rectangular array of numbers or other mathematical objects Can operate on with addition (matrix-matrix) and multiplication (scalar, vector, and matrix) Notation: Size: m x n rows x cols For the purposes of this class, matrices are used to represent transformations, which act on points, vectors, and other matrices 20/34

Product of row vector and column vector We haven t stressed this so far but there is distinction between vector written as row vs. vector written as column Product of a row vector and column vector denoted Use column vectors usually Vectors must be the same size Result is actually dot product of these two vectors 21/34

Matrix and vector multiplication Matrix-vector multiplication produces a new vector. kth element of v is the product kth row of M with v v = Mv Both v and v column vectors Same as the dot product of kth row of M with v If M is an m x n matrix, v must be length n Use Cases? Transform vertices into world space / camera space / screen space Transforming normal vectors (more later) Moving and animating graphical models Otherwise dot product not defined (m x n) (n x 1) m x 1 22/34

Matrix and matrix multiplication MNij = the dot product of the ith row of M and the jth column of N = Otherwise, dot product of ith row and jth column would not make sense MN is an m x k matrix Order of multiplication matters! N Product of ith row vector of M and jth column vector of N Subscript denotes row, then column If M is an m x n matrix, then N must be an n x k matrix. M In general MN NM NM may not even be defined! = 23/34

Matrix multiplication identity Scalar operations like addition and multiplication have identities What is the identity for matrix multiplication? The identity matrix I is a matrix with all zeros, except for on the diagonal, where it is all ones a+0=a a*1=a 0 for addition, 1 for multiplication Identity matrix exists for different dimensions Multiplication of an object (matrix or vector) by identity produces original object 24/34

Properties of Matrix Multiplication Properties similar to scalar multiplication Associative property Distributive property A(u + v) = Au + Av [vectors] Use transformation of component parts to transform complicated vector Identity (AB)C = A(BC) Important for combining transformations -- we can combine and group adjacent AI = A = IA Inverse (more later) For some A, there is a matrix A-1 such that AA-1 = I = A-1A 25/34

Visual Matrix Multiplication Since matrix multiplication is distributive over vectors, we can tell where each vector will be sent by knowing where each standard basis vector is sent Originally, we have a unit grid Then we apply transformation and set up a grid based on images of two standard basis vectors 26/34

Visual Matrix Multiplication Now to see where ends, instead of going 2 steps along x-axis, and 3 along y-axis, go 2 steps along image of and 3 along image of 27/34

Inverse of a Matrix A and B are inverses if AB = BA = I Some matrices don t have an inverse matrix Matrices for rotation, translation, and scaling have inverses What does an Inverse do? The inverse A-¹ of transformation A will undo the result of transforming by A If A scales uniformly by a factor of 2 and then rotates 135 degrees, then A-¹ will rotate by 135 degrees and then scales uniformly by ½ Note that A is a composite matrix! 28/34

Composite Inverses Why does it matter if you scale or rotate first? Results would be the same in this example but that may not always be the case Recall slide 32 from the Transformations lecture Inverses must apply the inverse transformations in the reverse order else you can get an incorrect result 29/34

How to get the inverse glm::inverse() Use Gauss-Jordan elimination To find A-1 with Gauss-Jordan elimination Augment A with I to get [A I] Reduce the new matrix into reduced row echelon form (rref) The matrix is now in the form [I A-1] To reduce a matrix into rref we are allowed to perform any of the three elementary row operations. These are: Multiply a row by a nonzero constant Interchange two rows Add a multiple of one row to another row 30/34

Example 31/34

Example 32/34

33/34

Additional Insight into the Gauss-Jordan Elimination When do we need to use this method? Why does this method work? A lot of matrices inverses can be deduced without applying this process For example, to invert normalizing transformation, the computer will apply inversion method Algebraic intuition: row operations are equivalent of operations on system of equations System of equations invariant under these operations Another explanation Row operations are actually matrix multiplications Check this link out if interested: http://aleph0.clarku.edu/~djoyce/ma130/elementary.pdf 34/34

Questions? 35/34