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

[CPP] Construct piecewise poly from boundary conditions (first derivatives at curve endpoints) #157

Open
leonardoedgar opened this issue Jan 8, 2021 · 5 comments

Comments

@leonardoedgar
Copy link
Contributor

Hi. I am trying to find a way to construct a 3rd order piecewise-polynomial / cubic spline by specifying first-derivatives at the endpoints of the curve in cpp.

I found the implementation in Python here

class SplineInterpolator(AbstractGeometricPath):

With the python implementation, a spline can be constructed by specifying boundary conditions such as the first-derivatives at the endpoints of the curve as documented here https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.CubicSpline.html

However, in cpp, all that I can find related to piecewise poly are here

class PiecewisePolyPath : public GeometricPath {

The spline in cpp can only be constructed from these 2 scenarios:

In the scenario where the first-order derivatives at each knot are unknown,
with a general form of a cubic spline in the following form (4n unknowns),
Screenshot from 2021-01-08 16-28-45

a cubic spline still can be constructed by specifying the following:

  • The values at each knot (2n equations)
    Screenshot from 2021-01-08 16-31-03

  • The first and second derivative of all polynomials are identical in the points where they touch their adjacent polynomial
    (2n - 2 equations)
    Screenshot from 2021-01-08 16-33-52
    Screenshot from 2021-01-08 16-31-08

  • The first derivative at the curve endpoints (2 equations)
    f1'(x1) = a
    fn'(xn+1) = b, where a and b are known values

However, currently, this method is not available in cpp. Are there any suggestions to go about this?

@jmirabel
Copy link
Collaborator

jmirabel commented Jan 8, 2021

As far as I know, this is not implemented. However, this is easy to implement since this boils down to solving A x = b and Eigen provides everything you need for it, you only have to build A and b. A bit cumbersome but nothing hard.

@leonardoedgar
Copy link
Contributor Author

Noted, thanks

@hungpham2511
Copy link
Owner

@leonardoedgar If you have an implementation, feel free to open a PR!

@leonardoedgar
Copy link
Contributor Author

@hungpham2511 noted

@github-actions
Copy link

Stale issue message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants