DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Multiply Two Matrices
// Multiply two matrices
/*!
* Multiplies a matrix by a second one (m = m * n).
*/
void lib3ds_matrix_mult(Lib3dsMatrix m, Lib3dsMatrix n) {
Lib3dsMatrix tmp;
int i, j, k;
float ab;
memcpy(tmp, m, sizeof(Lib3dsMatrix));
for (j = 0; j < 4; j++) {
for (i = 0; i < 4; i++) {
ab = 0.0f;
for (k = 0; k < 4; k++)
ab += tmp[k][i] * n[j][k];
m[j][i] = ab;
}
}
}





