Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Matrix4f Array naive

By: a guest on Jul 24th, 2011  |  syntax: Java 5  |  size: 2.06 KB  |  views: 86  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. public void mul4f(Matrix4fArray leftM, Matrix4fArray rightM) {
  2.         final float[] left = leftM.buffer;
  3.         final float[] right = rightM.buffer;
  4.  
  5.         float m00 = left[0] * right[0] + left[1] * right[4] + left[2] * right[8] + left[3] * right[12];
  6.         float m10 = left[0] * right[1] + left[1] * right[5] + left[2] * right[9] + left[3] * right[13];
  7.         float m20 = left[0] * right[2] + left[1] * right[6] + left[2] * right[10] + left[3] * right[14];
  8.         float m30 = left[0] * right[3] + left[1] * right[7] + left[2] * right[11] + left[3] * right[15];
  9.  
  10.         float m01 = left[4] * right[0] + left[5] * right[4] + left[6] * right[8] + left[7] * right[12];
  11.         float m11 = left[4] * right[1] + left[5] * right[5] + left[6] * right[9] + left[7] * right[13];
  12.         float m21 = left[4] * right[2] + left[5] * right[6] + left[6] * right[10] + left[7] * right[14];
  13.         float m31 = left[4] * right[3] + left[5] * right[7] + left[6] * right[11] + left[7] * right[15];
  14.  
  15.         float m02 = left[8] * right[0] + left[9] * right[4] + left[10] * right[8] + left[11] * right[12];
  16.         float m12 = left[8] * right[1] + left[9] * right[5] + left[10] * right[9] + left[11] * right[13];
  17.         float m22 = left[8] * right[2] + left[9] * right[6] + left[10] * right[10] + left[11] * right[14];
  18.         float m32 = left[8] * right[3] + left[9] * right[7] + left[10] * right[11] + left[11] * right[15];
  19.  
  20.         float m03 = left[12] * right[0] + left[13] * right[4] + left[14] * right[8] + left[15] * right[12];
  21.         float m13 = left[12] * right[1] + left[13] * right[5] + left[14] * right[9] + left[15] * right[13];
  22.         float m23 = left[12] * right[2] + left[13] * right[6] + left[14] * right[10] + left[15] * right[14];
  23.         float m33 = left[12] * right[3] + left[13] * right[7] + left[14] * right[11] + left[15] * right[15];
  24.  
  25.         final float[] buffer = this.buffer;
  26.  
  27.         buffer[0] = m00;
  28.         buffer[1] = m10;
  29.         buffer[2] = m20;
  30.         buffer[3] = m30;
  31.  
  32.         buffer[4] = m01;
  33.         buffer[5] = m11;
  34.         buffer[6] = m21;
  35.         buffer[7] = m31;
  36.  
  37.         buffer[8] = m02;
  38.         buffer[9] = m12;
  39.         buffer[10] = m22;
  40.         buffer[11] = m32;
  41.  
  42.         buffer[12] = m03;
  43.         buffer[13] = m13;
  44.         buffer[14] = m23;
  45.         buffer[15] = m33;
  46. }