# How to interpolate a polyline into a curve

Can you please tell the library?

Be sure to keep the original points. Let me explain that this is exactly a 2D polyline, and not a mat. function. That is, the X coordinate of the next point may be less than the X coordinate of the previous point.

Approximate interface: input vector with points, accuracy (how many adjacent points are involved in the calculations); at the exit a new, "smoothed" vector.

Does anyone know such libraries (preferably simpler) or functions?

• Previously tried to use the Lagrange method for the function found here . But he has a peculiarity: with a large number of points, a strong amplitude appears. It did not fit. Is there a similar solution for spline interpolation? - umbrella
• Akim's spline turned out to be the most appropriate. - umbrella

Previously tried to use the Lagrange method for the function found here. But he has a peculiarity: with a large number of points, a strong amplitude appears. It did not fit. Is there a similar solution for spline interpolation?

For any interpolation with a large number of points there will be "beats". To smooth out, one should use the approximation using either the least squares method with the given order of the polynomial (let it be the same Lagrange or Chebyshev) or apply the Bezier method

• According to the link I found the implementation of the spline Akima in PHP. The case remains for the small - convert to c ++ :) - umbrella

Nothing prevents from rotating the spline interpolation for individual fragments of a polyline - for the spline interpolation method there is no limit to the fact that the curve is a function.

As an extra. food for thought - google "smoothen polyline" and here these articles:

• About splitting into parts did not think. After joining smooth pieces, the corners are not formed at the junction? Need to think about. - umbrella
• > Nothing prevents from turning the spline interpolation. If the polylines in 3ds max, rhino are smoothed in this way, this is exactly what is needed. Do not know? - umbrella