Пример #1
0
    public Orbit(Double3 posIn, Double3 velIn, double timeIn, CelestialBodyData planet, CelestialBodyData lastPlanet)
    {
        this.planet = planet;
        this.timeIn = timeIn;
        double  mass    = planet.mass;
        Double3 b       = Double3.Cross2d(posIn, velIn);
        Double3 @double = Double3.Cross(velIn, b) / mass - posIn.normalized2d;

        this.eccentricity        = @double.magnitude2d;
        this.argumentOfPeriapsis = Math.Atan2(@double.y, @double.x);
        this.semiMajorAxis       = -mass / (2.0 * (Math.Pow(velIn.magnitude2d, 2.0) / 2.0 - mass / posIn.magnitude2d));
        this.periapsis           = this.semiMajorAxis * (1.0 - this.eccentricity);
        this.apoapsis            = ((this.eccentricity >= 1.0) ? double.PositiveInfinity : (this.semiMajorAxis * (1.0 + this.eccentricity)));
        this.semiLatusRectum     = Kepler.GetSemiLatusRectum(this.periapsis, this.eccentricity);
        this._period             = Kepler.GetPeriod(this.eccentricity, this.semiMajorAxis, mass);
        this.meanMotion          = Kepler.GetMeanMotion(this._period, this.eccentricity, mass, this.semiMajorAxis) * (double)Math.Sign(b.z);
        double trueAnomalyAtRadius = Kepler.GetTrueAnomalyAtRadius(posIn.magnitude2d, this.semiLatusRectum, this.eccentricity);
        double num = Kepler.GetMeanAnomaly(this.eccentricity, trueAnomalyAtRadius, posIn, this.argumentOfPeriapsis) / this.meanMotion;

        if (this.apoapsis > planet.orbitData.SOI || this.eccentricity >= 1.0)
        {
            this._period = 0.0;
        }
        this.periapsisPassageTime = timeIn + num - this._period * 10.0;
        this.GetOrbitType(timeIn, lastPlanet);
        this.stopTimeWarpTime = this.GetStopTimeWarpTime();
    }
Пример #2
0
    public double GetPassAnomaly(double height)
    {
        double trueAnomalyAtRadius = Kepler.GetTrueAnomalyAtRadius(height, this.semiLatusRectum, this.eccentricity);
        double meanAnomaly         = Kepler.GetMeanAnomaly(this.eccentricity, trueAnomalyAtRadius);

        return(Math.Abs(meanAnomaly / this.meanMotion));
    }
Пример #3
0
    public double GetLastTrueAnomalyPassageTime(double referenceTime, double trueAnomaly)
    {
        double num = this.periapsisPassageTime + Kepler.GetMeanAnomaly(this.eccentricity, trueAnomaly) / this.meanMotion;

        if (this.orbitType != Orbit.Type.Escape)
        {
            return(num + (double)((int)((referenceTime - num) / this._period)) * this._period);
        }
        return(num);
    }