ken-perlin asked me to get familiar with 4x4 matrix math, matrix multiplication & using matrices to transform vectors.


a matrix has rows & columns:

[2 3 4
 4 5 7]

therefore, 2x2 matrix (2r, 2c). this is the order of a matrix.


addition, subtraction can be done with matrices that have the same order. it’s pretty much like an array:

so a + b:


multiplication is a little more tricky.

say you have matrices:

we have a 1x3 matrix and a 3x1 matrix.

to be able to multiply, the columns in matrix 1 needs to be the same as rows in the second. the order is determined the by the last two numbers. for example:

 
a. b is 1x3 matrix multiplied by 3x1 matrix. 
 
can be multipled; order of resulting matrix ab will be 1x1. 
 

therefore, order matters.

multiplication is row x column.

you can essentially use these to transform vectors. i mean this is what p5 translate() does.

for example, rotation matrices can move a point in space. general formula:

reflection: move a point the same distance & same angle across a plane. this is simpler to do, just multiple by 1,0 for whatever needs to stay; and 0,-1 to flip.

used organic chemistry tutor videos, and this for rotation & reflection.