I'm trying to find the matrix form for the equation of a cubic b-spline. More specifically, the "middle" part, S_i(t), is pretty straightforward and available everywhere:
M2 = [
[-1, 3, -3, 1],
[ 3, -6, 0, 4],
[-3, 3, 3, 1],
[ 1, 0, 0, 0]]) * 1/6.
But I struggle finding S_0(t) and S_n-3(t), that is, the first and last segment, that respectively start on the first control point and ends on the last control point
To help explain what I'm looking for, here is exactly it for a quadratic B-Spline (taken from here):
M1 = [
[2, -4, 2],
[-3, 4, 0],
[1, 0, 0]]) * 1/2.
M2 = [
[1, -2, 1],
[-2, 2, 1],
[1, 0, 0]]) * 1/2.
M3 = [
[1, -2, 1],
[-3, 2, 1],
[2, 0, 0]]) * 1/2.
With those 3 matrices, if we work on P0, P1, P2
, we use M1
. If we work on Pn-2, Pn-1, Pn
, we use M3
. For everything else, M2
.
To summarize, I'm looking for M1 and M3, but for a cubic B-spline, not for a quadratic like just above.
Here is an image, to understand better:
- Green crosses: the control points of my cubic spline
- Red curve: desired result
- Yellow crosses: my current result. The middle part works, not the start/end (currently, this is just bezier)
Any help will be greatly appreciated, thank you!