// Return all times from start to stop. Also return the indexes of the times at which the earth elevation reaches a minima void GetLowEarthTimes(DateTime outer_start, DateTime outer_stop, out List <DateTime> all_times, out List <int> indices_of_minima_earth_elevation) { var center = new Point(Region.Left + Region.Width / 2, Region.Top + Region.Height / 2); var centerPatch = ViperEnvironment.GetPatch(TerrainPatch.LineSampleToId(center)); centerPatch.FillMatrices(ViperEnvironment.Terrain); // Generate the time / elevation pairs all_times = new List <DateTime>(); for (var time = outer_start; time <= outer_stop; time += Step) { all_times.Add(time); } var earth_elevations = all_times.Select(t => { centerPatch.GetAzEl(CSpice.EarthPosition(t), 0, 0, out float _, out float earth_elevation_rad); return(earth_elevation_rad); }).ToList(); // Find minima indices_of_minima_earth_elevation = new List <int>(); for (var i = 1; i < earth_elevations.Count - 1; i++) { if (Start <= all_times[i] && all_times[i] <= Stop && earth_elevations[i - 1] > earth_elevations[i] && earth_elevations[i] < earth_elevations[i + 1]) { indices_of_minima_earth_elevation.Add(i); } } }
void LoadTiles() { var s = TerrainPatch.DefaultSize; IdBounds = new Rectangle(Bounds.Left / s, Bounds.Top / s, Bounds.Width / s, Bounds.Height / s); _patches = new List <TerrainPatch>(); for (var y = IdBounds.Top; y < IdBounds.Bottom; y++) { for (var x = IdBounds.Left; x < IdBounds.Right; x++) { var p = ViperEnvironment.GetPatch(new Point(x, y)); if (p != null) { _patches.Add(p); } } } Console.WriteLine($"{_patches.Count} patches were loaded"); foreach (var p in _patches) { Console.WriteLine(p.Id); } }