Allegro.cc Forums » Programming Questions » Cubic Splines

 SiegeLord Member #7,827 October 2006 Well, yes it is.Quote: A cubic spline is a spline constructed of piecewise third-order polynomials which pass through a set of m control points. Which means that you have a set of individual cubic splines put together end to end. You make sure it looks nice by picking control points like in the article I showed you.Basically your function may sort of look like this:```// Interpolates between p1 and p2, such that the line is // parallel to vectors m1 and m2 at p1 and p2 respectively vector interpolate(vector p1, vector p2, vector m1, vector m2) { return TheUsualBezierInterpolation(p1, p1 + m1 / 3, p2 - m1 / 3, p2); } ``` You compute m1 and m2 using whatever method from the article I linked to you choose (but ultimately they depend on the 3 points that define each angle). TheUsualBezierInterpolation is just what it says. There's a version of it on the internet for sure. Allegro5 has it in the al_calculate_spline function. "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]