コード例 #1
0
        static PlanetarySystem GetSolarSystem()
        {
            PlanetarySystem solarSystem = new PlanetarySystem("Solar system");

            Models.Bodies.Star sun = new Models.Bodies.Star(
                center: new Point(0, 0, 0),
                mass: 2 * Math.Pow(10, 30),
                radius: 5,
                velocity: new Vector(0, 0, 0),
                name: "Sun");
            solarSystem.SetStar(sun);

            Planet earth = new Planet(
                center: new Point(0, 0, 0),
                mass: 5.972 * Math.Pow(10, 24),
                radius: 5,
                velocity: new Vector(new Point(0, 0, 0)),
                name: "Earth");

            solarSystem.AddPlanetByOrbitalRadius(earth, 150 * Math.Pow(10, 9), 0);

            //Moon moon = new Moon(
            //    center: new Point(0, 0, 0),
            //    mass: 7.342 * Math.Pow(10, 22),
            //    radius: 5,
            //    velocity: new Vector(new Point(0, 0, 0)),
            //    name: "Moon");
            //solarSystem.AddMoonByOrbitalSpeed(moon, earth, 1022);

            //Asteroid someAsteroid = new Asteroid(
            //    center: new Point(380 * Math.Pow(10, 13), 4560, 7867860),
            //    mass: 7987,
            //    radius: 5,
            //    velocity: new Vector(new Point(-456, 645, 6)),
            //    name: "someAsteroid");
            //solarSystem.AddAsteroid(someAsteroid);

            //ArtificialObject something = new ArtificialObject(
            //    center: new Point( -456786, 1568790, 12370),
            //    mass: 2000,
            //    radius: 5,
            //    velocity: new Vector(new Point(620, -82, 894)),
            //    name: "something");
            //solarSystem.AddArtificialObject(something);

            return(solarSystem);
        }
コード例 #2
0
        static void TESTPopulateDb()
        {
            using (SqlServerContext context = new SqlServerContext())
            {
                PlanetarySystem    solarSystem = new PlanetarySystem("Solar system");
                Models.Bodies.Star sun         = new Models.Bodies.Star(
                    center: new Point(0, 0, 0),
                    mass: 2 * Math.Pow(10, 30),
                    radius: 5,
                    velocity: new Vector(0, 0, 0),
                    name: "Sun");

                Planet earth = new Planet(
                    center: new Point(0, 0, 0),
                    mass: 5.972 * Math.Pow(10, 24),
                    radius: 5,
                    velocity: new Vector(new Point(0, 0, 0)),
                    name: "Earth");
                Moon moon = new Moon(
                    center: new Point(0, 0, 0),
                    mass: 7.342 * Math.Pow(10, 22),
                    radius: 5,
                    velocity: new Vector(new Point(0, 0, 0)),
                    name: "Moon");


                solarSystem.SetStar(sun);
                solarSystem.AddPlanetByOrbitalRadius(earth, 150 * Math.Pow(10, 9), 0);
                //solarSystem.AddPlanetByOrbitalSpeed(earth, 29780);
                solarSystem.AddMoonByOrbitalRadius(moon, earth, 384000000, 0);
                //solarSystem.AttachMoonToPlanetByOrbitalSpeed(moon, earth, 1022);

                context.PlanetarySystems.Add(solarSystem);
                context.Stars.Add(sun);
                context.Planets.Add(earth);
                context.Moons.Add(moon);

                Console.WriteLine("presave");
                context.SaveChanges();
            }
        }
コード例 #3
0
        static PlanetarySystem GetOtherSystem()
        {
            PlanetarySystem otherSystem = new PlanetarySystem("Other system");

            Models.Bodies.Star sun = new Models.Bodies.Star(
                center: new Point(0, 0, 0),
                mass: 2 * Math.Pow(10, 34),
                radius: 5,
                velocity: new Vector(0, 0, 0),
                name: "not the sun");
            otherSystem.SetStar(sun);

            Planet aiur = new Planet(
                center: new Point(0, 0, 0),
                mass: 6.772 * Math.Pow(10, 16),
                radius: 5,
                velocity: new Vector(new Point(0, 0, 0)),
                name: "Aiur");

            otherSystem.AddPlanetByOrbitalRadius(aiur, 75 * Math.Pow(10, 9), 0);

            Moon someAuirMoon = new Moon(
                center: new Point(0, 0, 0),
                mass: 8.123 * Math.Pow(10, 16),
                radius: 5,
                velocity: new Vector(new Point(0, 0, 0)),
                name: "Some Aiur moon");

            otherSystem.AddMoonByOrbitalSpeed(someAuirMoon, aiur, 220, 0);

            Planet notAiur = new Planet(
                center: new Point(0, 0, 0),
                mass: 4.772 * Math.Pow(10, 20),
                radius: 5,
                velocity: new Vector(new Point(0, 0, 0)),
                name: "NotAiur");

            otherSystem.AddPlanetByOrbitalRadius(notAiur, 15 * Math.Pow(10, 9), 0);

            //Moon floatingBrick = new Moon(
            //    center: new Point(0, 0, 0),
            //    mass: 2121.123 * Math.Pow(10, 16),
            //    radius: 5,
            //    velocity: new Vector(new Point(0, 0, 0)),
            //    name: "FoatingBrick");
            //otherSystem.AddMoonByOrbitalSpeed(floatingBrick, notAiur, 1520);

            Moon aDamnSubmarine = new Moon(
                center: new Point(0, 0, 0),
                mass: 1.123 * Math.Pow(10, 13),
                radius: 5,
                velocity: new Vector(new Point(0, 0, 0)),
                name: "a damn submarine");

            otherSystem.AddMoonByOrbitalSpeed(aDamnSubmarine, notAiur, 999, 0);

            Asteroid someOtherAsteroid = new Asteroid(
                center: new Point(-250 * Math.Pow(10, 17), -874560, 565784),
                mass: 7987,
                radius: 5,
                velocity: new Vector(new Point(754, 245, -3)),
                name: "someOtherAsteroid");

            otherSystem.AddAsteroid(someOtherAsteroid);

            ArtificialObject somethingElse = new ArtificialObject(
                center: new Point(1334124, -54656, 9654187654),
                mass: 2000,
                radius: 5,
                velocity: new Vector(new Point(-450, 15, -9987)),
                name: "somethingElse");

            otherSystem.AddArtificialObject(somethingElse);

            return(otherSystem);
        }
コード例 #4
0
        private void createNewButton_Click(object sender, EventArgs e)
        {
            try
            {
                ClearCreateNewSection();
                double coveredAngle = 0;
                try
                {
                    coveredAngle = double.Parse(createNewCoveredAngleBox.Text);
                }
                catch (Exception exc)
                { }

                double mass             = 0;
                double radius           = 0;
                double orbitalParameter = 0;
                if (createNewTypeBox.SelectedIndex != 0)
                {
                    mass             = MathUtilities.ParseFromExpNotation(double.Parse(createNewMassBox.Text), int.Parse(createNewMassEBox.Text));
                    radius           = MathUtilities.ParseFromExpNotation(double.Parse(createNewRadiusBox.Text), int.Parse(createNewRadiusEBox.Text));
                    orbitalParameter = MathUtilities.ParseFromExpNotation(double.Parse(orbitalParameterBox.Text), int.Parse(orbitalParameterEBox.Text));
                }

                switch (createNewTypeBox.SelectedIndex)
                {
                case 0:
                    currentPlanetarySystem = new PlanetarySystem(createNewNameBox.Text);
                    Star star = new Star(
                        new PlanetSystem.Models.Utilities.Point(0, 0, 0),
                        1,
                        1,
                        createNewNameBox.Text + "\' star");
                    currentPlanetarySystem.SetStar(star);
                    break;

                case 1:
                    Planet planet = new Planet(
                        new PlanetSystem.Models.Utilities.Point(0, 0, 0),
                        mass,
                        radius,
                        createNewNameBox.Text);

                    if (orbitByRadiusRadio.Checked)
                    {
                        currentPlanetarySystem.AddPlanetByOrbitalRadius(
                            planet,
                            orbitalParameter,
                            coveredAngle);
                    }
                    else
                    {
                        currentPlanetarySystem.AddPlanetByOrbitalSpeed(
                            planet,
                            orbitalParameter,
                            coveredAngle);
                    }
                    break;

                case 2:
                    string planetName = createNewPrimeSelectionBox.Text;
                    var    primeQuery = from p in currentPlanetarySystem.Planets
                                        where p.Name == planetName
                                        select p;
                    var  prime = primeQuery.FirstOrDefault();
                    Moon moon  = new Moon(
                        new PlanetSystem.Models.Utilities.Point(0, 0, 0),
                        mass,
                        radius,
                        createNewNameBox.Text);

                    if (orbitByRadiusRadio.Checked)
                    {
                        currentPlanetarySystem.AddMoonByOrbitalRadius(
                            moon,
                            prime,
                            orbitalParameter,
                            coveredAngle);
                    }
                    else
                    {
                        currentPlanetarySystem.AddMoonByOrbitalSpeed(
                            moon,
                            prime,
                            orbitalParameter,
                            coveredAngle);
                    }
                    break;

                case 3:
                    Asteroid asteroid = new Asteroid(
                        new PlanetSystem.Models.Utilities.Point(0, 0, 0),
                        mass,
                        radius,
                        createNewNameBox.Text);
                    currentPlanetarySystem.AddAsteroid(asteroid);
                    break;

                case 4:
                    ArtificialObject artObj = new ArtificialObject(new PlanetSystem.Models.Utilities.Point(0, 0, 0),
                                                                   mass,
                                                                   radius,
                                                                   createNewNameBox.Text);
                    currentPlanetarySystem.AddArtificialObject(artObj);
                    break;
                }
                LoadPlanetarySystemToTree(currentPlanetarySystem);
                Backup();
            }
            catch (Exception exc)
            {
            }
        }