Beispiel #1
0
        public void MoveToNextStatus(ShowInfoTextDelegate ShowInfoText, bool showContinueButton, bool showResetButton)
        {
            ResourceManager rm = new ResourceManager("Hohmann.InfoText", Assembly.GetExecutingAssembly());

            currStatus++;

            string infoMessage = rm.GetString("txtInfo" + currStatus.ToString(), new CultureInfo(System.String.Empty));

            ShowInfoText(infoMessage, showContinueButton, showResetButton);
        }
Beispiel #2
0
        public void AdvanceOneDay(ShowInfoTextDelegate ShowInfoText)
        {
            double satAnomaly;

            simulationDaysElapsed++;
            simulationCurrDate = simulationCurrDate.AddDays(1);

            bodyEarth.AdvanceOneDay();
            bodyMars.AdvanceOneDay();

            if (showingSatellite)
            {
                satAnomaly = bodySatellite.AdvanceOneDay();
                if (!freeSpinning && satEventWatcher.SignChangeInDifference(satAnomaly, Math.PI))                //check for completion of half an orbit (ie arrival on Mars)
                {
                    MoveToNextStatus(ShowInfoText, true, true);
                    freeSpinning = true;
                    return;
                }
            }

            if (!showingSatellite)
            {               //look for launch window
                int Tmars = bodyMars.OrbitalPeriod, Tsat = bodySatellite.OrbitalPeriod;
                //In Tsat/2 days, satellite will travel Pi radians,	and Mars will travel [Tsat/Tmars] * Pi radians,
                //so need to launch when Mars has a headstart of Pi (1- [Tsat/Tmars]) radians on the Earth
                double marsHeadstartRequired = Math.PI * (1 - (double)Tsat / Tmars);
                double earthAngle = bodyEarth.GetTrueAnomaly(), marsAngle = bodyMars.GetTrueAnomaly();

                if (marsAngle < earthAngle)
                {
                    marsAngle += 2.0 * Math.PI;                                         //always consider Mars to be ahead of Earth
                }
                //We're looking for HeadstartRequired = CurrentHeadstart, but we need to cope with floating-point
                // inaccuracies.  The best way to do this is to look for a sign change in (HeadstartRequired - CurrentHeadstart)
                double planetAngularSeparation = marsAngle - earthAngle;
                if (satEventWatcher.SignChangeInDifference(marsHeadstartRequired, planetAngularSeparation))
                {
                    showingSatellite  = true;
                    SatMajorAxisAngle = bodyEarth.GetTrueAnomaly();
                    bodySatellite.Init();
                    satOrbitRect = bodySatellite.OrbitBoundingRectUnrotated;
                    satEventWatcher.Reset();                     //now we will use the watcher to look for the satellite's arrival on Mars
                    MoveToNextStatus(ShowInfoText, true, false);
                    return;
                }
            }
        }
		public void AdvanceOneDay(ShowInfoTextDelegate ShowInfoText)
		{
			double satAnomaly;

			simulationDaysElapsed++;
			simulationCurrDate = simulationCurrDate.AddDays(1);

			bodyEarth.AdvanceOneDay();
			bodyMars.AdvanceOneDay();

			if(showingSatellite) 
			{
				satAnomaly = bodySatellite.AdvanceOneDay();
				if(!freeSpinning && satEventWatcher.SignChangeInDifference(satAnomaly, Math.PI)) //check for completion of half an orbit (ie arrival on Mars)
				{
					MoveToNextStatus(ShowInfoText, true, true);
					freeSpinning = true;
					return;
				}
			}

			if(!showingSatellite)
			{   //look for launch window
				int Tmars = bodyMars.OrbitalPeriod, Tsat = bodySatellite.OrbitalPeriod;
				//In Tsat/2 days, satellite will travel Pi radians,	and Mars will travel [Tsat/Tmars] * Pi radians,													  
				//so need to launch when Mars has a headstart of Pi (1- [Tsat/Tmars]) radians on the Earth
				double marsHeadstartRequired = Math.PI * (1 - (double) Tsat / Tmars);
				double earthAngle = bodyEarth.GetTrueAnomaly(),	marsAngle = bodyMars.GetTrueAnomaly();

				if(marsAngle < earthAngle) marsAngle += 2.0 * Math.PI;  //always consider Mars to be ahead of Earth

				//We're looking for HeadstartRequired = CurrentHeadstart, but we need to cope with floating-point
				// inaccuracies.  The best way to do this is to look for a sign change in (HeadstartRequired - CurrentHeadstart)
				double planetAngularSeparation = marsAngle - earthAngle;
				if(satEventWatcher.SignChangeInDifference(marsHeadstartRequired, planetAngularSeparation))
				{
					showingSatellite = true;
					SatMajorAxisAngle = bodyEarth.GetTrueAnomaly();
					bodySatellite.Init();
					satOrbitRect = bodySatellite.OrbitBoundingRectUnrotated;
					satEventWatcher.Reset(); //now we will use the watcher to look for the satellite's arrival on Mars
					MoveToNextStatus(ShowInfoText, true, false);
					return;
				}
			}			
		}
		public void MoveToNextStatus(ShowInfoTextDelegate ShowInfoText, bool showContinueButton, bool showResetButton)
		{
			ResourceManager rm = new ResourceManager("Hohmann.InfoText", Assembly.GetExecutingAssembly());

			currStatus++;

			string infoMessage = rm.GetString("txtInfo" + currStatus.ToString(), new CultureInfo(System.String.Empty));					

			ShowInfoText(infoMessage, showContinueButton, showResetButton);
		}