006 Métodos
006.6 Gráficos

3.3 Matriz

3.3.1 Why Matrices?

Matrices are a compact way of representing and combining transformations (e.g., rotations and translation). Matrices are so common that most computer hardware (e.g., graphical processing units (GPUs) and CPUs) are optimized to perform very efficient matrix operations (i.e., with special instructions and by means of parallelization).

3.3.2 Column or Row Major

A matrix can be ordered using either Column or Row ordering (i.e., depending upon your preference). While DirectX uses Row Major ordering to store the matrix in memory, OpenGL uses Column Major ordering. For this book, you primarily use Column Major ordering.

/*
* Column-major 4x4 matrix
*
* Layout:
*  0  4  8  12
*  1  5  9  13
*  2  6  10 14
*  3  7  11  15
*
* 3x3 Rotation Matrix Indices
*  0  4  8
*  1  5  9
*  2  6  10
*
* 3x1 Translation Indices
*  12
*  13
*  14
*
*/

3.3.3 A 4x4 Matrix

A 4x4 matrix (aka a homogeneous transformation matrix) can contain multiple different transformations (e.g.

3.3.4 Creating a Matrix

3.3.4.1 Identity Matrix

3.3.4.2 Translation Matrix

3.3.4.3 Scale Matrix

3.3.4.4 Rotation Matrix

3.3.5 Matrix-Matrix Multiplication

3.3.6 Pure Rotation

3.3.6.1 Orthogonal Matrices (Useful-Axis)

3.3.6.2 Transpose and Inverse

3.3.7 Transforming a Vector

3.3.7.1 Little Test

3.3.8 Matrix Inversion