math for programmers - gamedevs.org · algebraic vectors • any entity that meets certain rules...

64
Vectors & Matrices Marq Singer ([email protected])

Upload: vankhue

Post on 17-Aug-2019

222 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Vectors & Matrices

Marq Singer ([email protected])

Page 2: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

What Is a Vector?

• Geometric object with two properties– direction

– length (if length is 1, is unit vector)

• Graphically represented by

Page 3: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Algebraic Vectors

• Any entity that meets certain rules (lies in vector space) can be called ‘vector’

• Ex: Matrices, quaternions, fixed length polynomials

• Mostly mean geometric vectors, however

Page 4: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Vector Space

• Set of vectors related by +,∙• Meet rules

– v + w = w + v (commutative +)– (v + w) + u = v + (w + u) (associative +)– v + 0 = v (identity +)– v + (-v) = 0 (inverse +)– (αβ) v = α (βv) (associative ·)– (α+β)v = αv + βv (distributive ·)– α(v + w) = αv + αw (distributive ·)

Page 5: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Real Vector Spaces

• Usually only work in these

• Rn is an n‐dimensional system of real numbers– Represented as ordered list of real numbers 

(a1,…,an)• R3 is the 3D world, R2 is the 2D world

Page 6: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Linear Combination

• Combine set of n vectors using addition and scalar multiplication– v = α1v1 + α2v2 + … + αnvn

• Collection of all possible linear combinations for given v1… vn is called a span

• Linear combination of 2 perpendicular vectors span a plane

Page 7: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Linear Dependence

• A system of vectors v1, … ,vn is called linearly dependant if for at least one vi– vi = α1v1 +…+ αi-1vi-1 + αi+1vi+1 +…+ αnvn

• Otherwise, linearly independent• Two linearly dependant vectors are said to be collinear– I.e. w = α.v– I.e. they point the “same” direction

Page 8: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Linear Dependence

• Example

• Center vector can be constructed from outer vectors

Vector Prerequisites

Page 9: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Vector Basis

• Ordered set of n lin. ind. vectors – β = { v1, v2, …, vn}

• Span n‐dimensional space

• Represent any vector as linear combo– v = α1v1 + α2v2 + … + αnvn

• Or just components– v = (α1, α2, …, αn)

Page 10: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Vector Representation

• 3D vector v represented by (x, y, z)Use standard basis { i, j, k } Unit length, perpendicular (orthonormal)

– v = xi + yj + zk• Number of units in each axis direction

v1

v3

v2

Page 11: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Vector Operations

• Addition: +,‐

• Scale: ∙

• Length: ||v||• Normalize:  v̂

Page 12: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Addition

• Add a to b

b

a

a + b

( )332211 b,ab,aba +++=+ ba

Page 13: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Scalar Multiplication

• change length of vector v by α

)αααα 321 v,v,v ⋅⋅⋅=⋅ (v

Page 14: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Length

• Length– ||v|| gives length (or Euclidean norm) of v

– if ||v|| is 1, v is called unit vector

– usually compare length squared

• Normalize– v scaled by 1/||v|| gives unit vector 

23

22

21 vvv ++=v

Page 15: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Vector Operations

• Games tend to use most of the common vector operations– Addition, Subtraction

– Scalar multiplication

• Two others are extremely common:– Dot product

– Cross product

Page 16: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Dot product

• Also called inner product, scalar product

a

b

θ

332211 bababa ⋅+⋅+⋅=•baθ)(cosbaba ⋅⋅=•

Page 17: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Dot Product: Uses

• a • a equals ||a||2• can test for collinear vectors

– if a and b collinear & unit length, |a • b| ~ 1– Problems w/floating point, though 

• can test angle/visibility– a • b > 0 if angle < 90°– a • b = 0 if angle = 90° (orthogonal)– a • b < 0 if angle > 90°

Page 18: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Dot Product: Example

• Suppose have view vector v and vector t to object in scene (t = o - e)

• If v • t < 0, object behind us, don’t draw

v

to

e

Page 19: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Dot Product: Uses

• Projection of a onto b is

a

b

bbbbaab •

•=proj

abproj

Page 20: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Dot Product: Uses

• Example: break a into components collinear and perpendicular to b

a

b

abproj

aa bproj−

Page 21: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Cross Product

• Cross product: definition

– returns vector perpendicular to a and b– right hand rule

– length = area of parallelogram

a

bc

),,( 122131132332 babababababa −−−=×ba

Page 22: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Cross Product: Uses

• gives a vector perpendicular to the other two!

• ||a × b|| = ||a|| ||b|| sin(θ)• can test collinearity

– ||a × b|| = 0 if a and b are collinear– Better than dot – don’t have to be normalized

Page 23: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Other Operations

• Several other vector operations used in games may be new to you:– Scalar Triple Product

– Vector Triple Product

• These are often used directly or indirectly in game code, as we’ll see

Page 24: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Scalar Triple Product

• Dot product/cross product combo

• Volume of parallelpiped

• Test rotation direction– Check sign

)( wvu ו

w

vu

Page 25: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Triple Scalar Product: Example

• Current velocity v, desired direction don xy plane

• Take 

• If  > 0, turn left, if  < 0, turn right

v

dv × d

d

v

v × d

)( dvz ו

Page 26: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Vector Triple Product

• Two cross products

• Useful for building orthonormal basis– Compute and normalize:

)( wvu ××

u

)( uvu ××uv×

Page 27: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Points

• Points are positions in space — anchored to origin of coordinate system

• Vectors just direction and length — free‐floating in space

• Can’t do all vector operations on points

• But generally use one class in library

Page 28: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Point‐Vector Relations

• Two points related by a vector– (Q - P) = v– P + v = Q

vQ

P

Page 29: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Affine Space

• Vector, point related by origin– (P - O) = v– O + v = P

• Vector space, origin, relation between them make an affine space

v

P

O

e3

e2e1

Page 30: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Cartesian Frame

• Basis vectors {i, j, k}, origin (0,0,0)• 3D point P represented by (px, py, pz)• Number of units in each axis direction relative to origin

opx

pz

py

Page 31: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Affine Combination

• Like linear combination, but with points– P = a1P1 + a2P2 + … + anPn– a1,…,an barycentric coord., add to 1

• Same as point + linear combination– P = P1 + a2 (P2-P1) + … + an (Pn-P1)

• If vectors (P2-P1), …, (Pn-P1) are linearly independent, {P1, …, Pn} called a simplex (think of as affine basis)

Page 32: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Convex Combination

• Affine combination with a1,…,an between 0 and 1

• Spans smallest convex shape surrounding points – convex hull

• Example: triangle

Page 33: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Points, Vectors in Games

• Points used for models, position– vertices of a triangle

• Vectors used for velocity, acceleration– indicate difference between points, vectors

Page 34: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Parameterized Lines

• Can represent line with point and vector– P + tv

• Can also represent an interpolation from P to Q– P + t(Q-P)– Also written as (1-t)P + tQ

P vQ

Page 35: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Planes

• 2 non‐collinear vectors span a plane

• Cross product is normal n to plane

n

Page 36: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Planes

• Defined by – normal n = (A, B, C)– point on plane P0

• Plane equation– Ax+By+Cz+D = 0– D=-(A·P0x + B·P0y + C·P0z)

Page 37: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Planes

• Can use plane equation to test locality of point

• If n is normalized, gives distance to plane

n Ax+By+Cz+D > 0

Ax+By+Cz+D = 0

Ax+By+Cz+D < 0

Page 38: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Transformation

• Have some geometric data

• How to apply functions to it?

• Also desired: combine multiple steps into single operation 

• For vectors: linear transformations

Page 39: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Transformations

• A transformation T:V→W is a function that maps elements from vector space V to W

• The function 

f(x, y) = x2 + 2y

is a transformation because it maps R2 into R

Page 40: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Linear Transformation

• Two basic properties:– T(x + y) = T(x) + T(y)– T(ax) = aT(x)

• Follows that– T(0) = 0– T(ax+y) = aT(x) + T(y)

Page 41: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Linear Transformations

• Basis vectors span vector space

• Know where basis goes, know where rest goes

• So we can do the following:– Transform basis

– Store as columns in a matrix

– Use matrix to perform linear transforms

Page 42: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Linear Transforms

• Example:

• (1,0) maps to (1,2)

• (0,1) maps to (2,1)

• Matrix is

)2,2(),( yxyxyxT ++=

⎟⎟⎠

⎞⎜⎜⎝

⎛1221

Page 43: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

What is a Matrix?

• Rectangular m x n array of numbers

• M rows by n columns

• If n=m, matrix is square

⎟⎟⎟

⎜⎜⎜

− 2069129801.2

3.454.23.1

Page 44: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Matrix Concepts

• Number at row i and column j of matrix A is element Aij

• Elements in row i make row vector

• Elems in column j make column vector

• If at least one Aii (diagonal from upper left to lower right) are non‐zero and all others are zero, is diagonalmatrix

Page 45: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Transpose

• Represented by AT

• Swap rows and columns along diagonal 

• ATij = Aji

• Diagonal is invariant

⎟⎟⎟

⎜⎜⎜

⎛=

⎟⎟⎟

⎜⎜⎜

963852741

987654321 T

Page 46: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Transpose

• Transpose swaps transformed basis vectors from columns to rows 

• Useful identity

TTT ABAB =)(

Page 47: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Transforming Vectors

• Represent vector as matrix with one column 

• # of components = columns in matrix

• Take dot product of vector w/each row

• Store results in new vector

bAx =

Page 48: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Transforming Vectors

• Example: 2D vector

• Example: 3D vector to 2D vector

⎟⎟⎠

⎞⎜⎜⎝

⎛++

=⎟⎟⎠

⎞⎜⎜⎝

⎛⋅⎟⎟⎠

⎞⎜⎜⎝

222211

122111

2

1

2221

1211

babababa

aa

bbbb

⎟⎟⎠

⎞⎜⎜⎝

⎛++++

=⎟⎟⎟

⎜⎜⎜

⎛⋅⎟⎟⎠

⎞⎜⎜⎝

233222211

133122111

3

2

1

232221

131211

babababababa

aaa

bbbbbb

Page 49: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Row Vectors

• Can also use row vectors

• Transformed basis stored as rows

• Dot product with columns

• Pre‐multiply instead of post‐multiply

• If column default, represent row vector by vT

( ) ⎟⎟⎠

⎞⎜⎜⎝

⎛++

=⎟⎟⎠

⎞⎜⎜⎝

⎛⋅

222121

212111

2221

121121 baba

bababbbb

aa

Page 50: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Row vs. Column

• Using column vectors, others use row vectors– Keep your order straight!

• Transpose to convert from row to column (and vice versa)

321 MMMv ⋅⋅⋅T

vMMM 2 ⋅⋅⋅ 13

Row vector order (DirectX)

Column vector order (us, OpenGL)

Page 51: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Matrix Product

• Want to combine transforms

• What matrix represents         ?

• Idea:– Columns of matrix for S are xformed basis– Transform again by T

))(())(( xx STST =o

)( ST o

Page 52: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Matrix Product

• In general, element ABij is dot product of row ifrom A and column j from B

( ) ⎟⎟⎠

⎞⎜⎜⎝

⎛••••

=⋅⎟⎟⎠

⎞⎜⎜⎝

2212

211121

2

1

babababa

bbaa

T

T

⎟⎟⎠

⎞⎜⎜⎝

⎛⋅+⋅⋅+⋅⋅+⋅⋅+⋅

=⎟⎟⎠

⎞⎜⎜⎝

⎛⋅⎟⎟⎠

⎞⎜⎜⎝

2222122121221121

2212121121121111

2221

1211

2221

1211

babababababababa

bbbb

aaaa

or

Page 53: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Matrix product (cont’d)

• Number of rows in A must equal number of columns in B

• Generally not commutative

• Is associativeABBA ⋅≠⋅

( ) ( )CABBCA =

Page 54: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Block Matrices

• Can represent matrix with submatrices

• Product of block matrix contains sums of products of submatrices

⎟⎟⎠

⎞⎜⎜⎝

⎛DCBA

⎟⎟⎠

⎞⎜⎜⎝

⎛++++

=⎟⎟⎠

⎞⎜⎜⎝

⎛⋅⎟⎟⎠

⎞⎜⎜⎝

⎛DHCFDGCEBHAFBGAE

HGFE

DCBA

Page 55: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Identity

• Identity matrix I is square matrix with main diagonal of all 1s 

• Multiplying by I has no effect– A ⋅ I = A

⎟⎟⎟

⎜⎜⎜

100010001

Page 56: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Inverse

• A-1 is inverse of matrix A such that

• A-1 reverses what A does

• A is orthogonal if AT = A-1

–Component vectors are at right angles and unit length

– I.e. orthonormal basis

IAA 1 =⋅ −

Page 57: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Computing Inverse

• Only square matrices have inverse

• Inverse doesn’t always exist

• Zero row, column means no inverse

• Use Gaussian elimination or Cramer’s rule (see references)

Page 58: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Computing Inverses

• Most interactive apps avoid ever computing a general inverse

• Properties of the matrices used in most apps can simplify inverse

• If you know the underlying structure of the matrix, you can use the following:

Page 59: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Computing Inverse

• If orthogonal, A-1 =AT

• Inverse of diagonal matrix is diagonal matrix with A-1

ii = 1/Aii

• If know underlying structure can use

• We’ll use this to avoid explicit inverses

111)( −−− = ABAB

Page 60: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Storage Format

• Row major– Stored in order of rows

– Used by DirectX

⎟⎟⎟⎟⎟

⎜⎜⎜⎜⎜

1514131211109876543210

Page 61: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Storage Format (cont’d)

• Column Major Order– Stored in order of columns

– Used by OpenGL, and us 

⎟⎟⎟⎟⎟

⎜⎜⎜⎜⎜

1511731410621395112840

Page 62: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

Storage Format (cont’d)

• Note: storage format not the same as multiplying by row vector

• Same memory footprint:– Matrix for multiplying column vectors in column major format 

– Matrix for multiplying row vectors in row major format

• I.e. two transposes return same matrix

Page 63: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

System of Linear Equations

• Define system of m linear equations with nunknowns

b1 = a11x1 + a12 x2 + … + a1n xn

b2 = a21x1 + a22 x2 + … + a2n xn

bm = am1x1 + am2 x2+ … + amn xn

Page 64: Math for Programmers - gamedevs.org · Algebraic Vectors • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed

References

• Anton, Howard and Chris Rorres,  Elementary Linear Algebra, 7th Ed, Wiley & Sons, 1994.

• Axler, Sheldon, Linear Algebra Done Right, Springer Verlag, 1997.

• Blinn, Jim, Notation, Notation, Notation, Morgan Kaufmann, 2002.

• Van Verth, James M. and Lars M. Bishop, Essential Mathematics For Games & Interactive Applications, Morgan Kaufmann, San Francisco, 2004.