minimumVariationCurve
Converts this polyline into a minimum-variation curve (MVC) through all points: the G2 curve that minimizes the variation of its curvature, ∫(dκ/ds)² ds, after Moreton and Séquin, "Functional optimization for fair surface design" (SIGGRAPH 1992). The variation shrinks as a curve grows, so where the curve loops it has no minimum: the loop would inflate without end. The scale-invariant form, the variation times the cube of the curve length, is minimized instead; it has the same minimizers up to how the length is weighed in, and a circle still scores zero. Where clothoid splines let the curvature change linearly along every segment, the MVC lets it change as little as possible over the whole curve, so it is fairer still. Points on a circle give that circle, the curve with zero variation, and collinear points a straight line.
Every edge is a quintic Bézier given by Hermite data at its ends. Neighbouring edges share the tangent direction and the curvature at their common point, which makes the curve G2 by construction. The tangent directions and curvatures are optimized together with Levenberg-Marquardt on the quadrature residuals of the functional, starting from Catmull-Rom tangents and the curvature of the circle through every point and its neighbours. The functional is evaluated by Gauss-Legendre quadrature. At the ends of an open polyline the tangent and curvature are free variables like everywhere else, so the optimization chooses them too.
The optimization is local and the functional is not convex, so for erratic points the result is the nearest local minimum, which is still G2 and passes through all points.
Parameters
whether the polyline is closed, the last point should then not repeat the first
the largest distance between the cubic approximation and the quintic segments
the polarity of the resulting contour