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

Bezier curve interpolated with tension #228

Open
maurogzz opened this issue Mar 4, 2023 · 6 comments
Open

Bezier curve interpolated with tension #228

maurogzz opened this issue Mar 4, 2023 · 6 comments

Comments

@maurogzz
Copy link

maurogzz commented Mar 4, 2023

If you build an interpolated curve composed of several bezier splines and apply tension, it modifies the curve which is no longer interpolated but becomes a bezier that connects the first and last points of the original curve losing coincidence with all points intermediate. It would be desirable that applying tension to each individual bezier component so that the interpolated points are all on the resulting curve.

@msteinbeck
Copy link
Owner

Hi @maurogzz,

thank you for reporting this issue.

From your description I have the feeling that there is a misunderstanding of what the purpose of tension is. In TinySpline, applying tension to a spline results into what is called "spline straightening" in Hierarchical Edge Bundles: Visualization of Adjacency Relations in Hierarchical Data (by Danny Holten). That said: "losing coincidence with all points" is indeed a bug.

You seem to refer to the concept of tension which is known from Catmull-Rom splines (e.g., https://qroph.github.io/2018/07/30/smooth-paths-using-catmull-rom-splines.html and https://link.springer.com/article/10.1007/s42979-021-00770-x). This is currently not implemented in TinySpline. You can only interpolate Catmull-Rom splines with given alpha (see, e.g., https://en.wikipedia.org/wiki/Centripetal_Catmull%E2%80%93Rom_spline). If needed, I could add tension to the Catmull-Rom interpolation function.

@maurogzz
Copy link
Author

maurogzz commented Mar 7, 2023

Thanks, yes you got it right in the first and second case. If you could put 'tension' to the Catmull-Rom spline it would be interesting.
Truly many compliments for an original and useful library.

@msteinbeck
Copy link
Owner

I added the parameter tension to the Catmull-Rom interpolation function in branch issue-228. The interpolation function (should) now behaves as described by: https://qroph.github.io/2018/07/30/smooth-paths-using-catmull-rom-splines.html. That is, if tension = 0, the same spline as without tension is created. If tension = 1, a sequence of straight lines is created. I also updated the FLTK demo application (make target demo). It now includes a slider for the tension.

Please let me know whether this is what you expect from the tension parameter. If it suits your needs, I'll merge the branch into master.

@msteinbeck
Copy link
Owner

In case you cannot build the demo application (e.g., due to missing FLTK packages), here is a pre-built executable. It should also work with wine on Linux.

demo.zip

@maurogzz
Copy link
Author

I am happy with what you have done.
But the fix to the 'tension' bug for a bezier spline? Think you can fix it?
I realize that you are doing a great job for free and therefore I thank you in any case but if you could it would be great since I am using this functionality for my graphics application.

@msteinbeck
Copy link
Owner

But the fix to the 'tension' bug for a bezier spline? Think you can fix it?

I can probably fix that. I will try to work on this bug the next days.

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