I’ve got a vector of samples that form a curve. Let’s imagine there are 1000 points in it. If I want to stretch it to fill 1500 points, what is the simplest algorithm that gives decent results? I’m looking for something that is just a few lines of C/C++.
I’ll always want to increase the size of the vector, and the new vector can be anywhere from 1.1x to 50x the size of the current vector.
Thanks!
Here’s C++ for linear and quadratic interpolation.
interp1( 5.3, a, n )is a[5] + .3 * (a[6] – a[5]), .3 of the way from a[5] to a[6];interp1array( a, 1000, b, 1500 )would stretchatob.interp2( 5.3, a, n )draws a parabola through the 3 nearest points a[4] a[5] a[6]: smoother than interp1 but still fast.(Splines use 4 nearest points, smoother yet; if you read python, see
basic-spline-interpolation-in-a-few-lines-of-numpy.