A little background. I have a simulation that uses cubic splines for 1D trajectories. In this context, a cubic spline specifies an object's position, velocity, acceleration, and jerk as a function of time.
If you have:
then there is a unique spline. If you don't specify the final time, but instead want the minimum-time trajectory, then there is also a unique spline.
Actually finding these splines can be a royal pain, though. In the case where time is specified, a spline will consist of up to 7 polynomials, and the knots (transition points between polynomials) aren't known ahead of time.
This is not the usual case of fitting a spline to a set of data, it's creating splines from the boundary conditions and some additional constraints. I've read papers where people have used similar arrangements and have had similar needs, but I've never found any libraries (or even source code) that tackles generating splines of this sort. I've written some code that handles most cases, but it isn't terribly robust or fast. I'm not very worried about it being fast, but more robust would be great.
Are there any libraries that can do this available? Open source code, even if not built as a library? C, C++, Java, or Python preferred, but if it's open source other languages would still be useful as a reference.
Cubic spline interpolation is a way of finding a curve that connects data points with a degree of three or less. Splines are polynomial that are smooth and continuous across a given plot and also continuous first and second derivatives where they join.
Runge's phenomenon tells us that such an approximation often has large oscillations near the ends of the interpolating interval. On the other hand, cubic spline interpolation is often considered a better approximation method because it is not prone to such oscillations.
In the mathematical field of numerical analysis, spline interpolation is a form of interpolation where the interpolant is a special type of piecewise polynomial called a spline.
Cubic spline interpolation is a mathematical method commonly used to construct new points within the boundaries of a set of known points. These new points are function values of an interpolation function (referred to as spline), which itself consists of multiple cubic piecewise polynomials.
There is a boost library for C++ that is open source and might get you half-way there.
It has all the basic building blocks you need I think (Legrendre/Laguerre/Hermite polynomials, root finding, etc...), though it comes short of actually calculating splines.
The library documentation is here so you can check for yourself: http://www.boost.org/doc/libs/1_45_0/libs/math/doc/html/index.html
The problem with splines is that you have to solve simultaneous linear equations to solve the conditions. If your situation has any more information about some of those derivatives, you may be able to use Piecewise Cubic Hermite Interpolation (PCHIP).
For example, instead of defining that jerk must be zero, you could come up with a different constraint, use PCHIP, and solve your problem greedily. Anyway, it's something to remember even if you can't use it this time.
http://www.mathworks.com/moler/interp.pdf
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With