brainexcerpts / Spline

C++ routines to compute spline curves in nD
MIT License
41 stars 14 forks source link

Similar Results to CubicSpline from scipy + eval_ddf #3

Open JadTawil-theonly opened 3 years ago

JadTawil-theonly commented 3 years ago

I am trying to replicate the results with CubicSpline from scipy, but fail to do so :s, have you compared your implementation with theirs?

Also, Would you be able to add a eval_ddf method, for evaluating the acceleration of the spline as well?

ziyuang commented 1 year ago

I am trying to replicate the results with CubicSpline from scipy, but fail to do so :s, have you compared your implementation with theirs?

Also, Would you be able to add a eval_ddf method, for evaluating the acceleration of the spline as well?

How different are they?

brainexcerpts commented 1 year ago

Cubic Bézier are a specific case of B-splines. My code will give different behaviors whenever you change the order 'k' or the node type, that's expected.

A Cubic Bézier is a degree 3 curve with 4 control points. A B-Spline that reproduce it should have 4 control points as well (not less, not more) and an order of k=4 (degree of a B-Spline = k-1) The knot vector should be open uniform ranging from [0 - 1].

ddf is the acceleration, so by definition the difference of velocities, so one way to compute it numerically: eval_ddf(t) = ( eval_df( t + h ) - eval_df( t - h ) ) / 2*h

I don't recall the analytical evaluation though so I'll look it up later.