3
$\begingroup$

The equation for B-spline with control points $(P_0, P_1,\dots,P_n)$ is \begin{equation} P(t)=\sum_{i=0}^n B_{i,k}(t)P_i \end{equation}

If I have the following knots: $1,2,3,4$ and the following control points: $P_1=0$, $P_2=-1$, $P_3=1$ and $P_4=2$. Since I have uniform knots as it has been suggested I used the basis functions and I shift them $2$ units to the right. So after doing some calculations the shifted basis functions are: $B_0(u-2)=(27-u^3-27u+9u^2)/6$

$B_1(u-2)=(3u^3-24u^2+60u-44)/6$

$B_2(u-2)=(-3u^3+21u^2-45u+37)/6$

$B_3(u-2)=(u^3-6u^2+12u-8)/6$

Then I put everything into the equation of $P(t)$ like this: $P(t)=0\times B_0(u-2)-1\times B_1(u-2)+1 \times B_2(u-2)+2 \times B_3(u-2)$

Then I substituted the knot point t=1 into $P(t)$, i.e. $P(1)$. The result of $P(1)\neq0$. I was expecting that I will end up with zero because the spline in the end it has to be function that goes through the control points so we can check that. In my case is doesn't go through the control point so I did something wrong. Does anyone figure out what I did wrong?

$\endgroup$
  • $\begingroup$ If you want to evaluate at $u=1$, then, at a minimum, you will need 2 knots to the left of 0 and 2 knots after 1. So, some examples of knot sequences that would work are $(0,0,0,1,1,1)$ or $(-2,-1,0,1,2,3)$. Also, are your points indexed correctly? Your indexing starts at 1 in one place, and 0 in another place. $\endgroup$ – bubba Mar 7 '14 at 13:59
  • 1
    $\begingroup$ Generally, a b-spline won't pass through any of its control points. You can make it pass through the first and last control points by using repeated knots at the start and end of the knot sequence. For example, a knot sequence like $(0,0,0,0,1,2,3,4,5,5,5,5)$ would work. $\endgroup$ – bubba Mar 7 '14 at 14:02
  • $\begingroup$ To be honest I just put random knots and random control points because I was trying to understand how the b-splines work. I had the impression that that the b-spline will pass through each control point. In the sequence like the one you suggested $(0,0,0,0,1,2,3,4,5,5,5,5)$ you added 3 zeros on the left and 3 fives on the right. Why you choose to add 3 of each and not 2? Also in a sequence like this on which interval you have to focus in order to use the right basis functions? Before we shift by 2 units on right. $\endgroup$ – user105627 Mar 7 '14 at 14:17
  • $\begingroup$ See also the previous question and answer explaining the $B$-polynomials math.stackexchange.com/a/700183/115115 $\endgroup$ – Dr. Lutz Lehmann Mar 7 '14 at 14:53
  • 1
    $\begingroup$ > I had the impression that that the b-spline will pass through each control point. No, not true. Take a look at the pictures of b-splines in the references I already gave you. None of them pass through their control points (except maybe the first and last control points). $\endgroup$ – bubba Mar 7 '14 at 22:41
4
$\begingroup$

In general, a b-spline curve will not pass through any of its control points. There is an example at the bottom of this web page, which explains how repeating knot values will cause a b-spline curve to pass through one of its control points. This technique is typically used with the first and last knots, to force the spline to pass through the first and last control points.

When you repeat knots, this changes the form of the b-spline basis functions, so the ones you cited will not be correct near repeated knots.

To evaluate a cubic b-spline on the interval $[0,1]$, you need a knot sequence that has at least two knot values to the left of 0, and at least two knots to the right of 1. These 6 knots together are needed to define the basis functions that are non-zero on $[0,1]$. So, the knot vector you mentioned $(1,2,3,4, \ldots)$ certainly will not work.

If you want a b-spline curve that passes through a sequence of given points, then you need to use an "interpolating" b-spline. You compute one of these by solving a system of linear equations to get its control points, as explained by @LutzL and on this page.

$\endgroup$
  • $\begingroup$ By an interpolating b-spline also we will need basis functions.The formula states that $D_k=C(t_k)=\sum_{i=0}^n N_{i,p}(t_k) P_i$ where $D_k$ corresponds to data points and $t_k$ parameters. In this case why I cannot use the basis functions $(B_0,B_1,B_2,B3)$ as shown above? $\endgroup$ – user105627 Mar 10 '14 at 12:02
  • $\begingroup$ When you repeat knots, this changes the form of the b-spline basis functions, so the ones you cited will not be correct near repeated knots. $\endgroup$ – bubba Mar 10 '14 at 12:12
  • $\begingroup$ When I have a given set of data points and I want to find a b-spline curve that passes all data points am I able to use the basis functions that I cited above? I had read that in image registration they used B-splines to dorm the deformation field. They cited the basis functions $(B_0,B_1,B_2,B_3)$. In such cases they didn't repeat knots? $\endgroup$ – user105627 Mar 10 '14 at 13:12
  • $\begingroup$ If I want a b-spline curve that passes through a sequence of given points you suggested to use "interpolating" b-spline. I don't see the reason you are talking about repeated knots. Also what kind of basis function shall I use if I want a sequence that pass through a sequence of given points? $\endgroup$ – user105627 Mar 10 '14 at 16:53
1
$\begingroup$

Call the cubic B-spline centered at zero $β_3$. Then a linear combination of B-splines is $$ f(t)=\sum_{i=1}^nc_i\,β_3(x-i) $$ On any interval $x\in[i,i+1]$, the value of $f$ is given by the polynomial basis functions discussed in https://math.stackexchange.com/a/700183/115115 as $$ f(t)=B_0(x-i)c_{i-i}+B_1(x-i)c_{i}+B_2(x-i)c_{i+1}+B_3(x-i)c_{i+2}. $$


One could use $c_i=P_i$, but $β_3(-1)=\frac16=β_3(1)$ and $β_3(0)=\frac23$, this would result in an averaged value $f(i)=\frac16(P_{i-1}+4P_i+P_{i+1})$. Sometimes this is acceptable.

If you want to achieve true interpolation, $f(i)=P_i$, you would have to solve $\frac16(c_{i-1}+4c_i+c_{i+1})=P_i$, for instance using the Gauß-Seidel iterative method.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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