Search code examples
mathgraphicsvector-graphicsbeziersplines

Point Sequence Interpolation


Given an arbitrary sequence of points in space, how would you produce a smooth continuous interpolation between them?

2D and 3D solutions are welcome. Solutions that produce a list of points at arbitrary granularity and solutions that produce control points for bezier curves are also appreciated.

Also, it would be cool to see an iterative solution that could approximate early sections of the curve as it received the points, so you could draw with it.


Solution

  • The Catmull-Rom spline is guaranteed to pass through all the control points. I find this to be handier than trying to adjust intermediate control points for other types of splines.

    This PDF by Christopher Twigg has a nice brief introduction to the mathematics of the spline. The best summary sentence is:

    Catmull-Rom splines have C1 continuity, local control, and interpolation, but do not lie within the convex hull of their control points.

    Said another way, if the points indicate a sharp bend to the right, the spline will bank left before turning to the right (there's an example picture in that document). The tightness of those turns in controllable, in this case using his tau parameter in the example matrix.

    Here is another example with some downloadable DirectX code.