Conversation
…ity to display InterpolationIndex (for BSplineOutsideOfRange error)
Owner
|
awesome work, cheers ! :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request is to address issue #5 and is part of the roadmap to v1 (#187).
B-Splines
B-splines are constructed by joining polynomials of degree$d$ , resulting in a curve with continuity $C^{d-1}$ .
For a B-spline of degree$d$ , we define a set of control points:
We also define a non-decreasing sequence of knots:
where we require a total of$d + k + 1$ knots.
The basis functions are defined as follows:
for$i\in\set{0,1,\ldots,k+d-1}$ .
The basis functions$B_{i, d}(t)$ for $d>0$ can be evaluated via the Cox de Boor algorithm.
The splines are then constructed as follows (mathematical notation could not be rendered, so an image has been included instead):
The B-spline defined above can only be evaluated within the interval$t\in[t_{d}, t_{k}]$ .
Implementation
A B-spline configuration can be set up as follows:
An approximation can then be performed:
If the length of the knot vector does not align with the number of control points and the degree, an error will be raised:
Additionally, the domain over which you can perform approximations is limited, as mentioned earlier:
Notes:
The
add_point()method places the "x-axis" coordinate into its appropriate position within the knots vector, maintaining its sorted order. However, the corresponding "y-axis" value is appended to the end of the control_points vector, since the ordering of control points is independent of the knot values and is instead determined by the fitting process.Some of the unit tests were benchmarked against SciPy’s
BSpline()implementation to verify that the functionality behaves as expected.