Here you can find the source of normalizeHeightMap(float heightMap[])
public static void normalizeHeightMap(float heightMap[])
//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; } } }