
Title:
Matrix Math  Interactive 3D Graphics

Description:

At this point, you should have a pretty good sense of what the various

transforms do. Three.js supports these basic transforms without you needing to

understand what's going on inside the code. However, three.js can't provide

every possible type of transform out there. Though it tries. More importantly,

you'll need to know more about how transforms are coded if you want to program

the vertex and pixel shaders in the pipeline. Here's a screenshot of the

contents of the forearm object 3D from the robot arm demo. Using the debugger.

You have been using the debugger in your browser, right? If not, please go look

at the additional course materials right now and learn more about it. If you dig

inside any object 3D, you'll see a parameter called matrix. It is a Matrix4 with

a bunch of numbers in it. Ultimately this matrix parameter is what holds the

transform that changes the object's shape, orientation, and location. When you

set the position, rotation, and scale these all affect what gets stored in this

array. This matrix represents all these transforms put together in a tidy

package. We can multiply a coordinate, represented by a pointer vector, by this

matrix and get a new coordinate. That's honestly it in a nut shell. Any object

we make is ultimately represented by a bunch of points. These points are in the

object's own sort of space. For example if we make a cube using cube geometry

it's centered around the origin. We transform the cube's points by a transfer

matrix to move, rotate and scale it as desired. A transform matrix is a 4 by 4

set of numbers. Three.js also supports a Matrix3 type which almost no one uses.

In math in general a matrix can have any dimensions at all. Such as 12 by 38.

The 4 by 4 matrix is the size that the GPU prefers. We can multiply a coordinate

by a matrix. This is shown by putting the coordinate to the right of the matrix.

The new resulting coordinate is put to the left of the equals sign. The

mathematical notation is shown here. The coordinate times the matrix gives this

new coordinate. To multiply a coordinate by a matrix you take the coordinate and

perform a dot product with each row of the matrix. For example the dot product

of the first row and the coordinate is this, D1 equals N11 times C1 plus N21

times C2 and so on the sum of these four terms is the first coordinate of the

result. The dot product of the second row in a coordinate gives D2, the second

coordinate of the result. After four dot products, you have a new coordinate.