B-spline and rational B-spline (Lec 09)

yukita@k.hosei.ac.jp

•Bezier-B-Spline Approximation

We will seek for a partition of unity on the interval [0,n].

•Approximation of degree 1

B[1][t_]=Which[ -1<t<0, t+1, 0 <= t <1, -t+1, True, 0]

Which[-1 < t < 0, t + 1, 0 <= t < 1, -t + 1, True, 0]

Plot[B[1][t],{t,-2,2}];

[Graphics:HTMLFiles/index_2.gif]

Plot[Sum[B[1][t-j],{j,0,10}],{t,-1,12}];

[Graphics:HTMLFiles/index_3.gif]

This plot clearly shows that the set of continuous  functions { B[1,t-j] :  j=0,1,2,...,n } gives a partition  of  unity on the interval [0,n].  The support of  B[1,t-j]  is  [j-1,j+1].

We will  find a Bezier-B-Spline Approximation for the following  data.

data={{0,0},{1,3},{3,3},{5,-2},{6,-2},{7,+1},{9,4},{10,4}};

Length[data]

8

For readability, we transform the array into a function as follows.

cp[n_] := data[[n + 1]]

P[t_]=Sum[ B[1][t-j] cp[j],{j,0,7} ];

g1=ParametricPlot[ Evaluate[P[t]],{t,0,7},
                   DisplayFunction->Identity ];

g0=Graphics[ {Line[data],Line[{{0,-2},{0,5}}],
                         Line[{{0,0},{10,0}}]}];

Show[ GraphicsArray[{g0,g1}],
      DisplayFunction->$DisplayFunction ];

[Graphics:HTMLFiles/index_6.gif]

The approximation of degree one is the guiding line itself.

•Approximation of higher degree

B[q_][t_]:=1/q ( (t+(q+1)/2) B[q-1][t+1/2] +
                ((q+1)/2-t) B[q-1][t-1/2] );

Plot[ B[2][t], {t,-3,3} ];

[Graphics:HTMLFiles/index_7.gif]

Plot[ Sum[ B[2][t-j],{j,-1,11}], {t,-3,13}];

[Graphics:HTMLFiles/index_8.gif]

P[t_]=Sum[ B[2][t-j] cp[j],{j,0,7} ]+
      B[2][t+2] cp[0] +
      B[2][t+1] cp[0] +
      B[2][t-8] cp[7] +
      B[2][t-9] cp[7];

g1=ParametricPlot[ Evaluate[P[t]],{t,-1,7+1},
                   DisplayFunction->Identity ];

g0=Graphics[ { Thickness[0.002],Line[data] } ];

Show[ {g1,g0},
      DisplayFunction->$DisplayFunction ];

[Graphics:HTMLFiles/index_9.gif]

•Rational B-spline Approximation

If we assign weights to control points, we get rational  Bezier/B-spline curves.

•Exapmle of Rational B-spline

We use the same data as above. We  set the weights of control points as follows.

weights={ 1,1,4, 1, 1, 1, 1, 1};

w[n_] := weights[[n + 1]]

P[t_]=( Sum[ w[j] B[2][t-j] cp[j],{j,0,7} ]+
        w[0] B[2][t+2] cp[0] +
        w[0] B[2][t+1] cp[0] +
        w[7] B[2][t-8] cp[7] +
        w[7] B[2][t-9] cp[7] ) /
      ( Sum[ w[j] B[2][t-j],{j,0,7} ]+
        w[0] B[2][t+2]+
        w[0] B[2][t+1]+
        w[7] B[2][t-8]+
        w[7] B[2][t-9] );

g1=ParametricPlot[ Evaluate[P[t]],{t,-1,7+1},
                   DisplayFunction->Identity ];

g0=Graphics[ { Thickness[0.002],Line[data],
               Circle[ data[[3]], 1] } ];

Show[ {g1,g0},
      DisplayFunction->$DisplayFunction ];

[Graphics:HTMLFiles/index_11.gif]

We can see that the approximated curve is attracted to the third control point.

•Excersises

•Problem 1

Plot the quadratic B-spline approximation with the guiding line. Use the data above with a bit of functional tricks. Define the extend2 function that triplicates the first element and triplicates the last element.

extend2[data]

{{0, 0}, {0, 0}, {0, 0}, {1, 3}, {3, 3}, {5, -2}, {6, -2}, {7, 1}, {9, 4}, {10, 4}, {10, 4}, {10, 4}}

Use the bSplineBasis  below that returns the basis that is to be matched with the data of length n.

bSplineBasis[n_] := Table[ B[2][t - j], {j, -2, n + 1}]

•Solution

Converted by Mathematica  (June 3, 2003)