Skip to content

TomasGlgg/CubicInterpolation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Cubic interpolation

Usage:

>>> from lib import CubicInterpolate
>>> array = [1, 2, 3, 4, 5]
>>> i = CubicInterpolate(array)
>>> i.use(2.5)
3.5

Demo:

from matplotlib import pyplot as plt
from numpy import linspace

from lib import CubicInterpolate

array = [1, 1, 2, 3, 3, 2, 1, 1, 2, 3, 3, 2, 1, 1]
plt.plot(array, 'o')

i = CubicInterpolate(array)
curve_x = linspace(1, len(array) - 2, 100)
curve_y = []
for x in curve_x:
    curve_y.append(i.use(x))

plt.plot(curve_x, curve_y)
plt.show()

Demo