2 ms·
On the topic of interpolation, I've recently been playing with approximating 2D curves (given as some implicit or parametric formula) by chains of Bézier segmen
by LegionMammal978 2y ago
On the topic of interpolation, I've recently been playing with approximating 2D curves (given as some implicit or parametric formula) by chains of Bézier segments of a given degree, while maintaining a maximum distance between the Bézier segments and the exact curve.
Oddly, while there are preexisting resources for interpolating a Bézier through a set of points, there seems to be nothing much for continuous curves. So my current approach is a brute-force binary search, where, from a set start point, I select an end point on the input curve, construct a Bézier through it so that the slopes, curvatures, etc. match up at those points (as much as possible according to the degree), calculate the maximum distance, and compare it to the error bound.
This works quite well when it does work: e.g., with cubic Béziers and tame input curves, the maximum error can be over 100k times smaller than the arc length for a given segment. But the maximum-distance calculation can get quite hairy, since basic ray-tracing doesn't always find all the common normals, and this manifests as numerical instability in the binary search. I often wish I knew the proper ways to do these things, apart from giving up and resorting to the traditional "just discretize the input curve and use B-splines" strategy.