Exemplo n.º 1
0
        internal void SetToNearestJPLPosition(ulong NearestDate)
        {
            JPLHorizonsData.JPLRec Rec = JPLData.GetNearestRecByDateTime(NearestDate);
            // ShowStatus( "Rec.CalDate is:" );
            if (Rec.CalDate == 0)
            {
                ShowStatus("No JPL data for: " + ObjectName);
                return;
            }

            // ECTime ShowTime = new ECTime( Rec.CalDate );
            // ShowStatus( ShowTime.ToCrudeString());

            Position.X = Rec.PositionX;
            Position.Y = Rec.PositionY;
            Position.Z = Rec.PositionZ;

            Velocity.X = Rec.VelocityX;
            Velocity.Y = Rec.VelocityY;
            Velocity.Z = Rec.VelocityZ;

            ShowStatus(" ");
            ShowStatus(ObjectName);
            ShowStatus("Position.X: " + Position.X.ToString("N1"));
            ShowStatus("Position.Y: " + Position.Y.ToString("N1"));
            ShowStatus("Position.Z: " + Position.Z.ToString("N1"));

            ShowStatus("Velocity.X: " + Velocity.X.ToString("N1"));
            ShowStatus("Velocity.Y: " + Velocity.Y.ToString("N1"));
            ShowStatus("Velocity.Z: " + Velocity.Z.ToString("N1"));
        }
Exemplo n.º 2
0
/*
 * private void InitializeTimes()
 *  {
 *  SunTime.SetToNow();
 *
 *  // https://en.wikipedia.org/wiki/March_equinox
 *
 *  // "Spring Equinox 2018 was at 10:15 AM on
 *  // March 20."
 *  SpringTime.SetUTCTime( 2018,
 *                          3,
 *                          20,
 *                          10,
 *                          15,
 *                          0,
 *                          0 );
 *
 *
 *  }
 */



/*
 * private void SetPositionsAndTime( ECTime SetTime )
 *  {
 *  SunTime.Copy( SetTime );
 *
 *  }
 */



        private void AddInitialSpaceObjects()
        {
            try
            {
                // Sun:
                string JPLFileName = "C:\\Eric\\ClimateModel\\EphemerisData\\JPLSun.txt";
                Sun                 = new PlanetSphere(MForm, "Sun", true, JPLFileName);
                Sun.Radius          = 695700 * ModelConstants.TenTo3;
                Sun.Mass            = ModelConstants.MassOfSun;
                Sun.TextureFileName = "C:\\Eric\\ClimateModel\\bin\\Release\\sun.jpg";
                AddSpaceObject(Sun);

                // Earth:
                JPLFileName           = "C:\\Eric\\ClimateModel\\EphemerisData\\JPLEarth.txt";
                Earth                 = new EarthGeoid(MForm, "Earth", JPLFileName);
                Earth.Mass            = ModelConstants.MassOfEarth;
                Earth.TextureFileName = "C:\\Eric\\ClimateModel\\bin\\Release\\earth.jpg";
                AddSpaceObject(Earth);

                // Moon:
                JPLFileName = "C:\\Eric\\ClimateModel\\EphemerisData\\JPLMoon.txt";
                Moon        = new PlanetSphere(MForm, "Moon", false, JPLFileName);
                // Radius: About 1,737.1 kilometers.
                Moon.Radius          = 1737100;
                Moon.Mass            = ModelConstants.MassOfMoon;
                Moon.TextureFileName = "C:\\Eric\\ClimateModel\\bin\\Release\\moon.jpg";
                AddSpaceObject(Moon);

                // Space Station:
                // Both Earth and the Space Station need to be
                // using the same time intervals for the JPL
                // data.
                // JPLFileName = "C:\\Eric\\ClimateModel\\EphemerisData\\JPLSpaceStation.txt";
                // SpaceStation = new PlanetSphere( MForm, "Space Station", false, JPLFileName );
                // It's about 418 kilometers above the Earth.
                // SpaceStation.Radius = 400000; // 418000;
                // SpaceStation.Mass = 1.0;
                // SpaceStation.TextureFileName = "C:\\Eric\\ClimateModel\\bin\\Release\\TestImage2.jpg";
                // AddSpaceObject( SpaceStation );

/*
 * I would need to set this position after getting
 * Earth rotation angle and all that.
 *  // Leadville marker:
 *  JPLFileName = "";
 *  Leadville = new PlanetSphere( MForm, "Leadville", false, JPLFileName );
 *  Leadville.Radius = 1000000;
 *  Leadville.Mass = 0;
 *  Leadville.TextureFileName = "C:\\Eric\\ClimateModel\\bin\\Release\\TestImage.jpg";
 *  AddSpaceObject( Leadville );
 */

                // Mercury:
                JPLFileName = "C:\\Eric\\ClimateModel\\EphemerisData\\JPLMercury.txt";
                PlanetSphere Mercury = new PlanetSphere(
                    MForm, "Mercury", false, JPLFileName);

                Mercury.Radius          = 2440000d * RadiusScale;
                Mercury.Mass            = ModelConstants.MassOfMercury;
                Mercury.TextureFileName = "C:\\Eric\\ClimateModel\\bin\\Release\\Mercury.jpg";
                AddSpaceObject(Mercury);

                // Venus:
                JPLFileName = "C:\\Eric\\ClimateModel\\EphemerisData\\JPLVenus.txt";
                PlanetSphere Venus = new PlanetSphere(
                    MForm, "Venus", false, JPLFileName);

                Venus.Radius          = 6051000 * RadiusScale; // 6,051 km
                Venus.Mass            = ModelConstants.MassOfVenus;
                Venus.TextureFileName = "C:\\Eric\\ClimateModel\\bin\\Release\\Venus.jpg";
                AddSpaceObject(Venus);

                // Mars:
                JPLFileName = "C:\\Eric\\ClimateModel\\EphemerisData\\JPLMars.txt";
                PlanetSphere Mars = new PlanetSphere(
                    MForm, "Mars", false, JPLFileName);

                Mars.Radius          = 3396000 * RadiusScale;
                Mars.Mass            = ModelConstants.MassOfMars;
                Mars.TextureFileName = "C:\\Eric\\ClimateModel\\bin\\Release\\mars.jpg";
                AddSpaceObject(Mars);


                // Jupiter:
                JPLFileName = "C:\\Eric\\ClimateModel\\EphemerisData\\JPLJupiter.txt";
                PlanetSphere Jupiter = new PlanetSphere(
                    MForm, "Jupiter", false, JPLFileName);

                //                m  t
                Jupiter.Radius          = 69911000d * RadiusScale; // 69,911 km
                Jupiter.Mass            = ModelConstants.MassOfJupiter;
                Jupiter.TextureFileName = "C:\\Eric\\ClimateModel\\bin\\Release\\Jupiter.jpg";
                AddSpaceObject(Jupiter);

                // Saturn:
                JPLFileName = "C:\\Eric\\ClimateModel\\EphemerisData\\JPLSaturn.txt";
                PlanetSphere Saturn = new PlanetSphere(
                    MForm, "Saturn", false, JPLFileName);

                //               m  t
                Saturn.Radius          = 58232000d * RadiusScale; // 58,232 km
                Saturn.Mass            = ModelConstants.MassOfSaturn;
                Saturn.TextureFileName = "C:\\Eric\\ClimateModel\\bin\\Release\\Saturn.jpg";
                AddSpaceObject(Saturn);

                // North Pole:
                PlanetSphere NorthPole = new PlanetSphere(
                    MForm, "North Pole", false, "");

                NorthPole.Radius          = 400000d;
                NorthPole.Mass            = 0;
                NorthPole.TextureFileName = "C:\\Eric\\ClimateModel\\bin\\Release\\TestImage2.jpg";
                AddSpaceObject(NorthPole);

                // Moon Axis:
                PlanetSphere MoonAxis = new PlanetSphere(
                    MForm, "Moon Axis", false, "");

                MoonAxis.Radius          = 200000d;
                MoonAxis.Mass            = 0;
                MoonAxis.TextureFileName = "C:\\Eric\\ClimateModel\\bin\\Release\\TestImage2.jpg";
                AddSpaceObject(MoonAxis);


                // Solar North:
                PlanetSphere SolarNorth = new PlanetSphere(
                    MForm, "Solar North", false, "");

                SolarNorth.Radius          = 100000d;
                SolarNorth.Mass            = 0;
                SolarNorth.TextureFileName = "C:\\Eric\\ClimateModel\\bin\\Release\\TestImage2.jpg";
                AddSpaceObject(SolarNorth);


                ///////////////////////////////////
                // Set the positions of the objects from the JPL data.
                SetJPLTimes();


                // Now that the Earth's position has been set...

                Vector3.Vector NorthPoleUnit = Earth.GetNorthPoleVector();

                Vector3.Vector NorthPolePos =
                    Vector3.MultiplyWithScalar(NorthPoleUnit,
                                               ModelConstants.EarthRadiusMinor + NorthPole.Radius);

                NorthPolePos       = Vector3.Add(NorthPolePos, Earth.Position);
                NorthPole.Position = NorthPolePos;


                // Set the moon axis.
                Vector3.Vector MoonFirstPosition = Moon.Position;
                // Subtract the Earth's position so this is just in relation
                // to the Earth.
                MoonFirstPosition = Vector3.Subtract(MoonFirstPosition, Earth.Position);

                ECTime OneWeek   = new ECTime(SunTime.GetIndex());
                int    SevenDays = 7 * 24 * 60;
                OneWeek.AddMinutes(SevenDays);

                JPLHorizonsData.JPLRec Rec =
                    Moon.JPLData.GetNearestRecByDateTime(OneWeek.GetIndex());

                // if( Rec.CalDate == 0 ) then it's not found.

                Vector3.Vector MoonSecondPosition;
                MoonSecondPosition.X = Rec.PositionX;
                MoonSecondPosition.Y = Rec.PositionY;
                MoonSecondPosition.Z = Rec.PositionZ;

                // Get the Earth's position a week from now.
                Rec = Earth.JPLData.GetNearestRecByDateTime(OneWeek.GetIndex());

                Vector3.Vector EarthSecondPosition;
                EarthSecondPosition.X = Rec.PositionX;
                EarthSecondPosition.Y = Rec.PositionY;
                EarthSecondPosition.Z = Rec.PositionZ;


                MoonSecondPosition = Vector3.Subtract(MoonSecondPosition, EarthSecondPosition);

                // MoonFirstPosition = Vector3.Normalize( MoonFirstPosition );
                // MoonSecondPosition = Vector3.Normalize( MoonSecondPosition );

                Vector3.Vector MoonAxisPos = Vector3.CrossProduct(
                    MoonFirstPosition,
                    MoonSecondPosition);

                MoonAxisPos = Vector3.Normalize(MoonAxisPos);
                MoonAxisPos = Vector3.MultiplyWithScalar(MoonAxisPos,
                                                         ModelConstants.EarthRadiusMinor + MoonAxis.Radius);

                MoonAxisPos = Vector3.Add(MoonAxisPos, Earth.Position);

                MoonAxis.Position = MoonAxisPos;


                Vector3.Vector SolarNorthPos;
                SolarNorthPos.X = 0;
                SolarNorthPos.Y = 0;
                SolarNorthPos.Z = 1;
                SolarNorthPos   = Vector3.MultiplyWithScalar(SolarNorthPos,
                                                             ModelConstants.EarthRadiusMinor + SolarNorth.Radius);

                SolarNorthPos       = Vector3.Add(SolarNorthPos, Earth.Position);
                SolarNorth.Position = SolarNorthPos;
            }
            catch (Exception Except)
            {
                MForm.ShowStatus("Exception in SolarSystem.AddMercury(): " + Except.Message);
            }
        }