Advertisement

Bilinear interpolation calculator

Label corners by their x and y endpoints. Choose which value or coordinate to recover.

Calculator

Requested value
2.00000000
Grid position
Inside or on the rectangle

Advertisement

How this calculator works

Linear blending is performed across x and then across y. The four weights sum to one. Inside the rectangle they are nonnegative, so the answer lies between the smallest and largest corner values. Outside, the same expression extrapolates and may overshoot. An inverse mode is valid only if the requested variable has a nonzero coefficient.

Formula

s = (x - x1)/(x2 - x1), t = (y - y1)/(y2 - y1); P = (1-s)(1-t)Q11 + (1-s)tQ12 + s(1-t)Q21 + stQ22.

Worked example

On the rectangle [0, 2] by [0, 2], take Q11 = 0, Q12 = 2, Q21 = 2 and Q22 = 4. At (1, 1), every corner has weight 1/4, giving P = 2.

Advertisement

Frequently asked questions

Can I use an irregular quadrilateral?

No. The corners must form an axis-aligned rectangle.

What happens at a corner?

Its weight becomes one and the other weights become zero, so the result is exactly the corner value.

Can an inverse have many answers?

Yes. A constant grid slice cannot identify a coordinate, and a zero corner weight cannot identify that corner. Those cases return an error.

Sources

Advertisement