Java Array Normalize normalizeHeightMap(float heightMap[])

Here you can find the source of normalizeHeightMap(float heightMap[])

Description

normalize Height Map

License

Open Source License

Declaration

public static void normalizeHeightMap(float heightMap[]) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static void normalizeHeightMap(float heightMap[]) {
        int mapArea = heightMap.length;
        float minHeight = heightMap[0], maxHeight = heightMap[0];
        for (int i = 1; i < mapArea; i++) {
            if (heightMap[i] < minHeight)
                minHeight = heightMap[i];
            if (heightMap[i] > maxHeight)
                maxHeight = heightMap[i];
        }//from  www . j av a  2 s  . co  m

        float scaleFactor = maxHeight - minHeight;
        //if (min != 0.0f) minHeight -= min;
        //if (min != 0.0f || max != 1.0f) scaleFactor /= (max - min);

        for (int i = 0; i < mapArea; i++) {
            heightMap[i] = (heightMap[i] - minHeight) / scaleFactor;
        }
    }
}

Related

  1. normalizeForce(double[] data)
  2. normalizeFromLog10(double[] array)
  3. normalizeFromLog10(double[] array, boolean takeLog10OfOutput)
  4. normalizeFromLog10(final double[] array, final boolean takeLog10OfOutput, final boolean keepInLogSpace)
  5. normalizeFromRealSpace(final double[] array)
  6. normalizeHeightMapCopy(float heightMap[])
  7. normalizeHistogram(int[] h)
  8. normalizeHistogram(int[] hist)
  9. normalizeHistogramToBase(int[] hist, double base)