2021-08-01
function linear_interpolation(p, q, x){
var x1 = p[0],
y1 = p[1],
x2 = q[0],
y2 = q[1];
if(x < x1 || x > x2){
throw 'value x must be between the x-coordinates of p and q';
}
var y = y1+((x-x1)*(y2-y1))/(x2-x1);
return y;
}
Watch the video: