1
$\begingroup$

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!

$\endgroup$

1 Answer 1

1
$\begingroup$

If you want to determine those matrices you have to use the knot vector $[0, 0, 0, 0, 4, 5, 6,...]$ and write out the expressions using the Cox-DeBoor algorithm. I believe you will need to compute the functions on two knot spans and therefore obtain two different matrices.

However, you can also use a little trick here by constructing a ghost point. If You construct a point $P_{g} = (2P_0 - P_1)$ and then apply $M_2$ to $\begin{bmatrix} P_{g} \\ P_0 \\ P_1 \\ P_2 \end{bmatrix}$ you will end up with the following situation: enter image description here Here curve $a$ is constructed using control points $[P_{g}, P_0, P_1, P_2]$ and curve $b$ with $[P_0, P_1, P_2, P_3]$. Naturally, the same can be done at the end of the curve by creating a ghost point $P_g = 2P_n - P_{n-1}$. If you need the matrix you will have to substitute $(2P_0 - P_1)$ for $P_g$ and find out which functions act on $P_0$ and $P_1$ by writing out the equations and collecting the terms.

$\endgroup$
1
  • $\begingroup$ Great, adding an extra point does the trick, thank you! Next step will be for me to understand why we can't apply the same logic than for a quadratic bezier and why we need to introduce that knot vector, but for the time being, adding a point at the beginning works! Thank you so much =] $\endgroup$
    – fruity
    Jul 22, 2023 at 17:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.