johntfoster / bspline

Python/Numpy bspline implementation via Cox - de Boor
MIT License
56 stars 13 forks source link

Spline Boundary Behavior #1

Closed halfhorst closed 8 years ago

halfhorst commented 8 years ago

Hello John, thanks for this little python module, and sorry if this finds you having forgotten all about it.

I am investigating using this module to implement b-splines rather than reinventing the wheel and I am encountering boundary behavior I don't expect. Given an instantiation of the class

knot_vector = [0, 0, 0, 0, 25, 35, 55, 65, 85, 85, 85, 85]
basis = Bspline(knot_vector,3)
basis.plot()

The final spline as x --> 85 approaches one. However, the value at 85 is zero. Is this expected? My understanding was that this value should actually be equal to one at the final spline

print(basis(84.999))
>>> [  0.00000000e+00   0.00000000e+00   0.00000000e+00   0.00000000e+00
3.33333333e-14   4.99982778e-09   1.49987500e-04   9.99850007e-01]
print(basis(85))
>>> [ 0.  0.  0.  0.  0.  0.  0.  0.]

This is Python 3.5. Thanks for any insight

johntfoster commented 8 years ago

@chorst This is the expected behavior for this implementation. I use this to module to evaluate the shape functions during isogeometric analysis. Due to the nature of the integration routine I use, I never have to evaluate the shape function at either boundary so it works well in my use case. But, you are correct, by definition the value should be 1.