Example #1
0
 private void LoadVelocityInfo(AstronomicalBody body)
 {
     velXBox.Text      = body.Velocity.X.ToString();
     velYBox.Text      = body.Velocity.Y.ToString();
     velZBox.Text      = body.Velocity.Z.ToString();
     velLengthBox.Text = body.Velocity.Length.ToString();
     velThetaBox.Text  = body.Velocity.Theta.ToString();
     velPhiBox.Text    = body.Velocity.Phi.ToString();
 }
Example #2
0
        public AstronomicalBodyPage(AstronomicalBody body)
        {
            InitializeComponent();

            Title = body.Name;

            lblIcon.Text          = body.EmojiIcon;
            lblName.Text          = body.Name;
            lblMass.Text          = body.Mass;
            lblCircumference.Text = body.Circumference;
            lblAge.Text           = body.Age;
        }
Example #3
0
 private void LoadBodyInfo(AstronomicalBody body)
 {
     try
     {
         LoadGeneralInfo(body);
         LoadPositionInfo(body);
         LoadVelocityInfo(body);
     }
     catch (Exception exc)
     {
     }
 }
Example #4
0
        private void LoadPositionInfo(AstronomicalBody body)
        {
            double number = 0;
            int    e      = 0;

            MathUtilities.ParseToExpNotation(body.Center.X, out number, out e);
            posXBox.Text  = number.ToString();
            posXEBox.Text = e.ToString();
            MathUtilities.ParseToExpNotation(body.Center.Y, out number, out e);
            posYBox.Text  = number.ToString();
            posYEBox.Text = e.ToString();
            MathUtilities.ParseToExpNotation(body.Center.Z, out number, out e);
            posZBox.Text  = number.ToString();
            posZEBox.Text = e.ToString();
        }
Example #5
0
        private void LoadGeneralInfo(AstronomicalBody body)
        {
            // Name
            nameBox.Text = body.Name;

            // Type

            if (body is Star)
            {
                typeBox.Text = "Star";
            }
            else if (body is Planet)
            {
                typeBox.Text = "Planet";
            }
            else if (body is Moon)
            {
                typeBox.Text = "Moon";
            }
            else if (body is Asteroid)
            {
                typeBox.Text = "Asteroid";
            }
            else if (body is ArtificialObject)
            {
                typeBox.Text = "Artificial object";
            }

            // Mass
            double number = 0;
            int    e      = 0;

            MathUtilities.ParseToExpNotation(body.Mass, out number, out e);
            massBox.Text  = number.ToString();
            massEBox.Text = e.ToString();

            // Radius
            MathUtilities.ParseToExpNotation(body.Radius, out number, out e);
            radiusBox.Text  = number.ToString();
            radiusEBox.Text = e.ToString();

            // Density
            MathUtilities.ParseToExpNotation(body.Density, out number, out e);
            densityBox.Text  = number.ToString();
            densityEBox.Text = e.ToString();
        }
Example #6
0
 private void planetarySystemTreeView_AfterSelect(object sender, TreeViewEventArgs e)
 {
     if (e.Node.Text != currentPlanetarySystem.Name &&
         e.Node.Text != "No star assigned" &&
         e.Node.Text != "Planets:" &&
         e.Node.Text != "Moons:" &&
         e.Node.Text != "Asteroids:" &&
         e.Node.Text != "Artificial objects:")
     {
         var name = e.Node.Text;
         if (name.IndexOf("Star: ") >= 0)
         {
             name = name.Remove(0, 6);
         }
         var allBodies         = currentPlanetarySystem.GetAllBodies();
         var selectedBodyQuery = from b in allBodies
                                 where b.Name == name
                                 select b;
         selectedBody = selectedBodyQuery.FirstOrDefault();
         LoadBodyInfo(selectedBody);
     }
 }
Example #7
0
        private void setOrbitButon_Click(object sender, EventArgs e)
        {
            try
            {
                double coveredAngle = 0;
                try
                {
                    coveredAngle = double.Parse(setOrbitCoveredAngleBox.Text);
                }
                catch (Exception exc)
                { }
                double orbitParameter = MathUtilities.ParseFromExpNotation(
                    double.Parse(setOrbitParameterBox.Text),
                    int.Parse(setOrbitParameterEBox.Text));
                if (selectedBody is Planet)
                {
                    Planet planet = (Planet)selectedBody;
                    if (setOrbitRadiusRadio.Checked)
                    {
                        Vector startingVelocity = new Vector(planet.Velocity);
                        PlanetSystem.Models.Utilities.Point startingPoint = new PlanetSystem.Models.Utilities.Point(planet.Center);
                        if (setOrbitRadiusRadio.Checked)
                        {
                            Physics.EnterOrbitByGivenRadius(ref planet, currentPlanetarySystem.Star, orbitParameter, coveredAngle);
                        }
                        else
                        {
                            Physics.EnterOrbitByGivenSpeed(ref planet, currentPlanetarySystem.Star, orbitParameter, coveredAngle);
                        }
                        Vector deltaVelocity = planet.Velocity - startingVelocity;
                        PlanetSystem.Models.Utilities.Point deltaPoint = planet.Center - startingPoint;
                        planet.Moons.ToList().ForEach(m =>
                        {
                            Physics.AddVelocityToBody(ref m, deltaVelocity);
                            m.Center = new PlanetSystem.Models.Utilities.Point(
                                m.Center.X + deltaPoint.X,
                                m.Center.Y + deltaPoint.Y,
                                m.Center.X + deltaPoint.Z
                                );
                        });
                    }
                    else
                    {
                        Vector startingVelocity = new Vector(planet.Velocity);
                        PlanetSystem.Models.Utilities.Point startingPoint = new PlanetSystem.Models.Utilities.Point(planet.Center);
                        if (setOrbitRadiusRadio.Checked)
                        {
                            Physics.EnterOrbitByGivenSpeed(ref planet, currentPlanetarySystem.Star, orbitParameter, coveredAngle);
                        }
                        else
                        {
                            Physics.EnterOrbitByGivenSpeed(ref planet, currentPlanetarySystem.Star, orbitParameter, coveredAngle);
                        }
                        Vector deltaVelocity = planet.Velocity - startingVelocity;
                        PlanetSystem.Models.Utilities.Point deltaPoint = planet.Center - startingPoint;
                        planet.Moons.ToList().ForEach(m =>
                        {
                            Physics.AddVelocityToBody(ref m, deltaVelocity);
                            m.Center = new PlanetSystem.Models.Utilities.Point(
                                m.Center.X + deltaPoint.X,
                                m.Center.Y + deltaPoint.Y,
                                m.Center.X + deltaPoint.Z
                                );
                        });
                    }
                }
                else if (selectedBody is Moon)
                {
                    Moon moon = (Moon)selectedBody;
                    if (setOrbitRadiusRadio.Checked)
                    {
                        Physics.EnterOrbitByGivenRadius(ref moon, moon.Planet, orbitParameter, coveredAngle);
                    }
                    else
                    {
                        Physics.EnterOrbitByGivenSpeed(ref moon, moon.Planet, orbitParameter, coveredAngle);
                    }
                }
                else if (selectedBody is Asteroid)
                {
                    Asteroid asteroid     = (Asteroid)selectedBody;
                    var      bodies       = currentPlanetarySystem.GetAllBodies();
                    var      primaryQuery = from p in bodies
                                            where p.Name == setOrbitPrimeBox.SelectedText
                                            select p;

                    AstronomicalBody primary = primaryQuery.FirstOrDefault();
                    if (setOrbitRadiusRadio.Checked)
                    {
                        Physics.EnterOrbitByGivenRadius(ref asteroid, primary, orbitParameter, coveredAngle);
                    }
                    else
                    {
                        Physics.EnterOrbitByGivenSpeed(ref asteroid, primary, orbitParameter, coveredAngle);
                    }
                }
                else if (selectedBody is ArtificialObject)
                {
                    ArtificialObject artificialObject = (ArtificialObject)selectedBody;
                    var bodies       = currentPlanetarySystem.GetAllBodies();
                    var primaryQuery = from p in bodies
                                       where p.Name == setOrbitPrimeBox.SelectedText
                                       select p;

                    AstronomicalBody primary = primaryQuery.FirstOrDefault();
                    if (setOrbitRadiusRadio.Checked)
                    {
                        Physics.EnterOrbitByGivenRadius(ref artificialObject, primary, orbitParameter, coveredAngle);
                    }
                    else
                    {
                        Physics.EnterOrbitByGivenSpeed(ref artificialObject, primary, orbitParameter, coveredAngle);
                    }
                }
                else
                {
                    var bodies       = currentPlanetarySystem.GetAllBodies();
                    var primaryQuery = from p in bodies
                                       where p.Name == setOrbitPrimeBox.SelectedText
                                       select p;

                    AstronomicalBody primary = primaryQuery.FirstOrDefault();
                    if (setOrbitRadiusRadio.Checked)
                    {
                        Physics.EnterOrbitByGivenRadius(ref selectedBody, primary, orbitParameter, coveredAngle);
                    }
                    else
                    {
                        Physics.EnterOrbitByGivenSpeed(ref selectedBody, primary, orbitParameter, coveredAngle);
                    }
                }
                Refresh();
            }
            catch (Exception exc)
            {
            }
        }