interpol.polygon

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

Generalised barycentric interpolation inside/near single polygon.

Interpolate the value at any point in the plane, if the coordinates and the values of a polygon’s nodes are specified.

Parameters
anchorpoints

Iterable of node coordinates (x, y) in order as they appear in the polygon.

anchorvalues

Iterable of floats specifying the known value at each node.

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 polygon, 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.

Source of algorithm: https://www.inf.usi.ch/hormann/papers/Hormann.2006.MVC.pdf