Interface IResponseCurve<T>
- Namespace
- Gamelogic.Extensions.Algorithms
- Assembly
- Assembly-CSharp.dll
This interface represents a piecewise linear curve, with input-output pairs at the bends. Outputs can be any type for which continuous interpolation makes sense.
public interface IResponseCurve<out T>
Type Parameters
T
The number type of the input and output, usually float or double, but anything that can be interpolated (such as vectors and colors) is possible.
- Extension Methods
Remarks
This class is the base of the that described in AI Programming Wisdom 1, "The Beauty of Response Curves", by Bob Alexander.
The inputs need not be spread uniformly.
Properties
this[float]
Evaluates the curve at the given input and returns the result.
T this[float input] { get; }
Parameters
input
floatThe input for which output is sought.
Property Value
- T
Remarks
If the input is below the inputMin given in the constructor, the output is clamped to the first output sample.
If the input is above the inputMax given in the constructor, the output is clamped to the last output sample.
Otherwise, an index is calculated, and the output is interpolated
between outputSample[index]
and outputSample[index + 1]
.
Methods
Evaluate(float)
Evaluates the curve at the given input and returns the result.
T Evaluate(float input)
Parameters
input
floatThe input for which output is sought.
Returns
- T
Remarks
If the input is below the inputMin given in the constructor, the output is clamped to the first output sample.
If the input is above the inputMax given in the constructor, the output is clamped to the last output sample.
Otherwise, an index is calculated, and the output is interpolated
between outputSample[index]
and outputSample[index + 1]
.