```
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[j] = 0; k < 4; k++)
mat[j] += mat1[k] * mat2[k][j];
return mat;
}
vertex matrix_vertex_multiply(matrix mat, vertex vert) {
vertex v;
v.x = vert.x * mat.matrix[0][0] +
vert.y * mat.matrix[0][1] +
vert.z * mat.matrix[0][2] +
mat.matrix[0][3];
v.y = vert.x * mat.matrix[1][0] +
vert.y * mat.matrix[1][1] +
vert.z * mat.matrix[1][2] +
mat.matrix[1][3];
v.z = vert.x * mat.matrix[2][0] +
vert.y * mat.matrix[2][1] +
vert.z * mat.matrix[2][2] +
mat.matrix[2][3];
return v;
}
```

That should be enough to start you off.
(C)1997 Jeff Weeks and Code[sup]x[/sup] Software
0

Report Article

Sign in to follow this

Followers
0