Computer Graphics: Matrices, Transposes, Square Matrices, Multiplication, Determinants, In, Study notes of Computer Science

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

Pre 2010

Uploaded on 08/30/2009

koofers-user-2cd
koofers-user-2cd 🇺🇸

9 documents

1 / 7

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
mjb October 2, 2007
Oregon State University
Computer Graphics
Matrices
Mike Bailey
Oregon State University
mjb October 2, 2007
Oregon State University
Computer Graphics
Matrices
A matrix is a 2D array of numbers, arranged in rows that go
across and columns that go down:
1234
56 7 8
9101112
4 columns
3 rows
Matrix sizes are termed “#rows x #columns”, so this is a 3x4 matrix
pf3
pf4
pf5

Partial preview of the text

Download Computer Graphics: Matrices, Transposes, Square Matrices, Multiplication, Determinants, In and more Study notes Computer Science in PDF only on Docsity!

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:

T

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

  1. [ I x J ] = [ I x K ] * [ K x J ]**

⎡ ⎤ ⎡ ⎤ ⎡^ ⎤ ⎢ ⎥ ⎢ ⎥ ⎢^ ⎥ ⎢ ⎥ =⎢ ⎥ ⎢^ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢^ ⎥ ⎣ ⎦ ⎣ ⎦ ⎢^ ⎥ ⎣ ⎦

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 A B

C A A B

C A A B

⎧ ⎫ ⎡^ − ⎤⎧ ⎫

⎨ ⎬ =^ − ⎨ ⎬

C = ( A By zA Bz y , A Bz xA Bx z , A Bx yA 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

A B C

D E F

G H I

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

E F D F D E
H I G I G H
B C A C A B
H I G I G H
B C A C A B
E F D F D E
A B C
D E F
G H I
⎢ ⎣^ ⎦^ ⎣^ ⎦^ ⎣^ ⎦⎥
⎢ ⎡^ ⎤^ ⎡^ ⎤^ ⎡^ ⎤⎥
⎢ ⎢^ ⎥^ ⎢^ ⎥^ ⎢^ ⎥⎥
⎣ ⎣^ ⎦^ ⎣^ ⎦^ ⎣^ ⎦⎦