コード例 #1
0
ファイル: Orbit.cs プロジェクト: TruthfulGnome/SFSModLoader
    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
    private static void UpdateLocalTransferWindowMarker(ref bool show, ref MeshFilter meshFilterOrbit, double ejectionOrbitHeight, Orbit orbit, TransferWindow.Data transferWindow)
    {
        if (transferWindow.departure.type == CelestialBodyData.Type.Star || (transferWindow.transferType == TransferWindow.TransferType.ToNeighbour && transferWindow.departure != transferWindow.firstNeighbour))
        {
            return;
        }
        if (transferWindow.transferType == TransferWindow.TransferType.ToNeighbour || transferWindow.transferType == TransferWindow.TransferType.ToParent)
        {
            CelestialBodyData celestialBodyData = (transferWindow.transferType != TransferWindow.TransferType.ToNeighbour) ? transferWindow.departure : transferWindow.firstNeighbour;
            double            orbitHeightM      = celestialBodyData.orbitData.orbitHeightM;
            double            num        = (transferWindow.transferType != TransferWindow.TransferType.ToNeighbour) ? (transferWindow.target.radius + transferWindow.target.atmosphereData.atmosphereHeightM) : transferWindow.secondNeighbour.orbitData.orbitHeightM;
            double            num2       = Math.Min(num, orbitHeightM);
            double            num3       = (orbitHeightM + num) * 0.5;
            double            e          = 1.0 - num2 / num3;
            double            mass       = celestialBodyData.parentBody.mass;
            double            meanMotion = Kepler.GetMeanMotion(Kepler.GetPeriod(e, num3, mass), e, mass, num3);
            bool   flag           = num > orbitHeightM;
            double magnitude2d    = Kepler.GetVelocity(num3, orbitHeightM, meanMotion, (!flag) ? 3.1415926535897931 : 0.0, (!flag) ? 3.1415926535897931 : 0.0, e, 0.0).magnitude2d;
            double escapeVelocity = magnitude2d - -celestialBodyData.orbitData.orbitalVelocity;
            float  num4           = (float)(Kepler.GetEjectionAngle(escapeVelocity, ejectionOrbitHeight, celestialBodyData.mass, celestialBodyData.orbitData.SOI) * (double)Math.Sign(-orbit.meanMotion) + ((!flag) ? 3.1415926535897931 : 0.0));
            float  ejectionAngle  = num4 + (float)(Ref.controller.globalTime * celestialBodyData.orbitData._meanMotion) - 1.57079637f;
            TransferWindow.GenerateMeshOrbitTW(ref meshFilterOrbit, ref show, ejectionAngle, orbit);
            return;
        }
        if (transferWindow.transferType != TransferWindow.TransferType.ToSatellite)
        {
            return;
        }
        if (ejectionOrbitHeight > transferWindow.target.orbitData.orbitHeightM * 0.75)
        {
            return;
        }
        float num5           = (float)Kepler.GetPhaseAngle(ejectionOrbitHeight, transferWindow.target.orbitData.orbitHeightM);
        float ejectionAngle2 = num5 + (float)(Ref.controller.globalTime * transferWindow.target.orbitData._meanMotion);

        TransferWindow.GenerateMeshOrbitTW(ref meshFilterOrbit, ref show, ejectionAngle2, orbit);
    }