Here you can find the source of normalizeHeightMapCopy(float heightMap[])
public static float[] normalizeHeightMapCopy(float heightMap[])
//package com.java2s; //License from project: Open Source License public class Main { public static float[] normalizeHeightMapCopy(float heightMap[]) { float tmpHM[] = new float[heightMap.length]; System.arraycopy(heightMap, 0, tmpHM, 0, heightMap.length); normalizeHeightMap(tmpHM);/*www .ja v a 2 s . c om*/ return tmpHM; } 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]; } 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; } } }