I brute forced it with the least squares :(
*Edit: a cubic curve is also acceptable
I brute forced it with the least squares :(
*Edit: a cubic curve is also acceptable
Try reading Raph Levien’s PhD thesis starting at page 135 http://www.levien.com/phd/thesis.pdf
That is about converting a specific type of curve to cubic segments, but can give you an idea of the considerations involved.
How to approximate a curve within a given error threshold with the minimum number of control points.
If you are trying to approximate a function where the domain of the function is important then it’s fairly straightforward. See De Boor’s book A Practical Guide to Splines, which IIRC has a chapter or two about this.
If instead you are using your spline to approximate the points of a curve without worrying about the parametrization, that gets trickier. Try doing a google scholar search (keywords along the lines of “spline variable knots cagd”), there are a pile of papers analyzing different approaches.
Thank you these are great resources!
See https://en.wikipedia.org/wiki/B%C3%A9zier_curve#Derivative
So an easy method is just to remove the point with the minimal error contribution and iterate until a given threshold.
But the cost is too high for large curves.