Esempio n. 1
0
 public void Deinit()
 {
     // Environment
     StaticAirTemperature.Remove();
     StaticPressure.Remove();
     // Orbit
     Apoapsis.Remove();
     Periapsis.Remove();
     TimeToApoapsis.Remove();
     // Vessel
     Altitude.Remove();
     AngularVelocity.Remove();
     AvailablePosTorque.Remove();
     AvailableRCSForce.Remove();
     AvailableThrust.Remove();
     AvailableTorque.Remove();
     Direction.Remove();
     DryMass.Remove();
     Forward.Remove();
     Mass.Remove();
     MaxVacuumThrust.Remove();
     MomentOfInertia.Remove();
     Position.Remove();
     Right.Remove();
     Thrust.Remove();
     Up.Remove();
     VacuumSpecificImpulse.Remove();
     Velocity.Remove();
 }
Esempio n. 2
0
        private void InitializeModules()
        {
            modules = new List <IInfoModule>();

            peri = new Periapsis("Periapsis", currentVessel);
            apo  = new Apoapsis("Apoapsis", currentVessel);
            sma  = new SemiMajorAxis("Semi-Major Axis", currentVessel);
            ecc  = new Eccentricity("Eccentricity", currentVessel);
            inc  = new Inclination("Inclination", currentVessel);
            alt  = new Altitude("Current Altitude", currentVessel);
            vel  = new Velocity("Current Speed", currentVessel);
            acc  = new Acceleration("Current Acceleration", currentVessel);

            peri.IsVisible = PTGUI_Settings.Instance.showPeriapsis;
            apo.IsVisible  = PTGUI_Settings.Instance.showApoapsis;
            sma.IsVisible  = PTGUI_Settings.Instance.showSMA;
            ecc.IsVisible  = PTGUI_Settings.Instance.showApoapsis;
            inc.IsVisible  = PTGUI_Settings.Instance.showInclination;
            alt.IsVisible  = PTGUI_Settings.Instance.showAltitude;
            vel.IsVisible  = PTGUI_Settings.Instance.showVelocity;
            acc.IsVisible  = PTGUI_Settings.Instance.showAcceleration;

            modules.Add(peri);
            modules.Add(apo);
            modules.Add(sma);
            modules.Add(ecc);
            modules.Add(inc);
            modules.Add(alt);
            modules.Add(vel);
            modules.Add(acc);
        }
Esempio n. 3
0
        private List <IBasicModule> AddOrbitModules()
        {
            List <IBasicModule> modules = new List <IBasicModule>();

            apo      = new Apoapsis("Apoapsis");
            peri     = new Periapsis("Periapsis");
            inc      = new Inclination("Inclination");
            ecc      = new Eccentricity("Eccentricity");
            period   = new Period("Period");
            SMA      = new SemiMajorAxis("Semi Major Axis");
            LAN      = new LongAscending("LAN");
            AoPE     = new ArgOfPeriapsis("Arg of Pe");
            altitude = new OrbitAltitude("Altitude");
            radar    = new RadarAltitude("Radar Altitude");
            terrain  = new TerrainAltitude("Terrain Altitude");
            location = new Location("Location");

            apo.IsVisible       = settings.showApoapsis;
            apo.AlwaysShow      = settings.showApoapsisAlways;
            peri.IsVisible      = settings.showPeriapsis;
            peri.AlwaysShow     = settings.showPeriapsisAlways;
            inc.IsVisible       = settings.showInclination;
            inc.AlwaysShow      = settings.showInclinationAlways;
            ecc.IsVisible       = settings.showEccentricity;
            ecc.AlwaysShow      = settings.showEccentricityAlways;
            period.IsVisible    = settings.showPeriod;
            period.AlwaysShow   = settings.showPeriodAlways;
            SMA.IsVisible       = settings.showSMA;
            SMA.AlwaysShow      = settings.showSMAAlways;
            LAN.IsVisible       = settings.showLAN;
            LAN.AlwaysShow      = settings.showLANAlways;
            AoPE.IsVisible      = settings.showAoPe;
            AoPE.AlwaysShow     = settings.showAoPeAlways;
            altitude.IsVisible  = settings.showOrbitAltitude;
            altitude.AlwaysShow = settings.showOrbitAltitudeAlways;
            radar.IsVisible     = settings.showRadar;
            radar.AlwaysShow    = settings.showRadarAlways;
            terrain.IsVisible   = settings.showTerrain;
            terrain.AlwaysShow  = settings.showTerrainAlways;
            location.IsVisible  = settings.showLocation;
            location.AlwaysShow = settings.showLocationAlways;

            modules.Add(AoPE);
            modules.Add(LAN);
            modules.Add(SMA);
            modules.Add(terrain);
            modules.Add(radar);
            modules.Add(altitude);
            modules.Add(location);
            modules.Add(period);
            modules.Add(ecc);
            modules.Add(inc);
            modules.Add(peri);
            modules.Add(apo);

            return(modules);
        }
Esempio n. 4
0
        public void TestKeplerElementsFromVectors()
        {
            Vector3 position = new Vector3()
            {
                X = Distance.KmToAU(405400)
            };                                                                //moon at apoapsis
            Vector3 velocity = new Vector3()
            {
                Y = Distance.KmToAU(0.97)
            };                                                              //approx velocity of moon at apoapsis
            double         parentMass = 5.97237e24;
            double         objMass    = 7.342e22;
            double         sgp        = OrbitMath.CalculateStandardGravityParameter(parentMass, objMass);
            KeplerElements elements   = OrbitMath.KeplerFromPositionAndVelocity(sgp, position, velocity, new DateTime());

            Vector3 postionKm = new Vector3()
            {
                X = 405400
            };
            Vector3 velocityKm = new Vector3()
            {
                Y = 0.97
            };
            double sgpKm = OrbitMath.CalculateStandardGravityParameterInM3S2(parentMass, objMass);

            KeplerElements elementsKm = OrbitMath.KeplerFromPositionAndVelocity(sgpKm, postionKm, velocityKm, new DateTime());

            //check that the function is unit agnostic.
            Assert.AreEqual(Distance.AuToKm(elements.SemiMajorAxis), elementsKm.SemiMajorAxis, 0.001);
            Assert.AreEqual(elements.Eccentricity, elementsKm.Eccentricity, 1.0e-9); //this is where inacuarcy from units stars creaping in, not much can do about that.
            Assert.AreEqual(Distance.AuToKm(elements.Apoapsis), elementsKm.Apoapsis, 0.001);
            Assert.AreEqual(Distance.AuToKm(elements.Periapsis), elementsKm.Periapsis, 0.001);

            //var ta = OrbitMath.TrueAnomalyFromEccentricAnomaly(elements.Eccentricity, elements.)
            var speedAU = OrbitMath.InstantaneousOrbitalSpeed(sgp, position.Length(), elements.SemiMajorAxis);

            //var speedVectorAU = OrbitMath.PreciseOrbitalVelocityVector(sgp, position, elements.SemiMajorAxis, elements.Eccentricity, elements.LoAN + elements.AoP);
            //Assert.AreEqual(speedAU, speedVectorAU.Length());

            Assert.AreEqual(elementsKm.Apoapsis + elementsKm.Periapsis, elementsKm.SemiMajorAxis * 2, 0.001);


            var speedKm  = velocityKm.Length();
            var speedKm2 = OrbitMath.InstantaneousOrbitalSpeed(sgpKm, postionKm.Length(), elementsKm.SemiMajorAxis);

            Assert.AreEqual(speedKm, speedKm2, 0.001);


            Assert.GreaterOrEqual(elements.Apoapsis, elements.Periapsis);
            Assert.GreaterOrEqual(elementsKm.Apoapsis, elementsKm.Periapsis);

            //below was some experimentation with different ways of calculating things, and an attempt to use decimal for Eccentricity.
            //not sure it's worth the minor slowdown or complication, didn't seem to fix the problem I was seeing in anycase.
            #region experimentation

            var H   = Vector3.Cross(postionKm, velocityKm).Length();
            var p   = H * H / sgpKm;
            var sma = 1 / (2 / postionKm.Length() - velocityKm.Length() * velocityKm.Length() / sgpKm); //  semi-major axis


            decimal E;
            double  Periapsis;
            double  Apoapsis;

            if (sma < (double)decimal.MaxValue)
            {
                decimal smad = (decimal)sma;
                E = GMath.Sqrt(1 - (decimal)p / smad);

                decimal PlusMinus = smad * E;
                Periapsis = (double)(smad - PlusMinus);
                Apoapsis  = (double)(smad + PlusMinus);
            }
            else
            {
                E = (decimal)Math.Sqrt(1 - p / sma);  // eccentricity

                double PlusMinus = sma * (double)E;
                Periapsis = sma - PlusMinus;
                Apoapsis  = sma + PlusMinus;
            }
            Assert.AreEqual(Periapsis + Apoapsis, sma * 2, 0.0001);
            var peStr = Periapsis.ToString("R");
            var apStr = Apoapsis.ToString("R");
            //Assert.AreEqual(elementsKm.SemiMajorAxis, sma);
            var difference1 = (Periapsis + Apoapsis) - sma * 2;
            var difference2 = (elementsKm.Apoapsis + elementsKm.Periapsis) - elementsKm.SemiMajorAxis * 2;

            #endregion

            if (velocity.Z == 0)
            {
                Assert.IsTrue(elements.Inclination == 0);
            }
        }