Пример #1
0
 public float TTB(float dV, float throttle = -1)
 {
     if (throttle < 0)
     {
         throttle = ThrottleControl.NextThrottle(dV, 1, VSL);
     }
     return(TTB(dV, MaxThrustM, MaxMassFlow, throttle));
 }
Пример #2
0
 public float AntigravTTB(float vertical_V, float throttle = -1)
 {
     if (throttle < 0)
     {
         throttle = ThrottleControl.NextThrottle(vertical_V, 1, VSL);
     }
     return(VSL.Engines.TTB(vertical_V,
                            Utils.ClampL(MaxThrustM - VSL.Physics.StG * VSL.Physics.M, 1e-5f),
                            MaxMassFlow, throttle));
 }
Пример #3
0
        public static float BrakeDistance(float V0, VesselWrapper VSL, out float ttb)
        {
            ttb = VSL.Engines.TTB(V0);
            var throttle = ThrottleControl.NextThrottle((float)V0, 1, VSL);

            if (CheatOptions.InfinitePropellant)
            {
                return((V0 - VSL.Engines.MaxThrustM * throttle * ttb / 2 / VSL.Physics.M) * ttb);
            }
            return(V0 * ttb +
                   VSL.Engines.MaxThrustM / VSL.Engines.MaxMassFlow *
                   ((ttb - VSL.Physics.M / VSL.Engines.MaxMassFlow / throttle) *
                    Mathf.Log((VSL.Physics.M - VSL.Engines.MaxMassFlow * throttle * ttb) / VSL.Physics.M) - ttb));
        }
Пример #4
0
        public float TTB_Precise(float dV)
        {
            var ttb      = 0f;
            var mass     = VSL.Physics.M;
            var throttle = ThrottleControl.NextThrottle(dV, 1, mass, MaxThrustM, DecelerationTime10);

            while (dV > 0.1)
            {
                throttle = ThrottleControl.NextThrottle(dV, throttle, mass, MaxThrustM, DecelerationTime10);
                dV      /= 2;
                ttb     += TTB(dV, MaxThrustM, mass, MaxMassFlow, throttle, out mass);
            }
            throttle = ThrottleControl.NextThrottle(dV, throttle, mass, MaxThrustM, DecelerationTime10);
            return(ttb + TTB(dV, MaxThrustM, mass, MaxMassFlow, throttle, out mass));
        }
Пример #5
0
        public static float BrakeDistancePrecise(float V0, VesselWrapper VSL, out float ttb)
        {
            ttb = 0f;
            var   dist     = 0f;
            var   mass     = VSL.Physics.M;
            var   throttle = ThrottleControl.NextThrottle(V0, 1, mass, VSL.Engines.MaxThrustM, VSL.Engines.DecelerationTime10);
            float next_mass;
            float ttb_cur;

            while (V0 > 0.1)
            {
                throttle = ThrottleControl.NextThrottle(V0, throttle, mass, VSL.Engines.MaxThrustM, VSL.Engines.DecelerationTime10);
                ttb_cur  = EnginesProps.TTB(V0 / 2, VSL.Engines.MaxThrustM, mass, VSL.Engines.MaxMassFlow, throttle, out next_mass);
                dist    += BrakeDistance(V0, ttb_cur, VSL.Engines.MaxThrustM, mass, VSL.Engines.MaxMassFlow, throttle);
                ttb     += ttb_cur;
                mass     = next_mass;
                V0      /= 2;
            }
            throttle = ThrottleControl.NextThrottle(V0, throttle, mass, VSL.Engines.MaxThrustM, VSL.Engines.DecelerationTime10);
            ttb_cur  = EnginesProps.TTB(V0, VSL.Engines.MaxThrustM, mass, VSL.Engines.MaxMassFlow, throttle, out next_mass);
            dist    += BrakeDistance(V0, ttb_cur, VSL.Engines.MaxThrustM, mass, VSL.Engines.MaxMassFlow, throttle);
            ttb     += ttb_cur;
            return(dist);
        }
 public static float BrakingDistance(float V0, VesselWrapper VSL, out float ttb)
 {
     return(BrakingDistance(V0, VSL.Engines.MaxThrustM, VSL.Engines.MaxMassFlow,
                            ThrottleControl.NextThrottle((float)V0, 1, VSL),
                            VSL, out ttb));
 }
Пример #7
0
        public double FromSurfaceTTA(double ApA, double alpha, double gturn_curve, double surface_vel)
        {
            var t      = 0.0;
            var v      = new Vector3d(0, surface_vel);
            var h      = (double)VSL.Altitude.Absolute;
            var m      = (double)VSL.Physics.M;
            var eStats = VSL.Engines.NoActiveEngines?
                         VSL.Engines.GetNearestEnginedStageStats() :
                         VSL.Engines.GetEnginesStats(VSL.Engines.Active);
            var mT    = eStats.MaxThrust;
            var mflow = eStats.MaxMassFlow;
            var mTm   = mT.magnitude * Mathfx.Lerp(0.6, 0.95, Utils.ClampH(
                                                       VSL.Torque.AngularAcceleration(eStats.TorqueInfo.Torque + VSL.Torque.RCSLimits.Max + VSL.Torque.WheelsLimits.Max).magnitude, 1));
            var s        = VSL.Geometry.AreaInDirection(mT);
            var R        = Body.Radius;
            var thrust   = true;
            var throttle = 1.0;

//			var alpha0 = alpha; //debug
            while (v.x >= 0)
            {
                var atmF = Utils.Clamp(h / Body.atmosphereDepth, 0, 1);
                if (thrust)
                {
                    double apaT;
                    var    apa  = freeclimb_altitude(m, s, h, v.x, v.y, DeltaTime * 4, out apaT);
                    var    dapa = (ApA - apa) * gturn_curve;
                    var    arc  = (alpha - v.y * apaT / (R + (h + apa) / 2)) * (R + apa);
                    var    vv   = Utils.ClampL(dapa, 0);
                    var    hv   = Utils.ClampL(arc - dapa, 0) * Utils.Clamp((h - VSL.Altitude.Absolute) / GLB.ORB.GTurnOffset, 0, 1);
                    if (h < Body.atmosphereDepth)
                    {
                        hv *= Math.Sqrt(atmF);
                    }
                    var angle = Math.Atan2(vv, hv);
                    throttle = ThrottleControl.NextThrottle((float)(Math.Sqrt(vv * vv + hv * hv) * Globals.Instance.ORB.Dist2VelF * VSL.Physics.StG / Utils.G0),
                                                            (float)throttle, (float)m, (float)mTm, 0);
                    var v_throttle = Math.Sin(angle);
                    v.x += (mTm * v_throttle * throttle / m - G(h, v.y)) * DeltaTime;
                    var h_throttle = 0.0;
                    if (arc > 0)
                    {
                        h_throttle = Math.Cos(angle);
                        v.y       += (mTm * h_throttle * throttle / m) * DeltaTime;
                    }
                    thrust = ApA - apa > GLB.ORB.Dtol && arc > GLB.ORB.Dtol;
                    if (!CheatOptions.InfinitePropellant)
                    {
                        var dm = mflow * (h_throttle + v_throttle) * throttle * DeltaTime;
                        if (m < dm)
                        {
                            thrust = false; continue;
                        }
                        m -= dm;
                    }
//					Utils.Log("apaT {}, dapa {}, arc {}, throttle {}, h-thr {}, v-thr {}", apaT, dapa, arc, throttle);//debug
                }
                else
                {
                    v.x -= G(h, v.y) * DeltaTime;
                }
                if (h < Body.atmosphereDepth)
                {
                    var y  = v.y - surface_vel * (1 - atmF);
                    var vm = Math.Sqrt(v.x * v.x + y * y);
                    var D  = drag(s, h, vm) / m * DeltaTime / vm;
                    v.x -= v.x * D;
                    v.y -= y * D;
                }
                alpha -= v.y * DeltaTime / Body.Radius;
                h     += v.x * DeltaTime;
                t     += DeltaTime;
//				Utils.Log("v.v {}, v.h {}, drag {}, h {}, hmove {}", v.x, v.y, drag(s, h, vm)/m, h, hmove);//debug
//				DebugUtils.CSV("LambertSolver", t, v.x, v.y, (alpha0-alpha)*(R+h), h, m, mTm*throttle, throttle, Math.Atan2(v.x, v.y)*Mathf.Rad2Deg);//debug
            }
            return(t - DeltaTime / 2);
        }
Пример #8
0
 public float TTB(float dV)
 {
     return(TTB(dV, MaxThrustM, MaxMassFlow, ThrottleControl.NextThrottle(dV, 1, VSL)));
 }