# Thread: Matrix multiplication code anyone?

1. ## Matrix multiplication code anyone?

I just happened to forgot it, could you post the code.
I store the matrix in an array:

GLfloat matrix[16];

2. ## Re: Matrix multiplication code anyone?

i guess from the 16 elements your using a 4 by 4 matrix, the code for that is avaliable along with a definition a bit like the one you put there from the Game tutorials at http://nehe.gamedev.net/

3. ## Re: Matrix multiplication code anyone?

The method his using I already know, I want the algoritm, you know, using loops to multiply.

Thanks anyway.

4. ## Re: Matrix multiplication code anyone?

perhaps it helps if you take a look here http://mathworld.wolfram.com/

5. ## Re: Matrix multiplication code anyone?

void MultiplyMatrix (GLfloat *n1, GLfloat *n2, GLfloat *result) {
register GLbyte l, c, a;
GLshort lc;

for (l=0; l<=3; l++) {
for (c=0; c<=3; c++) {
lc = l*c;
for (a=0; a<=3; a++)
result[(lc)+c] += n1[(lc)+a] * n2[c + (a*4)];
}
}
}

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•