#C – MATH – CURVE FIT
6 messages in this thread
I am trying to find a C routine or the math formula to draw a smooth curve
through a given set of points. For example I would like to draw a smooth
curve between points like these ( a foil shape )
.
.
.
. .
Carol Barron informed me there might be a C routine in this forum which
will do this.
Any help in this direction would be appreciated.
I remmeber seeing cubic splines and stuff _somewhere_, but I have no idea
where. COuld it have been a Borland toolbox?
Have you looked at Bezier curves? Bezier curves allow you to draw smoothed
curves for any number of points. The curve is connected by the end points
and the inner points act as "control" points where each control point
influences the shape of the curve. Kent Porter covers them in detail in
"Stretching Turbo C" (Brady Books, NY) complete with source. Another good
book is "Graphics Programming in C" (M&T Books, CA) by Roger T. Stevens.
— MF
Mike, Bezier won't do what Aaron wants, since he wants a curve passing
through specific intermediate points. Splines are the right answer.
Jack
I see! (I should have read his question more carefully.) Roger
Stevens covers B-splines in the same book.
— MF
You want a B-Spline algorithm. There were a couple of curve fitting
routines here on the forum, I don't remember the names. I'll check my
archives and see what I can come up with. B-Splines are discussed in depth
in Newman and Sproull and in Van Dam, and are also to be found in Numerical
Recipes in C.
Tom G.