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 at a position 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 distance from x0 to x and from x0 to x1 The ratio of distance.
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) Thus, it can be represented on algebra Becomes: y = (1- α)y0 + αy1 or, y = y0 + α(y1 - y0) This allows y to be obtained directly by α.
Formula:Y = ( ( X - X1 )( Y2 - Y1) / ( X2 - X1) ) + Y1
Here: X1, Y1 = first value, X2, Y2 = second value, X = target value, Y = result
Powered by TorCMS (https://github.com/bukun/TorCMS).