Returns the transpose of a 4x4 matrix : Matrix « Game « Android






Returns the transpose of a 4x4 matrix

 
class Main{
      /**
       * Returns the transpose of a 4x4 matrix
       * @param m The matrix to transpose
       * @param result The place to store the transposed matrix
       **/
      public static void transpose(float[][] m, float[][] result) {
    for (int i=0;i<4;i++)
        for (int j=0;j<4;j++)
      result[j][i] = m[i][j];
      }

      public static void transpose(float[]m, float[] result) {
        for (int i=0;i<4;i++)
            for (int j=0;j<4;j++)
          result[j*4+i] = m[i*4+j];
      }


}

   
  








Related examples in the same category

1.How to implement a Matrix Palette
2.Matrix Operations
3.Rotate Matrix
4.Matrix Utils