Ejemplo n.º 1
0
        /// <summary>
        /// This will take the value and normalize it based off the maxValue then plot it and denormalize it
        /// </summary>
        /// <param name="curve">Curve type to use</param>
        /// <param name="value">The value to be normalized and plotted</param>
        /// <param name="maxValue">The maximum value used when scaling</param>
        /// <returns>The denormalized value from the curve</returns>
        public static float ScaledPlot(this ICurveFunction curve, float value, float maxValue)
        {
            var normalizedValue  = (value + float.Epsilon) / maxValue;
            var normalizedOutput = curve.Plot(normalizedValue);

            return(normalizedOutput * maxValue);
        }
Ejemplo n.º 2
0
        public static float Random(this IRandomizer randomizer, ICurveFunction curve, float minValue, float maxValue)
        {
            var randomNumber = randomizer.Random(minValue, maxValue);
            var isNegative   = minValue < 0;

            if (isNegative)
            {
                randomNumber = Math.Abs(randomNumber);
                maxValue     = Math.Abs(minValue);
            }

            var result = curve.ScaledPlot(randomNumber, maxValue);

            return(isNegative ? -result : result);
        }
Ejemplo n.º 3
0
 public static float SanitizeValue(this ICurveFunction curve, float value)
 {
     return(value.SanitizeAndClamp());
 }
Ejemplo n.º 4
0
    public void should_scale_plot_correctly(ICurveFunction curve, float inputValue, float maxValue, float expectedValue)
    {
        var actualValue = curve.ScaledPlot(inputValue, maxValue);

        Assert.Equal(expectedValue, actualValue);
    }
Ejemplo n.º 5
0
        public static float Random(this IRandomizer randomizer, ICurveFunction curve)
        {
            var randomNumber = randomizer.Random();

            return(curve.Plot(randomNumber));
        }
Ejemplo n.º 6
0
 public static int Random(this IRandomizer randomizer, ICurveFunction curve, int minValue, int maxValue)
 {
     return((int)Random(randomizer, curve, minValue, (float)maxValue));
 }