public void SatelliteMove() { var satellite = new Satellite(176400, 7200, 120,0,0); satellite.Move(1); Assert.AreEqual(176520, satellite.CurrentRot.Lat); }
public Satellite(Satellite s) : this(s.Pos.Lat, s.Pos.Lon, s.Speed, s.RotSpeed, s.MaxRot, s.Id) { CurrentRot = new Coords(s.CurrentRot); CurrentTurn = s.CurrentTurn; Range = new Range(s.Range); }
public static bool CanTakePicture(this Satellite s, Coords c, TimeRange t, out int pictureTurn, int maxTurn) { pictureTurn = 0; if (s.CurrentTurn > t.End) return false; s = new Satellite(s); //clone if(s.CurrentTurn < t.Start) { s.Move(t.Start - s.CurrentTurn); } for (int turn = Math.Max(t.Start, s.CurrentTurn); turn < Math.Min(t.End, maxTurn); turn++) { if(c.IsInRange(s.Range, s.Pos)) { pictureTurn = turn; return true; } s.Move(1); } return false; }
public void SatelliteMoveIsCorrect(int nbTurn, int expectedLat, int expectedLon) { var satellite = new Satellite(176400, 7200, 120, 0, 0, 0); satellite.Move(nbTurn); Assert.AreEqual(expectedLat, satellite.Pos.Lat); Assert.AreEqual(expectedLon, satellite.Pos.Lon); }
public static int GetNumberPictInRangeFixTrajectory(Satellite satellite, KdTree<float, PicCollection> tree, int maxIter) { if (maxIter < 0) { return 0; } var copySatellite = satellite.Clone(); copySatellite.NextTurn(); return tree.RadialSearch(new float[] { copySatellite.Pos.Lat, copySatellite.Pos.Lon }, copySatellite.MaxRot, 150) .Where(no => no.Value.PictureCanBeTaken(copySatellite.CurrentTurn)) .Where(k => copySatellite.CanTakePicture((int)k.Point[0], (int)k.Point[1])).Count() + GetNumberPictInRangeFixTrajectory(copySatellite, tree, --maxIter); }
public static int GetNumberPictInRangeInNextTurns(Satellite satellite, KdTreeNode<float, PicCollection> n, KdTree<float, PicCollection> tree) { var possiblePict = new Coords((int)n.Point[0], (int)n.Point[1]); var copySatellite = satellite.Clone(); copySatellite.TakePicture(possiblePict); copySatellite.NextTurn(); var inRange = tree.RadialSearch(new float[] { copySatellite.Pos.Lat, copySatellite.Pos.Lon }, copySatellite.MaxRot, 150) .Where(no => no.Value.PictureCanBeTaken(copySatellite.CurrentTurn)) .Where(k => copySatellite.CanTakePicture((int)k.Point[0], (int)k.Point[1])).Count() + GetNumberPictInRangeFixTrajectory(copySatellite, tree, 500); //Console.WriteLine("Number in range for {0} {1}: {2}", possiblePict.Lat, possiblePict.Lon, inRange); return inRange; }
public void SatelliteMo(int nbTurn) { var satellite = new Satellite(176400, 7200, 120, 5, 50, 0); satellite.Move(nbTurn); Assert.AreEqual(0, satellite.CurrentRot.Lat); Assert.AreEqual(0, satellite.CurrentRot.Lon); Assert.AreEqual(10, satellite.Range.DeltaLatMax); Assert.AreEqual(-10, satellite.Range.DeltaLatMin); Assert.AreEqual(-10, satellite.Range.DeltaLonMin); Assert.AreEqual(10, satellite.Range.DeltaLonMax); }
public static Input Parse(string fileName) { var input = new Input(); using (var reader = new StreamReader(fileName)) { input.NbTurns = ReadInt(reader); var nbSat = ReadInt(reader); for (int i = 0; i < nbSat; i++) { var line = ReadMulti(reader); var sat = new Satellite( lat: line[0], lon: line[1], speed: line[2], rotSpeed: line[3], maxRot: line[4], id: i); input.Satellites.Add(sat); } var nbCollec = ReadInt(reader); var picId = 0; for (int i = 0; i < nbCollec; i++) { var line = ReadMulti(reader); var collec = new PicCollection(line[0], picId); var nbLoc = line[1]; picId += nbLoc; for (int j = 0; j < nbLoc; j++) { var loc = ReadMulti(reader); collec.Locations.Add(new Coords {Lat = loc[0], Lon = loc[1]}); } var nbRanges = line[2]; for (int j = 0; j < nbRanges; j++) { var time = ReadMulti(reader); collec.TimeRanges.Add(new TimeRange(time[0], time[1])); } input.Collections.Add(collec); } } return input; }
private static void Step(List<PartialSolution> ranges, Satellite sat) { foreach (var range in ranges) { range.CurrentRange.Increase(1, sat.RotSpeed, sat.MaxRot); } sat.Move(1); }