Public
Edited
Jun 9, 2024
1 fork
6 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
interp = {
const controlPoints = [[-5, -4], [-18, 1], [-12, 4], [5, -3], [3, 3], [16, -3]];
const options = {
tension: 0, // default 0.5
alpha: 0.5, // default 0
closed: false, // default false
};
const lerp = new CurveInterpolator(controlPoints, options);

return lerp;
}
Insert cell
Insert cell
interp.getPointAt(0.25)
Insert cell
Insert cell
interp.getPoints(10) // using default values gives a list of points as arrays and along the full curve (position 0 to 1)
Insert cell
interp.getPoints(10, lib.Point, 0.25, 0.75) // here we pass in a type for the return type that implements VectorType and also give it a range
Insert cell
Insert cell
interp.getTangentAt(0.25)
Insert cell
Insert cell
interp.getNormalAt(0.25)
Insert cell
Insert cell
interp.getDerivativeAt(0.25)
Insert cell
Insert cell
interp.getSecondDerivativeAt(0.25)
Insert cell
Insert cell
interp.getCurvatureAt(0.25)
Insert cell
Insert cell
Insert cell
Insert cell
interp.getNearestPosition([2, 5])
Insert cell
Insert cell
Insert cell
Insert cell
interp.getBoundingBox()
Insert cell
Insert cell
Insert cell
Insert cell
interp.getIntersects(-10, 0)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
interp.getTimeFromPosition(0.25)
Insert cell
Insert cell
interp.getPositionFromTime(0.25)
Insert cell
Insert cell
interp.getPositionFromLength(50) // the position at 50 units
Insert cell
Insert cell
interp.length
Insert cell
Insert cell
interp.getLengthAt(0.25) // quarter of the total curve length
Insert cell
Insert cell
interp.getPositionAtKnot(2)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
lib = require('curve-interpolator@3.3.0')
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more