



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This document from oregon state university's computer graphics course covers various concepts related to matrices, including their definition, transpose, square matrices, row and column matrices, matrix multiplication, determinants, and inverses. Visual representations and explanations of each concept.
Typology: Study notes
1 / 7
This page cannot be seen from the preview
Don't miss anything!




mjb – October 2, 2007 Oregon State UniversityComputer Graphics
Matrices
Mike Bailey
Oregon State University
mjb – October 2, 2007 Oregon State UniversityComputer Graphics
Matrices
A matrix is a 2D array of numbers, arranged in rows that go across and columns that go down:
4 columns
3 rows
Matrix sizes are termed “#rows x #columns”, so this is a 3x4 matrix
mjb – October 2, 2007 Oregon State UniversityComputer Graphics
Matrix Transpose
A matrix transpose is formed by interchanging the rows and columns:
This is a 3x4 matrix This is a 4x3 matrix
mjb – October 2, 2007 Oregon State UniversityComputer Graphics
Square Matrices
A square matrix has the same number of rows and columns
3 columns
3 rows
This is a 3x3 matrix
mjb – October 2, 2007 Oregon State UniversityComputer Graphics
Matrix Multiplication in Software
Here’s how to remember how to do it:
**1. C = A * B
⎡ ⎤ ⎡ ⎤ ⎡^ ⎤ ⎢ ⎥ ⎢ ⎥ ⎢^ ⎥ ⎢ ⎥ =⎢ ⎥ ⎢^ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢^ ⎥ ⎣ ⎦ ⎣ ⎦ ⎢^ ⎥ ⎣ ⎦
C A B
I x J (^) = I x K K x J
C[ i ][ j ] = A[ i ][ k ] * B[ k ][ j ] ;
mjb – October 2, 2007 Oregon State UniversityComputer Graphics
Matrix Multiplication in Software
for( int i = 0; i < numArows; i++ ) { for( int j = 0; j < numBcols; j++ ) { C[ i ][ j ] = 0.; for( int k = 0; k < numAcols; k++ ) { C[ i ][ j ] += A[ i ][ k ] * B[ k ][ j ]; } } }
Note: numAcols must == numBrows!
mjb – October 2, 2007 Oregon State UniversityComputer Graphics
Matrix Multiplication where B and C are Column Matrices
for( int i = 0; i < numArows; i++ ) { C[ i ] = 0.; for( int k = 0; k < numAcols; k++ ) { C[ i ] += A[ i ][ k ] * B[ k ]; } }
To help you remember this, think of the “C[ i ]“ lines as: C[ i ][ 0 ] = 0.; … C[ i ][ 0 ] += A[ i ][ k ] * B[ k ][ 0 ];
mjb – October 2, 2007 Oregon State UniversityComputer Graphics
A Special Matrix
Consider the matrix * column situation below:
x z y x
y z x y
z y x z
C = ( A By z − A Bz y , A Bz x − A Bx z , A Bx y − A By x )
This gives:
Which you hopefully recognize as the Cross Product AxB
mjb – October 2, 2007 Oregon State UniversityComputer Graphics
Inverses
The matrix inverse is also important in graphics applications because it represents the undoing of the original transformation matrix. It is also useful in solving systems of simultaneous equations. The inverse of a 2x2 matrix is the transpose of the cofactor matrix divided by the determinant:
1 A B (^) 1 D B
C D A D B C C A
− ⎡ ⎤ ⎡ − ⎤ ⎢ ⎥ = ⎢ ⎥ ⎣ ⎦ ∗^ −^ ∗ ⎣− ⎦
mjb – October 2, 2007 Oregon State UniversityComputer Graphics
Inverses
1
−
The determinant of a 3x3 matrix is done in terms of its component 2x2 sub-matrices::
The determinant of 4x4 and larger matrices can be done in a similar way, but usually isn’t. Gauss Elimination is more efficient.
det det det
det det det
det det det
det