Java Matrix Flatten flatten4(float[][] in, int size, float[] out)

Here you can find the source of flatten4(float[][] in, int size, float[] out)

Description

Flatten a 2D array with 4 items in the second dimension into a 1D array.

License

LGPL

Parameter

Parameter Description
in The array to be flattened
size The number of items to copy from the in array
out The output array to write the values to

Declaration

public static void flatten4(float[][] in, int size, float[] out) 

Method Source Code

//package com.java2s;
/*****************************************************************************
 *                        Web3d.org Copyright (c) 2001 - 2006
 *                               Java Source
 *
 * This source is licensed under the GNU LGPL v2.1
 * Please read http://www.gnu.org/copyleft/lgpl.html for more information
 *
 * This software comes with the standard NO WARRANTY disclaimer for any
 * purpose. Use it at your own risk. If there's a problem you get to fix it.
 *
 ****************************************************************************/

public class Main {
    /**/*from w ww . j  av a  2s  . com*/
     * Flatten a 2D array with 4 items in the second dimension into a 1D array.
     *
     * @param in The array to be flattened
     * @param size The number of items to copy from the in array
     * @param out The output array to write the values to
     */
    public static void flatten4(float[][] in, int size, float[] out) {
        int count = size * 4 - 1;

        for (int i = size; --i >= 0;) {
            out[count--] = in[i][3];
            out[count--] = in[i][2];
            out[count--] = in[i][1];
            out[count--] = in[i][0];
        }
    }
}

Related

  1. flatten(int[][] arr)
  2. Flatten(int[][] in, int[] out)
  3. flatten(String[][] table)
  4. flatten2DArray(byte[][] array)
  5. flatten2DArray(double[][] array)
  6. flattenIndicesCollection(int[][] multipleIndices, int[] extents)
  7. flattenN(float[][] in, int size, int width, float[] out)