liveBook · Manning

Inverse distance interpolation

As explained in Geometry for Programmers

Inverse distance interpolation is a spatial interpolation method that estimates an unknown value by weighting nearby known values according to the inverse of their distances.

Inverse distance interpolation estimates an unknown value as a normalized weighted sum of known values. Each weight is an inverse power of distance, so nearby points influence the result more strongly. section 8.3.1

For one variable, choose a power n and assign each known value yi the weight 1/|x−xi|^n. Increasing n makes the interpolant more local and produces more pronounced plateaus. At a known point, handle the zero distance explicitly and return its value. section 8.3.1 section 8.3.2

Extend the same idea spatially:

  • In two dimensions, compute Euclidean distance from (x, y) to every known point and normalize the weighted sum. section 8.3.2
  • In three or more dimensions, extend the distance formula and apply the same normalized weighting. section 8.3.2
  • Use values or functions attached to the known points, depending on whether the interpolant represents samples or richer local behavior. section 8.3.1 section 8.3.2

A small terrain interpolator

Given xs = [2, 9, 8, 3, 5], ys = [1, 2, 9, 8, 5], and vs = [1, 2, 3, 4, 5], set n = 2. For each query (x, y), compute the distance to every sample, return the sample value on an exact match, otherwise accumulate vs[i]/distance^n and divide the weighted total by the weight total. This produces a surface suitable for procedural terrain. section 8.3.2

Table 8.2 Convergence of F(x) in x ≈ 1 (view table figure)

x

F(x) approximately

1.1

2.89

1.01

2.98

1.001

2.99

1.0001

2.999

1.00001

2.9999

1.000001

2.99999

Compare values near a known point to see the interpolant converge toward that point’s value. section 8.3.1

How Geometry for Programmers covers it

How deep it goes
Explains normalized inverse-distance weights, powers, endpoint limits, multidimensional formulas, and implementation safeguards.
Examples
Demonstrates two-point convergence, power-controlled curves, four-point interpolation, and a Python-style terrain surface.
What it assumes
Assumes familiarity with linear interpolation and Euclidean distance while developing the method from those ideas.
What you can do after
Build it from scratch for sampled surfaces by computing distances, handling exact matches, and normalizing weighted values.
How it connects
Connects linear interpolation, polynomial interpolation, Bézier functions, spatial interpolation, surfaces, and deformation fields.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Geometry for Programmers. The section links point to the parts of the book it draws on.