/// <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); }
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); }
public static float SanitizeValue(this ICurveFunction curve, float value) { return(value.SanitizeAndClamp()); }
public void should_scale_plot_correctly(ICurveFunction curve, float inputValue, float maxValue, float expectedValue) { var actualValue = curve.ScaledPlot(inputValue, maxValue); Assert.Equal(expectedValue, actualValue); }
public static float Random(this IRandomizer randomizer, ICurveFunction curve) { var randomNumber = randomizer.Random(); return(curve.Plot(randomNumber)); }
public static int Random(this IRandomizer randomizer, ICurveFunction curve, int minValue, int maxValue) { return((int)Random(randomizer, curve, minValue, (float)maxValue)); }