I was hoping someone can point out an efficient formula for 4x4 affine matrix transform. Currently my code uses cofactor expansion and it allocates a temporary array for ea
IIRC you can greatly shrink the code and time by precomputing a bunch (12?) 2x2 determinants. Split the matrix in half vertically and compute every 2x2 in both the upper and lower half. One of these smaller determinants is used in every term you'll need for the bigger computation and they each get reused.
Also, don't use a separate determinant function - reuse the sub-determinants you computed for the adjoint to get the determinant.
Oh, just found this.
There are some improvements you can make knowing its a certain kind of transform too.