Advertisement
Ember

float4x4 mul

Sep 13th, 2015
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.34 KB | None | 0 0
  1.     // Matrix multiplication --------------------------------------------------------------
  2.     static Float4x4 Multiply(const Float4x4& matrixA, const Float4x4 matrixB)
  3.     {
  4.         // Transpose B so everything becomes dot products
  5.         Float4x4 matrixBtranspose = Transpose(matrixB);
  6.  
  7.         Float4x4 result;
  8.         // Dot products infinity
  9.         result.x.x = Dot(matrixA.x, matrixBtranspose.x);
  10.         result.x.y = Dot(matrixA.x, matrixBtranspose.y);
  11.         result.x.z = Dot(matrixA.x, matrixBtranspose.z);
  12.         result.x.w = Dot(matrixA.x, matrixBtranspose.w);
  13.         // -- //
  14.         result.y.x = Dot(matrixA.y, matrixBtranspose.x);
  15.         result.y.y = Dot(matrixA.y, matrixBtranspose.y);
  16.         result.y.z = Dot(matrixA.y, matrixBtranspose.z);
  17.         result.y.w = Dot(matrixA.y, matrixBtranspose.w);
  18.         // -- //
  19.         result.z.x = Dot(matrixA.z, matrixBtranspose.x);
  20.         result.z.y = Dot(matrixA.z, matrixBtranspose.y);
  21.         result.z.z = Dot(matrixA.z, matrixBtranspose.z);
  22.         result.z.w = Dot(matrixA.z, matrixBtranspose.w);
  23.         // -- //
  24.         result.w.x = Dot(matrixA.w, matrixBtranspose.x);
  25.         result.w.y = Dot(matrixA.w, matrixBtranspose.y);
  26.         result.w.z = Dot(matrixA.w, matrixBtranspose.z);
  27.         result.w.w = Dot(matrixA.w, matrixBtranspose.w);
  28.  
  29.         return result;
  30.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement