Example #1
0
        public void ResetClCdCmSteady(Vector3d CoM, InstantConditionSimInput input, out FARCenterQuery center, bool reset_cossweep, bool clear_clcd, bool reset_stall)
        {
            Vector3d velocity, liftDown, sideways, angVel, velVector;

            GetAxisVectors(CoM, input, out velocity, out liftDown, out sideways, out angVel);
            velVector = input.fltenv.VelocityVector(velocity);

            if (reset_cossweep)
            {
                for (int i = 0; i < _wingAerodynamicModel.Count; i++)
                {
                    FARWingAerodynamicModel w = _wingAerodynamicModel[i];
                    if (w == null)
                    {
                        continue;
                    }

                    w.ResetCosSweepAngle();
                }
            }

            for (int i = 0; i < _wingAerodynamicModel.Count; i++)
            {
                FARWingAerodynamicModel w = _wingAerodynamicModel[i];
                if (!(w && w.part))
                {
                    continue;
                }

                w.ComputeForceEditor(velVector, input.fltenv);
            }

            if (clear_clcd)
            {
                for (int i = 0; i < _wingAerodynamicModel.Count; i++)
                {
                    FARWingAerodynamicModel w = _wingAerodynamicModel[i];
                    if (!(w && w.part))
                    {
                        continue;
                    }

                    w.EditorClClear(reset_stall);
                }
            }

            for (int i = 0; i < _wingAerodynamicModel.Count; i++)
            {
                FARWingAerodynamicModel w = _wingAerodynamicModel[i];
                if (!(w && w.part))
                {
                    continue;
                }

                Vector3d relPos = w.GetAerodynamicCenter() - CoM;
                Vector3d vel    = velVector + Vector3d.Cross(angVel, relPos);

                if (w is FARControllableSurface)
                {
                    (w as FARControllableSurface).SetControlStateEditor(CoM, vel, (float)input.pitchValue, 0, 0, input.flaps, input.spoilers);
                }
                else if (w.isShielded)
                {
                    continue;
                }

                w.ComputeForceEditor(vel, input.fltenv);
            }

            center = new FARCenterQuery();
            for (int i = 0; i < _currentAeroSections.Count; i++)
            {
                // Rodhern: The hardcoded 2 for density is replaced, but some other parameters are still rough editor approximations.
                float  reynoldsPerUnitLength = 10000;
                float  pseudoKnudsenNumber   = 0;
                double pseudoLengthScale     = 1;
                float  skinFrictionDrag      = (float)input.fltenv.SkinFrictionDrag(pseudoLengthScale);
                _currentAeroSections[i].PredictionCalculateAeroForces((float)input.fltenv.Rho, (float)input.fltenv.MachNumber,
                                                                      reynoldsPerUnitLength, pseudoKnudsenNumber, skinFrictionDrag,
                                                                      velVector, center);
            }
        }