Method | Description | |
---|---|---|
getSplinePoints ( $source, array $args = [] ) : array | Determine where the input $source argument is a callback function, a set of arrays, or neither. If $source is a callback function, run it through the functionToPoints() method with the input $args, and set $points to output array. If $source is a set of arrays, simply set $points to $source. If $source is neither, throw an Exception. | |
interpolate ( $source, $args ) : |
Interpolate | |
validateSpline ( array $points, number $degree = 2 ) : boolean | Validate that there are enough input arrays (points), that each point array has precisely three numbers, and that no two points share the same first number (x-component) |
Method | Description | |
---|---|---|
functionToSplinePoints ( callable $function, callable $derivative, number $start, number $end, number $n ) : array | Evaluate our callback function and derivative at n evenly spaced points on the interval between start and end |
protected static functionToSplinePoints ( callable $function, callable $derivative, number $start, number $end, number $n ) : array | ||
$function | callable | f(x) callback function |
$derivative | callable | f'(x) callback function |
$start | number | the start of the interval |
$end | number | the end of the interval |
$n | number | the number of function evaluations |
return | array |
public static getSplinePoints ( $source, array $args = [] ) : array | ||
$source | The source of our approximation. Should be either a callback function or a set of arrays. | |
$args | array | The arguments of our callback function: derivative, start, end, and n. Example: [$derivative, 0, 8, 5]. If $source is a set of arrays, $args will default to []. |
return | array |
public static interpolate ( $source, $args ) : |
||
$source | The source of our approximation. Should be either a callback function or a set of arrays. Each array (point) contains precisely three numbers: x, y, and y' Example array: [[1,2,1], [2,3,0], [3,4,2]]. Example callback: function($x) {return $x**2;} | |
return | The interpolting (piecewise) polynomial, as an instance of Piecewise. |