9 lines
242 B
Python
9 lines
242 B
Python
def linear_interpolation(x, nodes):
|
|
for i in range(len(nodes) - 1):
|
|
x0, y0 = nodes[i]
|
|
x1, y1 = nodes[i+1]
|
|
if x0 <= x <= x1:
|
|
t = (x - x0) / (x1 - x0)
|
|
return y0 + t * (y1 - y0)
|
|
return 0.0
|