/* Matrix arithmetic functions. Tested with Borland C++ 2.0 in the small model */ /* Matrix multiplies Xform by SourceVec, and stores the result in DestVec. Multiplies a 4x4 matrix times a 4x1 matrix; the result is a 4x1 matrix, as follows: -- -- -- -- -- -- | | | 4 | | 4 | | 4x4 | X | x | = | x | | | | 1 | | 1 | -- -- -- -- -- -- */ void XformVec(double Xform[4][4], double * SourceVec, double * DestVec) { int i,j; for (i=0; i<4; i++) { DestVec[i] = 0; for (j=0; j<4; j++) DestVec[i] += Xform[i][j] * SourceVec[j]; } } /* Matrix multiplies SourceXform1 by SourceXform2 and stores the result in DestXform. Multiplies a 4x4 matrix times a 4x4 matrix; the result is a 4x4 matrix, as follows: -- -- -- -- -- -- | | | | | | | 4x4 | X | 4x4 | = | 4x4 | | | | | | | -- -- -- -- -- -- */ void ConcatXforms(double SourceXform1[4][4], double SourceXform2[4][4], double DestXform[4][4]) { int i,j,k; for (i=0; i<4; i++) { for (j=0; j<4; j++) { DestXform[i][j] = 0; for (k=0; k<4; k++) DestXform[i][j] += SourceXform1[i][k] * SourceXform2[k][j]; } } }