CompletePiecewiseLinearFunction¶
Overview¶
Describes a 1d complete (fully defined for any number) function, where values are extrapolated given the final end points.
E.g. if the points (0,0) and (1,1) are provided, it represents the function f(x) = x for ALL values, especially values outside of the range [0,1]. For example, f(6) = 6.
If a single point is provided, it represents a constant function.
@author Jonathan Olson <jonathan.olson@colorado.edu>
Class CompletePiecewiseLinearFunction¶
Constructor¶
new CompletePiecewiseLinearFunction( points : Vector2[] )¶
Instance Methods¶
findMatchingPair( x : number ) : [ Vector2, Vector2 ]¶
Returns the pair of points that the x value is defined by.
NOTE: x may NOT be contained in these points, if it's either less than or greater than any points in the points list.
evaluate( x : number ) : number¶
Evaluates the function at the given x value, e.g. returns f(x).
plus( linearFunction : CompletePiecewiseLinearFunction ) : CompletePiecewiseLinearFunction¶
Returns a CompletePiecewiseLinearFunction that's the result of adding the two functions.
minus( linearFunction : CompletePiecewiseLinearFunction ) : CompletePiecewiseLinearFunction¶
Returns a CompletePiecewiseLinearFunction that's the result of subtracting the two functions.
min( linearFunction : CompletePiecewiseLinearFunction ) : CompletePiecewiseLinearFunction¶
Returns a CompletePiecewiseLinearFunction that's the result of taking the minimum of the two functions
max( linearFunction : CompletePiecewiseLinearFunction ) : CompletePiecewiseLinearFunction¶
Returns a CompletePiecewiseLinearFunction that's the result of taking the maximum of the two functions
withXValues( xValues : number[] ) : CompletePiecewiseLinearFunction¶
Allows redefining or clamping/truncating the function by only representing it from the given x values
inverted() : CompletePiecewiseLinearFunction¶
Returns an inverted form of the function (assuming it is monotonically increasing or monotonically decreasing)
Instance Properties¶
points : Vector2[]¶
Static Methods¶
sum( ...functions : CompletePiecewiseLinearFunction[] ) : CompletePiecewiseLinearFunction¶
min( ...functions : CompletePiecewiseLinearFunction[] ) : CompletePiecewiseLinearFunction¶
max( ...functions : CompletePiecewiseLinearFunction[] ) : CompletePiecewiseLinearFunction¶
constant( y : number ) : CompletePiecewiseLinearFunction¶
linear( a : number, b : number ) : CompletePiecewiseLinearFunction¶
Represents the function ax+b
Source Code¶
See the source for CompletePiecewiseLinearFunction.ts in the dot repository.