예제 #1
0
        public EnvelopePoint(AeroPredictor vessel, CelestialBody body, float altitude, float speed, float AoA_guess = float.NaN, float maxA_guess = float.NaN, float pitchI_guess = float.NaN)
        {
            this.altitude = altitude;
            this.speed    = speed;
            AeroPredictor.Conditions conditions = new AeroPredictor.Conditions(body, speed, altitude);
            float gravParameter, radius;

            gravParameter        = (float)body.gravParameter;
            radius               = (float)body.Radius;
            this.mach            = conditions.mach;
            this.dynamicPressure = 0.0005f * conditions.atmDensity * speed * speed;
            float   weight = (vessel.Mass * gravParameter / ((radius + altitude) * (radius + altitude))) - (vessel.Mass * speed * speed / (radius + altitude));
            Vector3 thrustForce = vessel.GetThrustForce(conditions);

            fuelBurnRate = vessel.GetFuelBurnRate(conditions);
            //AoA_max = vessel.GetMaxAoA(conditions, out Lift_max, maxA_guess);
            if (float.IsNaN(maxA_guess))
            {
                AoA_max = vessel.GetMaxAoA(conditions, out Lift_max, maxA_guess);
                //Lift_max = AeroPredictor.GetLiftForceMagnitude(vessel.GetAeroForce(conditions, AoA_max, 1) + thrustForce, AoA_max);
            }
            else
            {
                AoA_max  = maxA_guess;
                Lift_max = AeroPredictor.GetLiftForceMagnitude(vessel.GetAeroForce(conditions, AoA_max, 1) + thrustForce, AoA_max);
            }

            AoA_level = vessel.GetAoA(conditions, weight, guess: AoA_guess, pitchInputGuess: 0, lockPitchInput: true);
            if (AoA_level < AoA_max)
            {
                pitchInput = vessel.GetPitchInput(conditions, AoA_level, guess: pitchI_guess);
            }
            else
            {
                pitchInput = 1;
            }

            if (speed < 5 && Math.Abs(altitude) < 10)
            {
                AoA_level = 0;
            }

            Thrust_available = thrustForce.magnitude;

            //vessel.GetAeroCombined(conditions, AoA_level, pitchInput, out force, out Vector3 torque);
            force     = vessel.GetAeroForce(conditions, AoA_level, pitchInput);
            aeroforce = AeroPredictor.ToFlightFrame(force, AoA_level); //vessel.GetLiftForce(body, speed, altitude, AoA_level, mach, atmDensity);
            drag      = -aeroforce.z;
            float lift = aeroforce.y;

            Thrust_excess = -drag - AeroPredictor.GetDragForceMagnitude(thrustForce, AoA_level);
            if (weight > Lift_max)// AoA_level >= AoA_max)
            {
                Thrust_excess = Lift_max - weight;
                AoA_level     = AoA_max;
            }
            Accel_excess = (Thrust_excess / vessel.Mass / WindTunnelWindow.gAccel);
            LDRatio      = Math.Abs(lift / drag);
            dLift        = (vessel.GetLiftForceMagnitude(conditions, AoA_level + WindTunnelWindow.AoAdelta, pitchInput) - lift)
                           / (WindTunnelWindow.AoAdelta * Mathf.Rad2Deg);
            //stabilityDerivative = (vessel.GetAeroTorque(conditions, AoA_level + WindTunnelWindow.AoAdelta, pitchInput).x - torque.x)
            //    / (WindTunnelWindow.AoAdelta * Mathf.Rad2Deg);
            //GetStabilityValues(vessel, conditions, AoA_level, out stabilityRange, out stabilityScore);

            completed = true;
        }