title: How to combine all linear transformations into a composite transformation matrix?
body: <p>The matMul function performs a matrix multiplication storing it in Matrix C. For the computeTransformationMatrix function,  the goal is to combine the rotation matrices, scaling matrix, translation matrix, and projection matrix into a single transformation matrix M. All transformation matrices are 4x4 except the projection matrix which is a 2X4 matrix. Constants are properly defined elsewhere, although not shown below. Is the only way to combine the transformations to apply the matMul function once(shown at the very bottom) per transformation matrix until finally creating the composite transformation matrix M?</p>
  
  <pre><code>void matMul(Matrix A, Matrix B, int ARows, int ACols, int BCols, Matrix C){
     int i,j,k, sum;
          for(i=0;i&lt;ARows;i++){
          sum = 0;
          for(j=0;j&lt;ACols;j++){
              for(k=0;k&lt;BCols;k++){
              sum += A[i][k]*B[k][j];
          }
          C[i][j] = sum;
          }
      }    
  }    
  
  
  void computeTransformationMatrix(Matrix M, float scale, float xt, float yt, float zt) {
  // to return final transformation in M
      Matrix P;   // projection matrix
      Matrix S;   // scaling matrix
      Matrix T;   // translation matrix
      Matrix R_X, R_Y, R_Z; //rotation matrices
  
      // initialize transformation matrices
      rotationMatrixX(ROTATION_ANGLE_X, R_X);
      rotationMatrixY(ROTATION_ANGLE_Y, R_Y);
      rotationMatrixZ(ROTATION_ANGLE_Z, R_Z);
      projectionMatrix(P);
      scalingMatrix(scale, scale, -scale, S);  
      translationMatrix(xt, yt, zt, T);
  
      Matrix TM1, TM2, TM3, TM4;//store transformed matrices
          matMul(R_X, R_Y, 4, 4, 4, TM1);
          matMul(R_Z, TM1, 4, 4, 4, TM2);
          matMul(T,TM2, 4, 4, 4, TM3);
          matMul(S, TM3, 4, 4, 4, TM4);
          matMul(P, TM4, 2, 4, 4, M);
      }
  </code></pre>