Linear Interpolation Calculator

First point coordinatesX1:Y1:
The second point coordinatesX2:Y2:
Target point x coordinate  X :
Y coordinate of target point

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

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

We can get (y-y0)(x-x0)/(y1-y0)(x1-x0) Assuming that the values ​​on both sides of the equation are α, then this value is the interpolation coefficient - the ratio of the distance from x0 to x to the distance from x0 to x1.

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 as: y = (1- α)y0 + αy1 Or, y = y0 + α(y1 - y0) In this way, y can be directly obtained through α.

Formula: Y = ( ( X - X1 )( Y2 - Y1) / ( X2 - X1) ) + Y1

Here: X1, Y1 = first value, X2, Y2 = second value, X = target value, Y = result