|
Algorithm presented in this article is derived from Boehm's knot insertion method [1].
|
t1j=t0j,
j=0,1,¼,r
t1r+1=t
t1j+1=t0j,
j=r+1,¼,m+k
which defines m+1 new basis functions Ni,k1(t). Now we want to write
the given B-spline curve in terms of the new control poles di1
and the new basis functions, i.e.,
|
d1i = d0i, i=0,¼,r-k+1
d1i+1 = d0i, i=r,¼,m-1
To compute k-1 affected poles d1r-k+2, ¼,d1r, we set
|
|
|
|
We use a temporary array bij to store the intermediate results. So,
bi0 = di0, i=r-k+1,¼, r
do j=1, p
do i=r-k+1+j, r
a = (t-t0i)/(t0i+k-j-t0i)
bij=bi-1j-1+a(bij-1-bi-1j-1)
enddo
enddo
When completed, we have the following intermediate results:
| ||||||||||||||||||||||||||||||||||||||||||||||||
|
bi0 = dr-k+1+i0, i=0,1,¼,
k-1
do j=1, p
do i=j, k-1
a = (t-t0r-k+1+i)/(t0r+1+i-j-t0r-k+1+i)
bij=bi-1j-1+a(bij-1-bi-1j-1)
enddo
enddo
When completed, we have the following intermediate results:
| ||||||||||||||||||||||||||||||||||||||||||||||||
// First level of insertion:
do i=1, k-1
a = (t-t0r-k+1+i)/(t0r+i-t0r-k+1+i)
bi=bi-1+a(bi-bi-1)
enddo
dr-k+2=b1
dr+p-1=bk-1
// Loop for remaining levels of insertion:
do j=2, p
p0 = bj-1
do i=j, k-1
p1 = bi
a = (t-t0r-k+1+i)/(t0r+1+i-j-t0r-k+1+i)
bi=p0+a(p1-p0)
p0 = p1
enddo
dr-k+1+j=bj
dr+p-j=bk-1
enddo
// Copy remaining elements at the pth row:
dr-k+1+i=bi, i=p+1,¼,k-1
As it is seen, we separate the first level of insertion from others to avoid data copying. Furthermore, we use two variables p0 and p1 to store the data so that bi can be overwritten at each level of insertion. Consequently, we need to allocate only one dimension array to store bi (i=0,1,¼, k).
Having gone through previous sections, the conversion from a B-spline curve to a composite Bézier curve is fairly straightforward: Inserting knots repeatedly using the blossoming formula until the interior knots all have multiplicity equal to k-1. In applications, we may encounter a case where some interior knots may already have multiplicity s with respect to t. In this case, we consider that s knots have been inserted into the knot vector and need to insert remaining p=k-1-s knots.
We now outline the procedure of conversion as follows:
|
|
bi0 = dr-k+1+i0, i=0,1,¼,k-1
do j=1, p
do i=j, k-1
a = (t-t0r-k+1+i)/(t0r+1+i-j-t0r-k+1+i)
bij=bi-1j-1+a(bij-1-bi-1j-1)
enddo
enddo
dpr-k+1+i=dii, i=1,2,¼, p
dpr-k+1+p+i=dp-ip, i=1,2,¼, p
[1] Boehm, W. (1980), Inserting new knots into B-spline curves, Computer-Aided Design 12, pp.199-201