View Full Version : Multiplicating matrices

Fernando

12-17-2001, 05:36 PM

hi everyone!!!

I'm getting some problems with matrix multiplication!!

The problem is:

I have two matrices of 4x4, and I want to make a multiplication on them...

How I do that? Is there any function I can use?

Fernando

12-17-2001, 06:06 PM

Ok!!!

I found a way to do this!

For them, who wants this function too, here it go:

Matrix Matrix_Multiply(Matrix mat1, Matrix mat2) {

int i, j, k;

Matrix mat;

// For speed reasons, use the unroll-loops option of your compiler

for(i = 0; i < 4; i++)

for(j = 0; j < 4; j++)

for(k = 0, mat[i][j] = 0; k < 4; k++)

mat[i][j] += mat1[i][k] * mat2[k][j];

return mat;

}

I got this code at page <a href="http://www.gamedev.net/reference/articles/article877.asp

">http://www.gamedev.net/reference/articles/article877.asp</a>

and it's wrote by Jeff Weeks and Codex Software

Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.