interpol.polygons

interpol.polygons(anchorpoints: Iterable, anchorvalues: Iterable) → Callable[source]

Generalised barycentric interpolation (using polygons) near set of points.

Interpolate the value at any point in the plane, if the coordinates and values of a set of anchors is specified. The convex hull around them is tessellated with polygons.

Parameters
anchorpoints

Iterable of anchor point coordinates (x, y).

anchorvalues

Iterable of floats specifying the known value at each anchor point.

Returns
Function that accepts coordinates (x, y) of any point in the plane as a
2-Iterable, and returns the interpolated value at that point.

Notes

Instead of single floats, the anchorvalues may also be iterables of uniform length, e.g. 3- or 4-tuples specifying colors. The interpolation function’s return value has the same length as the anchorvalues.

For points that lie outside the hull, the interpolated value may be smaller (larger) than the minimum (maximum) of the specified anchorvalues. This means that, when using colors for the anchorvalues, an invalid color may be returned.