public HeightMap(double gridSize, Vector2 min, Vector2 max) { if (min.X == max.X || min.Y == max.Y) { throw new Exception("Height map can't be infinitely narrow"); } int pointsX = (int)Math.Ceiling((max.X - min.X) / gridSize) + 1; int pointsY = (int)Math.Ceiling((max.Y - min.Y) / gridSize) + 1; if (pointsX < 2 || pointsY < 2) { throw new Exception("Height map must have at least 4 points"); } Points = new double?[pointsX, pointsY]; if (max.X < min.X) { double a = min.X; min.X = max.X; max.X = a; } if (max.Y < min.Y) { double a = min.Y; min.Y = max.Y; max.Y = a; } Min = min; Max = max; SizeX = pointsX; SizeY = pointsY; for (int x = 0; x < SizeX; x++) { for (int y = 0; y < SizeY; y++) { NotProbed.Add(new Tuple <int, int>(x, y)); } } }
private void CreateHeightMap(double gridSizeX, double gridSizeY, Vector2 min, Vector2 max) { if (min.X == max.X || min.Y == max.Y) { throw new Exception(LibStrings.FindResource("HeigthMapNarrow")); } int pointsX = (int)Math.Ceiling((max.X - min.X) / gridSizeX) + 1; int pointsY = (int)Math.Ceiling((max.Y - min.Y) / gridSizeY) + 1; if (pointsX < 2 || pointsY < 2) { throw new Exception(LibStrings.FindResource("HeigthMapMinSize")); } Points = new double?[pointsX, pointsY]; if (max.X < min.X) { double a = min.X; min.X = max.X; max.X = a; } if (max.Y < min.Y) { double a = min.Y; min.Y = max.Y; max.Y = a; } Min = min; Max = max; SizeX = pointsX; SizeY = pointsY; for (int x = 0; x < SizeX; x++) { for (int y = 0; y < SizeY; y++) { NotProbed.Add(new Tuple <int, int>(x, y)); } } }