An implementation of the Catmull-Rom spline.
A Curves.Spline.Type.Hermite spline whose tangents are worked out for you: the tangent at each knot is half the
distance from the previous knot to the next one, so you only give the knots.
This makes a smooth, C1 continuous spline.
It has relatives that work the same way, with something extra: Curves.Spline.Type.Cardinal adds a
:tension, Curves.Spline.Type.CentripetalCatmullRom never makes loops when knots are bunched up,
and Curves.Spline.Type.KochanekBartels adds tension, continuity and bias dials.
curve = Curves.define_catmull_rom([
{0, 0},
{1, 0},
{1, 1},
{0, 1},
{0, 2},
{1, 2},
])
# Find any point along the curve (u goes from 0.0 to Curves.max_u(curve))...
Curves.solve!(curve, 1.5)
# ...or draw the whole curve as an SVG image
Curves.Svg.save!(curve, "catmull_rom.svg")