4x4 matrix multiplication
Arrays as Arguments

When you write this:

void MultiplyTwoMatrixes(float aMatrix[9], float bMatrix[9], float product[9])


That is exactly equivalent to:

void MultiplyTwoMatrixes(float*, float*, float*);


That is, there's no size checking on any of the inputs whatsoever - I could call your function with three arrays of size 3, 1, and 72. Would compile fine. Which is a problem!

Encapsulation and Operators

We want type safety. That suggests a Matrix class. For simplicity, let's just make it 2d:

template &lt;typename T, int Rows, int Cols&gt;
struct Matrix;


And then we can write a multiply operator:

template &lt;typename T, int R1, int C1, int C2&gt;
Matrix&lt;T, R1, C2&gt; operator*(const Matrix&lt;T, R1, C1&gt;&amp; lhs, const Matrix&lt;T, C1, C2&gt;&amp; rhs);


Notice that this already handles dimensional analysis for you. You just have to write the internals, which isn't complicated. And then you would be able to write your rotation function naturally:

Matrix&lt;float, 3, 3&gt; xyzResult = xRot * yRot * zRot;


Type-safe and more readable!

newMatrix

I don't understand the construction of newMatrix. So I can't really offer a better solution? You're not setting lots of indices of newMatrix, for one thing...