View Full Version : Matrix multiplication code anyone?
Questions Burner
02-17-2002, 07:01 AM
I just happened to forgot it, could you post the code.
I store the matrix in an array:
GLfloat matrix[16];
Mr_Smith
02-17-2002, 07:47 AM
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 http://www.opengl.org/discussion_boards/ubb/smile.gif from the Game tutorials at http://nehe.gamedev.net/
Questions Burner
02-17-2002, 10:02 PM
The method his using I already know, I want the algoritm, you know, using loops to multiply.
Thanks anyway.
satan
02-18-2002, 02:46 AM
perhaps it helps if you take a look here http://mathworld.wolfram.com/
Fernando
02-18-2002, 06:26 PM
Maybe it'll help you!
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)];
}
}
}
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.