Programmer's guide to polynomials and splines
wordsandbuttons.online
wordsandbuttons.online
https://en.wikipedia.org/wiki/Monotone_cubic_interpolation
It seems the best algorithm for monotone cubic interpolation is the Fritsch-Butland algorithm - here's a nice interactive demonstration:
http://bl.ocks.org/niclasmattsson/7bceb05fba6c71c78d507adae3...
On a side not, a lot of current research focuses on simplifying CAD models to use them as inputs to simulation programs (CFD, finite element analysis codes etc). Indeed, since your CAD model is highly precise, the models are hard to mesh (need very fine mesh to discretize the details), so you simplify them manually and it's very time consuming.
One of the methods that most struck me to automate this simplification was taking the CAD model, transforming it to the frequency domain where high frequencies represent small geometric details and large frequencies, larges underlying features in the model's geometry. So you can filter out the high frequencies, transform it back and end up with a simplified model. You've literally filtered away the smaller geometric features of the model. I remember the paper describing the method for 2D geometry only.
Here's a paper surveying the some of the state of the art methods to simplify CAD models and prepare them for simulation packages. https://www.sciencedirect.com/science/article/pii/S001044850...
That’s a very interesting idea. I guess the problem is though, how would you be able to make such a transformation?
I brute forced it with the least squares :(
*Edit: a cubic curve is also acceptable
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.
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!
Where I could learn the most was in code examples. They provided me new concepts I could poke, modify the values, and see the output, and hopefully after some time I would be able to understand how to use it.
There's a trend that everyone should understand how to code, and python is used as the língua franca for beginners, so providing a lot of examples helps people that do not intend to work as a developer understand new concepts. First you read about it, then you play with it for a while, and finally you'll get how to use it (and when to) in the future.