Beispiel #1
0
        //The next time at which the orbiting object will reach the given mean anomaly.
        //For elliptical orbits, this will be a time between UT and UT + o.period
        //For hyperbolic orbits, this can be any time, including a time in the past, if
        //the given mean anomaly occurred in the past
        public static double UTAtMeanAnomaly(this Orbit o, double meanAnomaly, double UT)
        {
            double currentMeanAnomaly = o.MeanAnomalyAtUT(UT);
            double meanDifference     = meanAnomaly - currentMeanAnomaly;

            if (o.eccentricity < 1)
            {
                meanDifference = MuUtils.ClampRadiansTwoPi(meanDifference);
            }
            return(UT + meanDifference / o.MeanMotion());
        }
Beispiel #2
0
        //The mean anomaly of the orbit.
        //For elliptical orbits, the value return is always between 0 and 2pi
        //For hyperbolic orbits, the value can be any number.
        public static double MeanAnomalyAtUT(this Orbit o, double UT)
        {
            // We use ObtAtEpoch and not meanAnomalyAtEpoch because somehow meanAnomalyAtEpoch
            // can be wrong when using the RealSolarSystem mod. ObtAtEpoch is always correct.
            double ret = (o.ObTAtEpoch + (UT - o.epoch)) * o.MeanMotion();

            if (o.eccentricity < 1)
            {
                ret = MuUtils.ClampRadiansTwoPi(ret);
            }
            return(ret);
        }
Beispiel #3
0
        //Originally by Zool, revised by The_Duck
        //Converts an eccentric anomaly into a mean anomaly.
        //For an elliptical orbit, the returned value is between 0 and 2pi
        //For a hyperbolic orbit, the returned value is any number
        public static double GetMeanAnomalyAtEccentricAnomaly(this Orbit o, double E)
        {
            double e = o.eccentricity;

            if (e < 1) //elliptical orbits
            {
                return(MuUtils.ClampRadiansTwoPi(E - (e * Math.Sin(E))));
            }
            else //hyperbolic orbits
            {
                return((e * Math.Sinh(E)) - E);
            }
        }
Beispiel #4
0
 private float LaunchHeading(Vessel vessel)
 {
     return((float)MuUtils.HeadingForLaunchInclination(vessel.mainBody, Inclination, vessel.latitude, inclinationHeadingCorrectionSpeed));
 }
Beispiel #5
0
 public string ToString(string format)
 {
     return(MuUtils.PrettyPrint(value, format));
 }
Beispiel #6
0
 //returns a new Orbit object that represents the result of applying a given dV to o at UT
 public static Orbit PerturbedOrbit(this Orbit o, double UT, Vector3d dV)
 {
     //should these in fact be swapped?
     return(MuUtils.OrbitFromStateVectors(o.SwappedAbsolutePositionAtUT(UT), o.SwappedOrbitalVelocityAtUT(UT) + dV, o.referenceBody, UT));
 }
Beispiel #7
0
 //Returns whether o has a descending node with the equator. This can be false
 //if o is hyperbolic and the would-be descending node is within the opening
 //angle of the hyperbola.
 public static bool DescendingNodeEquatorialExists(this Orbit o)
 {
     return(Math.Abs(MuUtils.ClampDegrees180(o.DescendingNodeEquatorialTrueAnomaly())) <= o.MaximumTrueAnomaly());
 }
Beispiel #8
0
 //Returns whether a has a descending node with b. This can be false
 //if a is hyperbolic and the would-be descending node is within the opening
 //angle of the hyperbola.
 public static bool DescendingNodeExists(this Orbit a, Orbit b)
 {
     return(Math.Abs(MuUtils.ClampDegrees180(a.DescendingNodeTrueAnomaly(b))) <= a.MaximumTrueAnomaly());
 }
Beispiel #9
0
 //Gives the true anomaly at which o crosses the equator going southwards, if o is east-moving,
 //or northwards, if o is west-moving.
 //The returned value is always between 0 and 360.
 public static double DescendingNodeEquatorialTrueAnomaly(this Orbit o)
 {
     return(MuUtils.ClampDegrees360(o.AscendingNodeEquatorialTrueAnomaly() + 180));
 }
Beispiel #10
0
 //Gives the true anomaly (in a's orbit) at which a crosses its descending node
 //with b's orbit.
 //The returned value is always between 0 and 360.
 public static double DescendingNodeTrueAnomaly(this Orbit a, Orbit b)
 {
     return(MuUtils.ClampDegrees360(a.AscendingNodeTrueAnomaly(b) + 180));
 }