liveBook · Manning

Cubic polynomial approximation

As explained in Geometry for Programmers

Cubic interpolation is the construction of a polynomial interpolation function of degree three from specified data points.

Cubic interpolation constructs a degree-three polynomial that matches four specified values. It is useful when a straight or projective transformation cannot represent curvature, such as a bent book page. section 8.1.3

A practical single-variable construction follows these steps:

Unbending a photographed page

A scanning app maps a flat page to a standard square and then maps that square onto a manually outlined, curved page. Cubic interpolation supplies curvature along the bent direction while retaining linear behavior along the normally straight direction. section 8.1.3

Listing 8.3 Getting coefficients for a generic cubic interpolation formula
from sympy import *
 
z1, z2, z3, z4, a, b, c, d = symbols('z1 z2 z3 z4 a b c d')
 
print(solve([
    d - z1,
    a * 1./27. + b * 1./9. + c * 1./3. + d - z2,
    a * 8./27. + b * 4./9. + c * 1./3. + d - z3,
    a + b + c + d - z4,
    ], (a, b, c, d)))

The SymPy listing turns four interpolation constraints into generic cubic coefficients, making the algebra directly testable. section 8.1.3

How Geometry for Programmers covers it

How deep it goes
Derives coefficients, implements evaluation, and composes linear and cubic interpolation; it stops short of computer-vision control-point detection.
Examples
Uses four-point one-dimensional interpolation, SymPy coefficient solving, and a linear-cubic page-unbending transformation.
What it assumes
Assumes linear interpolation and coordinate transformations, while introducing the four-point cubic construction explicitly.
What you can do after
Apply it via Python or SymPy to construct cubic interpolants and combine them into curved coordinate transformations.
How it connects
Connects cubic interpolation with linear interpolation, projective transformation, polynomial interpolation, and NURBS.

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.