Exemple #1
0
            public VelPoint(AeroPredictor vessel, CelestialBody body, float altitude, float speed)
            {
                this.altitude = altitude;
                this.speed    = speed;
                AeroPredictor.Conditions conditions = new AeroPredictor.Conditions(body, speed, altitude);
                float gravParameter, radius;

                lock (body)
                {
                    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);

                AoA_max          = vessel.GetMaxAoA(conditions, out Lift_max);
                AoA_level        = Mathf.Min(vessel.GetAoA(conditions, weight), AoA_max);
                pitchInput       = vessel.GetPitchInput(conditions, AoA_level);
                Thrust_available = thrustForce.magnitude;
                Vector3 force = vessel.GetAeroForce(conditions, AoA_level, pitchInput);

                drag          = AeroPredictor.GetDragForceMagnitude(force, AoA_level);
                Thrust_excess = -drag - AeroPredictor.GetDragForceMagnitude(thrustForce, AoA_level);
                Accel_excess  = Thrust_excess / vessel.Mass / WindTunnelWindow.gAccel;
                LDRatio       = Mathf.Abs(AeroPredictor.GetLiftForceMagnitude(force, AoA_level) / drag);
                dLift         = (vessel.GetLiftForceMagnitude(conditions, AoA_level + WindTunnelWindow.AoAdelta, pitchInput) -
                                 vessel.GetLiftForceMagnitude(conditions, AoA_level, pitchInput)) / (WindTunnelWindow.AoAdelta * Mathf.Rad2Deg);
            }
            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;

                lock (body)
                {
                    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))); // TODO: Minus centrifugal force...
                Vector3 thrustForce = vessel.GetThrustForce(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);
                }
                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;
                }

                Thrust_available = thrustForce.magnitude;
                force            = vessel.GetAeroForce(conditions, AoA_level, pitchInput);
                liftforce        = AeroPredictor.ToFlightFrame(force, AoA_level); //vessel.GetLiftForce(body, speed, altitude, AoA_level, mach, atmDensity);
                drag             = AeroPredictor.GetDragForceMagnitude(force, AoA_level);
                float lift = AeroPredictor.GetLiftForceMagnitude(force, AoA_level);

                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      = Mathf.Abs(lift / drag);
                dLift        = (vessel.GetLiftForceMagnitude(conditions, AoA_level + WindTunnelWindow.AoAdelta, pitchInput) -
                                vessel.GetLiftForceMagnitude(conditions, AoA_level, pitchInput)) / (WindTunnelWindow.AoAdelta * Mathf.Rad2Deg);
            }
        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;
        }