 | GeneratorInterpolateTSource Method (IGeneratorTSource, Int32, FuncTSource, TSource, Single, TSource) |
Makes a generator that interpolates between values of a given generator.
Namespace:
Gamelogic.Extensions.Algorithms
Assembly:
Assembly-CSharp (in Assembly-CSharp.dll) Version: 0.0.0.0
Syntaxpublic static IGenerator<TSource> Interpolate<TSource>(
this IGenerator<TSource> generator,
int sampleCount,
Func<TSource, TSource, float, TSource> interpolater
)
Parameters
- generator
- Type: Gamelogic.Extensions.AlgorithmsIGeneratorTSource
The source generator. - sampleCount
- Type: SystemInt32
The sample count per cycle. - interpolater
- Type: SystemFuncTSource, TSource, Single, TSource
The interpolater function. This function takes three arguments: the first
two are the left and right endpoints, and the third is a fraction between 0 and 1. For typical interpolation, the
function must return the left endpoint if this fraction is 0, and the right endpoint if the fraction is 1.
Type Parameters
- TSource
- The type of elements to generate.
Return Value
Type:
IGeneratorTSourceA new generator.
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type
IGeneratorTSource. When you use instance method syntax to call this method, omit the first parameter. For more information, see
Extension Methods (Visual Basic) or
Extension Methods (C# Programming Guide).
Exceptions
Remarks
The expression (x, y, t) => x*(1 - t) + y*t) is standard linear interpolation.
Examplesvar baseGenerator = Generator.Count(2);
var interpolatedGenerator =
baseGenerator.Interpolate(2, (x, y, t) => x*(1 - t) + y*t);
See Also