public TemperatureMap(TerrainMap tm, int month) { this.xSize = tm.xSize; this.ySize = tm.ySize; this.grid = new float[xSize, ySize]; this.terrainmap = tm; float st, lt, lat; for (int y = 0; y < ySize; y++) { lat = Latitude.getLatitude(y, ySize); st = getSeaTemperature(lat, month); lt = getLandTemperature(lat, month); for (int x = 0; x < xSize; x++) { if (tm.grid [x, y].terrainType == TerrainType.sea) { this.grid [x, y] = st; } else { this.grid [x, y] = lt; } } } smoothMean(5, 5); smoothMean(1, 10); IFunction altitudeTemperature = new LineFunction(-80, 40); IFunction depthTemperature = new LineFunction(10, -5); for (int x = 0; x < xSize; x++) { for (int y = 0; y < ySize; y++) { if (tm.grid [x, y].terrainType != TerrainType.sea) { this.grid [x, y] += altitudeTemperature.calculate(tm.grid [x, y].height); } else { this.grid [x, y] += depthTemperature.calculate(tm.grid [x, y].height); } } } }
private Map <Vector2> blendLayers() { Map <Vector2> m = new Map <Vector2>(xSize, ySize); IFunction redistr = new LineFunction(0, 3, 60, 1.5f); Vector2 v; float mag; for (int x = 0; x < xSize; x++) { for (int y = 0; y < ySize; y++) { v = LayersWeightedAverage(x, y); mag = v.magnitude; v.Normalize(); v *= mag + redistr.calculate(mag); m.setAt(x, y, v); } } return(m); }