Home | Gaming | Programming | Play Online | Contact | Keyword Query
Games++ Games & Game Programming

Games++ Home
Games++ Gaming
Games++ Programming
Beta Testing Games
Free Online Games
Hints & Cheats

E-mail This Page
Add to Favorites


Web Games++

Cheat Codes
Trickster Wiki
Game Ratings
Gameboy Cheats
PlayStation Cheats
BlackBerry Games
Photoshop Tutorials
Illustrator Tutorials
ImageReady Tutorials



Matrix Multiplication Part 3: Matrix Transformation Tutorial

Table of Contents

  1. Introduction
  2. Math Prerequisites

  3. Importance of Correct Transformations
  4. What a Matrix Represents
  5. Matrix Multiplication
  6. Transforming a Vector by a Matrix
  7. Object Space Transformations
  8. Camera Transformations
  9. Inverse Transformations
  10. Hierarchical Transformations

  11. Precision
  12. Conclusion

Matrix Multiplication

There are two matrix operations which we will use in our matrix transformations, multiplying (concatenating) two matrices, and transforming a vector by a matrix. We will now examine the first of these two operations, matrix multiplication.

Matrix multiplication is the operation by which one matrix is transformed by another. A very important thing to remember is that matrix multiplication is not commutative. That is, [a] * [b] != [b] * [a]. For now, it will suffice to say that a matrix multiplication stores the results of the sum of the products of matrix rows and columns. Here is some example code of a matrix multiplication routine which multiplies matrix [a] * matrix [b], then copies the result to matrix a.

void matmult(float a[4][4], float b[4][4])
    float temp[4][4];       // temporary matrix for storing result
    int i, j;               // row and column counters

    for (j = 0; j < 4; j++)         // transform by columns first
        for (i = 0; i < 4; i++)     // then by rows
            temp[i][j] = a[i][0] * b[0][j] + a[i][1] * b[1][j] +
                         a[i][2] * b[2][j] + a[i][3] * b[3][j];

    for (i = 0; i < 4; i++)         // copy result matrix into matrix a
        for (j = 0; j < 4; j++)
            a[i][j] = temp[i][j];

I have been informed that there is a faster way of multiplying matrices, which involves taking the dot product of rows and columns. However, I have yet to implement such a method, so I will not discuss it here at this time.

Copyright © 1998-2007, Games++ All rights reserved. | Privacy Policy