liveBook · Manning

Polynomial parametric curve

As explained in Geometry for Programmers

A polynomial parametric curve is a curve whose coordinate functions are polynomials in its parameter.

A polynomial parametric curve describes each coordinate as a polynomial in a parameter. A 2D cubic uses Px(t) = ax t³ + bx t² + cx t + dx and Py(t) = ay t³ + by t² + cy t + dy, requiring eight coefficients. section 7.2.1

Build an interpolating curve by following this practical workflow:

  • Choose parameter values for the points, commonly distributing four points evenly over t in [0, 1]. section 7.2.1
  • Compose one Vandermonde system for Px(t) and another for Py(t), then solve for their coefficients. section 7.2.1
  • Reuse symbolic coefficient formulas instead of solving the systems for every new set of points. section 7.2.1

Four-point interpolation

Given four points, assign them parameter values 0, 1/3, 2/3, and 1. Solve separate systems for x and y to obtain the eight cubic coefficients, then evaluate both polynomials to draw a curve through all four points. section 7.2.1

Interpolation guarantees passage through the chosen points but gives limited control over tangent vectors, which matters when joining curves smoothly. A cubic can instead use endpoint positions and tangent vectors as its four constraints per coordinate; multiple segments can then meet smoothly when their joint tangents are compatible. section 7.2.1

Listing 7.6 Getting the formula for the coefficients of a parametric polynomial curve
from sympy import *
 
ax, bx, cx, dx = symbols('ax bx cx dx')    #1
ay, by, cy, dy = symbols('ay by cy dy')    #2
x1, x2, x3, x4 = symbols('x1 x2 x3 x4')    #3
y1, y2, y3, y4 = symbols('y1 y2 y3 y4')    #4
 
x_system = [                               #5
    dx - x1,
    (1/27)*ax + (1/9)*bx + (1/3)*cx + dx - x2,
    (8/27)*ax + (4/9)*bx + (2/3)*cx + dx - x3,
    ax + bx + cx + dx - x4
]
 
y_system = [                               #6
    dy - y1,
    (1/27)*ay + (1/9)*by + (1/3)*cy + dy - y2,
    (8/27)*ay + (4/9)*by + (2/3)*cy + dy - y3,
    ay + by + cy + dy - y4
]
 
axs = solve(x_system, (ax, bx, cx, dx))
ays = solve(y_system, (ay, by, cy, dy))
 
print(axs)
print(ays)

A SymPy listing defines the coordinate symbols, constructs the two interpolation systems, solves them, and prints reusable coefficient formulas. section 7.2.1

How Geometry for Programmers covers it

How deep it goes
Explains cubic equations, parameter assignment, Vandermonde systems, symbolic solving, tangent constraints, and smooth joining.
Examples
Demonstrates four-point interpolation, SymPy coefficient formulas, tangent-controlled cubics, and smoothly joined cubic segments.
What you can do after
Build it from scratch by assigning parameters, solving coordinate systems, reusing SymPy formulas, and controlling endpoint tangents.
How it connects
Connects polynomial curves with parametric curves, interpolation, Vandermonde systems, splines, Bézier curves, tangent vectors, and CAD.

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.