Esempio n. 1
0
        public Orbit(double semiMajorAxis, double eccentricity, double argumentOfPeriapsis, double gravParameter, double meanAnomaly, bool prograde)
        {
            _semiMajorAxis       = semiMajorAxis;
            _eccentricity        = eccentricity;
            _argumentOfPeriapsis = argumentOfPeriapsis;
            this.gravParameter   = gravParameter;

            _prograde = prograde;

            this.meanAnomaly = meanAnomaly;
            _trueAnomaly     = OrbitMath.ConvertMeanToTrueElliptic(this.meanAnomaly, _eccentricity);

            meanMotion = System.Math.Sqrt(gravParameter / System.Math.Pow(_semiMajorAxis, 3));

            _periapsis = _semiMajorAxis * (1 - _eccentricity);
            _apoapsis  = _semiMajorAxis * (1 + _eccentricity);
            _radius    = OrbitMath.CalculateRadius(_semiMajorAxis, _eccentricity, _trueAnomaly);

            flightPathAngle = OrbitMath.CalculateFlightpathAngle(_eccentricity, _trueAnomaly);
            _velocity       = OrbitMath.CalculateVelocity(this.gravParameter, _radius, _semiMajorAxis);
        }
Esempio n. 2
0
        public DVector2[] GetSubsets(int count, bool includeFirst = true)
        {
            DVector2[] subsets = new DVector2[count];
            double     step    = 2 * Math.PI / ((double)count - (includeFirst?1:0));

            for (int i = 0; i < count - (includeFirst ? 1 : 0); i++)
            {
                DVector2 pos = new DVector2(OrbitMath.CalculateRadius(_semiMajorAxis, _eccentricity, step * (double)i), 0).Rotate(OrbitMath.ReduceAngle(_argumentOfPeriapsis + step * (double)i));
                subsets[i] = pos;
            }
            if (includeFirst)
            {
                subsets[--count] = subsets[0];
            }
            return(subsets);
        }