コード例 #1
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);
        }
コード例 #2
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)
            {
            }
        }