msteinbeck / tinyspline

ANSI C library for NURBS, B-Splines, and Bézier curves with interfaces for C++, C#, D, Go, Java, Javascript, Lua, Octave, PHP, Python, R, and Ruby.
MIT License
1.2k stars 208 forks source link

What method is being used for interpolation? #30

Closed tweeter0830 closed 8 years ago

tweeter0830 commented 8 years ago

Hello,

I'm coming across some weird things when I create a Spline through interpolation. Is there a good reference that talks about how TinySpline is doing its interpolation?

msteinbeck commented 8 years ago

The interpolation of a spline is handled in two steps. First of all we need to find the "B-Spline control points" using Thomas algorithm. The actual computation is based on the pseudo code given at http://www.bakoma-tex.com/doc/generic/pst-bspline/pst-bspline-doc.pdf page 7. Afterwards we have to create a sequence of Bézier curves connecting each point generated by step 1. I have implemented the formulas given at http://www.math.ucla.edu/~baker/149.1.02w/handouts/dd_splines.pdf page 8 starting with sentence "Given B-Spline control points ..."

EDIT: The C code performing the first step can be found here. The code performing the second step can be found here.

msteinbeck commented 8 years ago

What kind of weird things do you mean?

msteinbeck commented 8 years ago

FYI. TinySpline uses the natural spline interpolation. Further interpolation types are planned, namely closed/clamed, periodic, and not-a-knot. I'm closing this issue for the moment because your questions seems to be answered. Feel free to reopen it.