Exemplo n.º 1
0
        public Form1()
        {
            var earth = new Planet(this.sol);
            sol.OrbitSun(earth, 365d);
            earth.AddSatellite(new Moon(earth), 28d);

            var mars = new Planet(this.sol);
            sol.OrbitSun(mars, 450d);

            var phobos = new Moon(mars);
            mars.AddSatellite(phobos, 41d);

            var deimos = new Moon(phobos);
            phobos.AddSatellite(deimos, 15d);

            InitializeComponent();
        }
Exemplo n.º 2
0
        public void Orbiting()
        {
            Rand.Initialise(0);
            var sol = new SolarSystem();

            var earth = new Planet(sol);
            sol.OrbitSun(earth, 365d);

            var moon = new Moon(earth);
            earth.AddSatellite(moon, 28d);

            double earthOrbitRadius = (earth.UniversalCoordinates - sol.UniversalCoordinates).Magnitude;
            double moonOrbitRadius = (moon.UniversalCoordinates - earth.UniversalCoordinates).Magnitude;

            for (uint i=0; i <= 365; i++)
            {
                sol.Tick(i);

                Assert.AreEqual(earthOrbitRadius, (earth.UniversalCoordinates - sol.UniversalCoordinates).Magnitude, "Earth hit escape velocity!");
                Assert.AreEqual(moonOrbitRadius, (moon.UniversalCoordinates - earth.UniversalCoordinates).Magnitude, "Moon hit escape velocity!");

                Console.WriteLine("{0:n4},{1:n4},{2:n4},{3:n4}", earth.UniversalCoordinates.X, earth.UniversalCoordinates.Y, moon.UniversalCoordinates.X, moon.UniversalCoordinates.Y);
            }
        }