Mega Code Archive

 
Categories / Android / Game
 

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];       } }