//------------------------------------------------------------------------------------- /// <summary> /// CalculateOrbitSolutions Precalculate satellite positions for a particular orbit /// </summary> //------------------------------------------------------------------------------------- private List<SatelliteModel> CalculateOrbitSolutions() { // Calculate the long orbit and divide it up into points. double theta = 0; List<SatelliteModel> mainOrbit = new List<SatelliteModel>(); var testSatellite = new SatelliteModel(); var satelliteRadius = PhysicalConstants.EARTHRADIUS_METERS + SimulationConstants.Altitude_Meters; SetSatelliteData(theta, testSatellite, satelliteRadius); var stepDistanceMeters = 20000; mainOrbit.Add(testSatellite.Clone()); var lastLocation = testSatellite.Location; var orbitCheckLocation = testSatellite.Location; int count = 0; var done = false; int thisOrbitCount = 0; while (!done) { while ((testSatellite.Location - lastLocation).Length < stepDistanceMeters) { var length = (testSatellite.Location - lastLocation).Length; count++; testSatellite.Move(.1); // Check for orbit completion if (thisOrbitCount > 2) { if ((testSatellite.Location - orbitCheckLocation).Length < stepDistanceMeters) { theta += Math.PI * .05; if (theta > Math.PI * 2) { done = true; } SetSatelliteData(theta, testSatellite, satelliteRadius); orbitCheckLocation = lastLocation = testSatellite.Location; thisOrbitCount = 0; break; } } } mainOrbit.Add(testSatellite.Clone()); thisOrbitCount++; lastLocation = testSatellite.Location; } return mainOrbit; }