Ejemplo n.º 1
0
        /// <summary>
        /// Calculates weighted sum of two values.
        /// The values are not directly provided.
        /// Delegates that calculate the values are provided instead.
        /// The values are not calculated if they have zero weight.
        /// </summary>
        /// <param name="x">The delegate that calculates the first value.</param>
        /// <param name="xWeight">The weight of the first value.</param>
        /// <param name="y">The delegate that calculates the second value.</param>
        /// <param name="yWeight">The weight of the second value.</param>
        /// <returns>The weighted sum.</returns>
        public static float GetWeightedSum(
            FloatValueSource x,
            float xWeight,
            FloatValueSource y,
            float yWeight)
        {
            if (xWeight == 0)
            {
                if (yWeight == 0)
                {
                    return(0);
                }

                return(y());
            }

            if (yWeight == 0)
            {
                return(x());
            }

            return(GetWeightedSum(x(), xWeight, y(), yWeight));
        }
Ejemplo n.º 2
0
 public FloatValueSourceMB()
 {
     variable = (variable ?? new FloatValueSource());
 }
 public void SetFloatValue(int index, FloatValueSource value)
 {
     _floatInputs[index]._valueSource = value;
 }