A Spline that Lowers to Quadratic Curves
Status: Draft
This piece is an experiment — I'm working on getting comfortable publishing less polished work, so this draft was written quickly & published right away.
I came across an interesting paper during the pandemic that described a new kind of parametric spline.
I found it exciting, because one virtue of this spline is that it can lower directly to quadratic Bézier curves, which are relatively easy to render since they cannot contain cusps, and this is an advantage if you're doing all of the curve rendering yourself.
As someone who has occasionally implemented graphics engines I decided to play around with an implementation. You can find it here, and there's also an interactive notebook that shows what randomly-generated splines of this form look like.
For efficiency, the implementation contains improvements that take advantage of the shared sub-computations between contiguous curve patches to reduce the amount of work that needs to be performed when rendering incrementally along a path of points.
The equations are specialized to the particular spline parameters that minimize distortion & approximate a centripetal Catmull-Rom spline. You can see my calculations in this Mathematica notebook.
For the idea and math underlying this approach, see the paper Quadratic Approximation of Cubic Curves.
The paper notes that the lowering is reversible and can also be used to raise the degree of a suitable piecewise quadratic curve:
Note that our degree reduction is lossless, in the sense that the original cubic curve can be perfectly reconstructed from the quadratic curves we generate, though the cubic and quadratic curves have slightly different shapes.
[...]
In that respect, our method can also be used as a form of degree elevation: given a 𝐶¹ continuous piecewise quadratic curve (with even number of pieces), we can construct a 𝐶¹ piecewise cubic curve that passes through all data points (i.e. control points that are interpolated) of the quadratic curve.
Thanks to 082349872349872 for pointing this out.
Notes to self
need to make a font that has áccents. Also maybe an alpha character since that's the only reason I used alpha rather than \alpha in the last post
put the code up as a two-file gist [made one file]
Have the notebook pull the code from the gist. I wonder if the relative import for vecmath will work.
remove the references to Silk, maybe?
This write-up is an abbreviated version, edited and expanded in some ways, from the version in the Drafts folder in /drafts/drawing/splines
.