示例#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
 private static void GenerateMeshOrbitTW(ref MeshFilter meshFilterOrbit, ref bool show, float ejectionAngle, Orbit orbit)
 {
     for (int i = 0; i < 2; i++)
     {
         double num = Math.Abs(Kepler.GetRadius(Kepler.GetSemiLatusRectum(orbit.periapsis, orbit.eccentricity), orbit.eccentricity, (double)(ejectionAngle + (float)i * 0.2f * (float)Math.Sign(orbit.meanMotion)) - orbit.argumentOfPeriapsis));
         if (num > orbit.planet.orbitData.SOI || num > orbit.periapsis * 1.35)
         {
             return;
         }
     }
     Vector3[] array = new Vector3[42];
     for (int j = 0; j < 21; j++)
     {
         float num2 = ejectionAngle + (float)j * 0.01f * (float)Math.Sign(orbit.meanMotion);
         array[j * 2]     = new Vector3(Mathf.Cos(num2), Mathf.Sin(num2), 0f) * (float)(Kepler.GetRadius(Kepler.GetSemiLatusRectum(orbit.periapsis, orbit.eccentricity), orbit.eccentricity, (double)num2 - orbit.argumentOfPeriapsis) / 10000.0);
         array[j * 2 + 1] = array[j * 2] * 0.915f;
     }
     meshFilterOrbit.mesh.vertices = array;
     meshFilterOrbit.mesh.RecalculateNormals();
     meshFilterOrbit.mesh.RecalculateBounds();
     show = true;
 }
示例#3
0
 private bool GenerateLocalTransferWindowMarker(float ejectionAngle, Orbit orbit)
 {
     for (int i = 0; i < 2; i++)
     {
         double num = Math.Abs(Kepler.GetRadius(Kepler.GetSemiLatusRectum(orbit.periapsis, orbit.eccentricity), orbit.eccentricity, (double)(ejectionAngle + (float)i * 0.2f * (float)Math.Sign(orbit.meanMotion)) - orbit.argumentOfPeriapsis));
         if (num > orbit.planet.orbitData.SOI || num > orbit.periapsis * 1.2)
         {
             return(false);
         }
     }
     Vector3[] array = new Vector3[42];
     for (int j = 0; j < 21; j++)
     {
         float num2 = ejectionAngle + (float)j * 0.01f * (float)Math.Sign(orbit.meanMotion);
         array[j * 2]     = new Vector3(Mathf.Cos(num2), Mathf.Sin(num2), 0f) * (float)(Kepler.GetRadius(Kepler.GetSemiLatusRectum(orbit.periapsis, orbit.eccentricity), orbit.eccentricity, (double)num2 - orbit.argumentOfPeriapsis) / 10000.0);
         array[j * 2 + 1] = array[j * 2] * 0.915f;
     }
     this.transferWindow.localMarkerMesh.mesh.vertices = array;
     this.transferWindow.localMarkerMesh.mesh.RecalculateNormals();
     this.transferWindow.localMarkerMesh.mesh.RecalculateBounds();
     return(true);
 }