Created
June 1, 2015 18:51
-
-
Save naruse/e03d7242bcc97a4aa81d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "Matrix.h" | |
float const Matrix::identityMatrix[] = { | |
1,0,0,0, | |
0,1,0,0, | |
0,0,1,0, | |
0,0,0,1 | |
}; | |
Matrix Matrix::MultiplyMatrices(const Matrix* m1, const Matrix* m2) { | |
Matrix result; | |
result.m = Matrix::Identity(); | |
unsigned int row; | |
unsigned int column; | |
unsigned int rowOffset; | |
for(row = 0, rowOffset = row*4; row < 4; ++row, rowOffset = row*4) | |
for(column = 0; column < 4; ++column) | |
result.m[rowOffset + column] = (m1->m[rowOffset + 0] * m2->m[column + 0]) + | |
(m1->m[rowOffset + 1] * m2->m[column + 4]) + | |
(m1->m[rowOffset + 2] * m2->m[column + 8]) + | |
(m1->m[rowOffset + 3] * m2->m[column + 12]); | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment