Game Development Reference
In-Depth Information
Figure 3-18. Matrix transpose
The following code statement transposes a 4-by-4 matrix m_NormalMatrixInvert and puts the result
in m_NormalMatrix . The offsets into the data of both matrices are 0.
//static void transposeM(float[] mTrans, int mTransOffset,
// float[] m, int mOffset)
Matrix.transposeM(m_NormalMatrix, 0, m_NormalMatrixInvert, 0);
Matrix Multiplication
Matrix multiplication of matrix A and matrix B is done by multiplying elements in the rows of A into
the corresponding elements in the columns of B and adding the products. Matrix multiplication is
essential in translating objects, rotating objects, scaling objects, and displaying 3D objects on a 2D
screen. For example, in Figure 3-19 , matrix A is being multiplied by matrix B, and the result is put
into matrix C.
C11 = (A11 * B11) + (A12 * B21) + (A13 * B31)
C12 = (A11 * B12) + (A12 * B22) + (A13 * B32)
C21 = (A21 * B11) + (A22 * B21) + (A23 * B31)
C22 = (A21 * B12) + (A22 * B22) + (A23 * B32)
 
Search WWH ::




Custom Search