linear interpolation calculator

first point coordinatesX1:Y1:
second point coordinatesX2:Y2:
target point x coordinateX :
target point y coordinate

linear interpolation is a simple interpolation method widely used in mathematics, computer graphics and other fields.

the commonly used calculation method is as follows: suppose we know the coordinates (x0, y0) and (x1, y1), and we want to get the value of x on the straight line at a certain position in the [x0, x1] interval.

we can get (y-y0)(x-x0)/(y1-y0)(x1-x0) assuming that the value on both sides of the equation is α, then this value is the interpolation coefficient—the distance from x0 to x is the same as the distance from x0 to x1 distance ratio.

since the value of x is known, the value of α can be obtained from the formula α=(x-x0)/(x1-x0) similarly, α=(y-y0)/(y1-y0) in this way, it can be expressed algebraically becomes: y = (1- α)y0 + αy1 or, y = y0 + α(y1 - y0) in this way, y can be obtained directly through α.

formula: y = ( ( x - x1 )( y2 - y1) / ( x2 - x1) ) + y1

here: x1,y1 = first value, x2,y2 = second value, x = target value, y = result