private void UpdateUpstreamValuesFromWingModules(List <FARWingAerodynamicModel> wingModules, List <double> associatedInfluences, double directionalInfluence, double thisWingAoA)
        {
            for (int i = 0; i < wingModules.Count; i++)
            {
                FARWingAerodynamicModel wingModule = wingModules[i];
                double wingInfluenceFactor         = associatedInfluences[i] * directionalInfluence;

                double tmp = Vector3.Dot(wingModule.transform.forward, parentWingModule.transform.forward);

                effectiveUpstreamMAC  += wingModule.GetMAC() * wingInfluenceFactor;
                effectiveUpstreamb_2  += wingModule.Getb_2() * wingInfluenceFactor;
                effectiveUpstreamArea += wingModule.S * wingInfluenceFactor;

                effectiveUpstreamLiftSlope     += wingModule.GetLiftSlope() * wingInfluenceFactor;
                effectiveUpstreamStall         += wingModule.GetStall() * wingInfluenceFactor;
                effectiveUpstreamCosSweepAngle += wingModule.GetCosSweepAngle() * wingInfluenceFactor;
                effectiveUpstreamAoAMax        += wingModule.AoAmax * wingInfluenceFactor;
                effectiveUpstreamCd0           += wingModule.GetCd0() * wingInfluenceFactor;
                effectiveUpstreamInfluence     += wingInfluenceFactor;

                double wAoA = wingModule.CalculateAoA(wingModule.GetVelocity()) * Math.Sign(tmp);
                tmp = (thisWingAoA - wAoA) * wingInfluenceFactor;                //First, make sure that the AoA are wrt the same direction; then account for any strange angling of the part that shouldn't be there

                effectiveUpstreamAoA += tmp;
            }
        }
        //Returns the tinted color if active; else it returns an alpha 0 color
        private Color AeroVisualizationTintingCalculation(AeroVisualizationGUI aeroVizGUI)
        {
            // Disable tinting for low dynamic pressure to prevent flicker
            if (vessel.dynamicPressurekPa <= 0.00001)
            {
                return(new Color(0, 0, 0, 0));
            }

            // Stall tinting overrides Cl / Cd tinting
            if (legacyWingModel != null && aeroVizGUI.TintForStall)
            {
                return(new Color((float)((legacyWingModel.GetStall() * 100.0) / aeroVizGUI.FullySaturatedStall), 0f, 0f, 0.5f));
            }

            if (!aeroVizGUI.TintForCl && !aeroVizGUI.TintForCd)
            {
                return(new Color(0, 0, 0, 0));
            }

            double visualizationCl = 0, visualizationCd = 0;

            if (projectedArea.totalArea > 0.0)
            {
                Vector3 worldVelNorm   = partTransform.localToWorldMatrix.MultiplyVector(partLocalVelNorm);
                Vector3 worldDragArrow = Vector3.Dot(totalWorldSpaceAeroForce, worldVelNorm) * worldVelNorm;
                Vector3 worldLiftArrow = totalWorldSpaceAeroForce - worldDragArrow;

                double invAndDynPresArea = legacyWingModel != null ? legacyWingModel.S : projectedArea.totalArea;
                invAndDynPresArea *= vessel.dynamicPressurekPa;
                invAndDynPresArea  = 1 / invAndDynPresArea;
                visualizationCl    = worldLiftArrow.magnitude * invAndDynPresArea;
                visualizationCd    = worldDragArrow.magnitude * invAndDynPresArea;
            }

            double fullSatCl = 0, satCl = 0, fullSatCd = 0, satCd = 0;

            if (legacyWingModel != null)
            {
                fullSatCl = aeroVizGUI.FullySaturatedCl;
                fullSatCd = aeroVizGUI.FullySaturatedCd;
            }
            else
            {
                fullSatCl = aeroVizGUI.FullySaturatedClBody;
                fullSatCd = aeroVizGUI.FullySaturatedCdBody;
            }

            if (aeroVizGUI.TintForCl)
            {
                satCl = Math.Abs(visualizationCl / fullSatCl);
            }
            if (aeroVizGUI.TintForCd)
            {
                satCd = Math.Abs(visualizationCd / fullSatCd);
            }

            return(new Color((float)satCd, 0.5f * (float)(satCl + satCd), (float)satCl, 0.5f));
        }
        private void CalculateStallFraction()
        {
            for (int i = 0; i < _LEGACY_currentWingAeroModel.Count; i++)
            {
                FARWingAerodynamicModel w = _LEGACY_currentWingAeroModel[i];
                vesselInfo.stallFraction += w.GetStall() * w.S;
            }

            vesselInfo.stallFraction /= wingArea;
        }