cubic-hermite-spline
v1.0.1
Published
Cubic Hermite spline interpolation
Maintainers
Readme
cubic-hermite-spline
Cubic Hermite spline interpolation
Cubic Hermite spline interpolation of points / tangeants in any dimension with optional derivative computation. The interpolator can also take a knot-like vector as an optional parameter, which may be useful to enforce time at control points when used for position / velocity interpolation.
Install
$ npm install cubic-hermite-splineExample
Basic usage
var hermite = require('cubic-hermite-spline');
var points = [
[-1, 0],
[ 0, 0],
[ 1, 0]
];
var tangents = [
[1, 1],
[0, 1],
[1, 1]
];
for(var t=0; t<1; t+=0.01) {
var point = hermite(t, points, tangents);
var tangent = hermite(t, points, tangents, null, true);
}With a knot vector
var hermite = require('cubic-hermite-spline');
var points = [
[-1, 0],
[ 0, 0],
[ 1, 0]
];
var tangents = [
[1, 1],
[0, 1],
[1, 1]
];
var knots = [
0, 1.5, 2
];
for(var t=0; t<1; t+=0.01) {
var point = hermite(t, points, tangents);
var tangent = hermite(t, points, tangents, knots, true);
}Usage
hermite(t, points, tangents[, knots, derivative, result])
Computes the interpolation at t for the provided set of points and tangents, and optional knots.
tposition along the curve: in the [0, 1] range for regular use, and [0, last-knot-value] when using knotspointsvectors to interpolatetangentstangents at provided pointsknotsenforced values oftat provided pointsderivativeif true return the tangeant attinstead of the positionresultpreallocated array in which the result will be stored (avoid GC)
Returns the interpolated vector
