Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add further interpolation types #39

Open
msteinbeck opened this issue May 19, 2016 · 5 comments
Open

Add further interpolation types #39

msteinbeck opened this issue May 19, 2016 · 5 comments

Comments

@msteinbeck
Copy link
Owner

TinySpline provides natural spline interpolation only. We should add closed, periodic, and knot-a-knot interpolation in order to provide a more convenient interface.

@msteinbeck
Copy link
Owner Author

msteinbeck commented Nov 27, 2016

https://www.cs.mtu.edu/~shene/COURSES/cs3621/NOTES/INT-APP/CURVE-INT-global.html provides code describing the interpolation of B-Splines with given degree.

https://people.sc.fsu.edu/~jburkardt/c_src/superlu/superlu.html provides a linear solver implemented in ANSI C

msteinbeck pushed a commit that referenced this issue Apr 14, 2017
We need static factory methods to support different interpolation techniques with same signature (a vector of points and a dimension). ref #39.
@Mortal
Copy link

Mortal commented May 17, 2017

Any plans to implement interpolation of a closed curve, i.e. "splinegon interpolation"? I would like to extend Ipe (feature request) with a drawing tool to draw the natural splinegon through given points since I could benefit a lot from this in my technical drawings of blobs nested inside blobs. Currently I tweak the control points to get the splinegons where I want them in my drawings, but this is imprecise and inefficient.

Alternatively, do you have references on how to implement closed interpolation? Would this be achieved by, say, changing the Thomas algorithm? (I am not at all familiar with spline interpolation algorithms, but I could probably implement some pseudocode in C if it exists.)

@msteinbeck
Copy link
Owner Author

Hi @Mortal. I never heard of "splinegons"---nice to know.

Interpolation of closed splines is something I really would like to address. So, yes, I do have plans to implement it. However, I didn't find the time to do it yet ( there are many different things to do on this library :) ). Implementing closed spline interpolation shouldn't be to hard though.

Alternatively, do you have references on how to implement closed interpolation? Would this be achieved by, say, changing the Thomas algorithm?

The Thomas algorithm most probably must not be changed. What this algorithm basically does is solving a special kind of matrix in linear instead of cubic time. If you want to interpolate a closed instead of a natural spline, all you need to do is to "modify" the base matrix that is used as input for the Thomas algorithm. You can find some information about this matrix at http://www.math.ucla.edu/%7Ebaker/149.1.02w/handouts/dd_splines.pdf page DD 9 (B1 to B4 are the intermediate points of the spline to interpolate). By changing, for instance, the upper left and bottom right entry of the input matrix, you could (more or less) easily interpolate closed (alias clamped) splines. You can find more about this approach at page DD 15: Other possible end conditions.

The Thomas algorithm uses a forward and backward sweep approach to solve a matrix. You can find TinySpline's implementation at https://github.com/msteinbeck/tinyspline/blob/master/library/tinyspline.c#L524 with m being the base matrix. This implementation is based on: http://mirror.hmc.edu/ctan/graphics/pstricks/contrib/pst-bspline/pst-bspline-doc.pdf page 12. An approach showing how to interpolate a closed spline is given on page 13.

If you want to, feel free to implement this approach and create a PR :). Note: closed/clamped spline interpolation is a specials case of periodic spline interpolation. That is, the end points are equals when interpolating a closed/clamped spline. If they differ, it is a periodic spline interpolation.

@msteinbeck
Copy link
Owner Author

msteinbeck commented May 18, 2017

It looks like using the Thomas algorithm will not be applicable for closed spline interpolation.Though having a tridiagonal matrix given in dd_splines.pdf, page DD 16, I can't find a way to put it into the existing code. Consequently, I suggest to implement the pseudo code given in pst-bspline-doc.pdf, page 14 which is using the Gaussian elimination to solve the matrix.

@msteinbeck
Copy link
Owner Author

Currently implemented are:

  • cubic natural
  • catmull rom

Missing:

@msteinbeck msteinbeck changed the title Add further interpolation types. Add further interpolation types Apr 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants