-
-
Notifications
You must be signed in to change notification settings - Fork 211
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
How to make a smooth closed interpolation? #111
Comments
Hallo @yiroro, Currently, only the natural spline interpolation approach has been implemented. What you are looking for is called periodic spline interpolation where the first and the last control point have the same location. Unfortunately, I don't know any C library which provides this method out of the box :(. |
I close this issue for now. Don't hesitate to reopen. |
Hello @msteinbeck, thank you so much for creating and maintaining this tool. It's fantastic. I add my name to the list of people who would love support for periodic interpolation. I did come up with a hacky and inefficient way to make splines that are approximately periodic, but it doesn't do interpolation at the moment... if S is a spline I want to make periodic, I first create a new spline T out of several (5 seems to work well) endpoint-to-endpoint copies of S. Then I interpolate T at some points to create P, and finally take a subspline S' of P corresponding to of the middle copy of S in T. Using this method I've been able to create a nearly-periodic version of splines. Rescaling is sometimes necessary at the end to minimize e.g. ||S - S'||^2. Here is a picture. At the top is the original spline S which I want to make periodic. Below is T in black and P in blue. The green points (t = 3/8 and t = 5/8 here, found empirically) are where the subspline S' was cut from P: As you can see, rescaling is needed to make S' more closely approximate S. I didn't do much thinking about what the best interpolation points were, which also could be optimized. However, the derivatives at the endpoints of the resultant spline are nearly identical, as desired:
|
Hi @rothos,
Thank you. Nice to see that this project is also useful for others.
I did some research in the last years and found the following document: https://mirror.math.princeton.edu/pub/CTAN/graphics/pstricks/contrib/pst-bspline/pst-bspline-doc.pdf. On page 13 (Section 5.2: |
I'm trying to fit a set of data points with a closed B-spline using
ts_bspline_interpolate_cubic()
, but the resulted curve is not smooth at the joining point. Is there any way to generate a smooth interpolated curve?The text was updated successfully, but these errors were encountered: