private float[,] ExpandBiasGridToMap(TWorld world, float[,] biasGrid, int biasGridSize) { var map = new float[world.Width, world.Height]; var biasToWorldX = ((biasGridSize - 1) / (double)world.Width); var biasToWorldY = ((biasGridSize - 1) / (double)world.Height); for (int x = 0; x < world.Width; x++) { for (int y = 0; y < world.Height; y++) { var biasX = (int)(x * biasToWorldX); var biasY = (int)(y * biasToWorldY); var ul = MapUtil.ValueAtOrDefault(biasGrid, biasX, biasY, 0); var ur = MapUtil.ValueAtOrDefault(biasGrid, biasX + 1, biasY, 0); var ll = MapUtil.ValueAtOrDefault(biasGrid, biasX, biasY + 1, 0); var lr = MapUtil.ValueAtOrDefault(biasGrid, biasX + 1, biasY + 1, 0); map[x, y] = (float)MapUtil.BilinerInterpolate(ul, ur, ll, lr, (x - (biasX / biasToWorldX)) * biasToWorldX, (y - (biasY / biasToWorldY)) * biasToWorldY); } } return(map); }