Click or drag to resize

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
Syntax
C#
public 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: IGeneratorTSource
A 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
ExceptionCondition
ArgumentNullExceptiongenerator is $(null).
ArgumentOutOfRangeExceptionsampleCount not positive.
ArgumentNullExceptioninterpolater is $(null).
Remarks
The expression (x, y, t) => x*(1 - t) + y*t) is standard linear interpolation.
Examples
var baseGenerator = Generator.Count(2); //Generates 0 1 0 1 0 1...
var interpolatedGenerator = 
    baseGenerator.Interpolate(2, (x, y, t) => x*(1 - t) + y*t); //Generates 0 0.5f 1 0.5f 0 0.5f....
See Also