Release 3.1.0
A complete re-write of the library for a better developer experience, improved performance and of course, some new features.
New features:
- get curvature at any point or time along the curve
- get nearest position on curve from a given point
- get normal and tangent at any point or time
- convenience functions added to get position or time at knot points
- convenience functions added for mapping between position (u) and time (t)
- convenience functions added for mapping between length and normalized length/position (u)
- convenience functions added for iterating over a range of the curve (map, reduce and forEach)
- numerical integral method now used as default for calculating length and mapping between time and position (if arcDivisions option = 0 or not provided)
- improved performance and accuracy
Some existing functions are still available, but marked as deprecated and put into the legacy folder in the source code. These will be removed from the library shortly.
As this is a rewrite of the library from the ground up, there are a a few breaking changes to be aware of:
- CurveInterpolator.getT is now named CurveInterpolator.getTimeFromPosition
- CurveInterpolator.lookup is now named CurveInterpolator.getIntersects
- CurveInterpolator.lookupPositions is now named CurveInterpolator.getIntersectsAsPositions
If you used any of the old core functions, like getPointAtT , getTangentAtT etc. you should now instantiate and use the CurveInterpolator class. The reason for this is to allow caching of coefficients and other pre-calculated values. The CurveInterpolator has functions such as CurveInterpolator.getPointAtTime and CurveInterpolator.getTangentAtTime etc. that serves the same purpose.
Please report an issue if you find a bug, have issues migrating to the new version or just have questions. Hope you find this library useful!
Take a look at the new demo at ObservableHQ: https://observablehq.com/@kjerandp/curve-interpolator-demo