Skip to content

[question] Interpolating closed spline ? #13

Answered by ttk592
4rzael asked this question in Q&A
Discussion options

You must be logged in to vote

The library lacks the ability to set the periodic boundary condition f'(a) = f'(b) which we would need for a closed curve which is smooth at the point where it connects. However, with a small workaround it can still be achieved as a reasonable approximation, see examples/plot_parametric.cpp. E.g. the below draws something resembling an inf sign:

$ ./plot_parametric.sh -x 0 0 1 2 2 1 -y 0 1 0.5 0 1 0.5 -c

The correct way to do it:

  • define a time grid points, e.g. T[i+1]=T[i]+distance(X[i],Y[i], X[i+1],Y[i+1]).
  • set splines for x and y grid points: sx.set_points(T,X); and sy.set_points(T,Y); with periodic boundary conditions (which is not implemented)
  • plot points x=sx(t); and y=sy(t); and …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ttk592
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #6 on February 23, 2021 18:38.