You are on page 1of 8

B-SPLINE CURVES

Robby T. Tan
A Lecture Note of 3D Modeling Course, 2011-2012

Introduction
1. B in B-spline stands for basis. The mathematical term spline means a piecewise polynomial function.
2. Compared to a Bezier curve, a b-spline curve has a few distinct features:
(a) The degree of the curve is independent from the total number of the control points
(b) It is made out of several curve segments that are joined smoothly.
(c) It locally propagates (while a Bezier curve globally propagates)

Definition

A b-spline curve is mathematically defined as:


Q(u) =

n
X

Pj Bj,d (u)

(1)

td1 u tn+1

(2)

j=0

where Pj is a control point. j is the index of the control points. n + 1 is the number of the control points. d
is the number of the control points that control a segment. Implying, d 1 is the degree of the polynomial, for
example: d = 2 is linear, d = 3 is quadratic, d = 4 is cubic, etc. The value of n must be larger or equal to d. tj
is a knot value. A few knot values form a knot vector t.

2.1

B-splines Basis Functions

There are two mathematical definitions of b-splines basis functions: when d = 1, and when d > 1. We will
immediatealy see that these two definitions depend on the knot vector t, where t = (t0 , t1 , t2 , ...), which will be
explained in the subsequent section.
1. when d = 1

Bj,1 (u) =

1
0

if tj u < tj+1
otherwise

(3)

2. when d > 1

Bj,d (u) =

u tj
tj+d1 tj


Bj,d1 (u) +

tj+d u
tj+d tj+1


Bj+1,d1 (u)

(4)

2.2

Knot Vector

The knot vector, as can be observed in the last two equations, affects the values of the basis functions. Moreover,
different ways to build the vector create two different types of b-spline: uniform and non-uniform. The number
of the knot values (or the size of the knot vector) is determine by:
m=n+d+1

(5)

Hence, if n = 2 and d = 2 then m = 5, t = (t0 , t1 , t2 , t3 , t4 ).


1. The knot vector for a uniform b-spline curve requires the following condition:
tj+1 = tj + k

(6)

where k is any constant scalar value.


Example: n = 2, d = 2, k = 1 t = (t0 , t1 , t2 , t3 , t4 ) = (0, 1, 2, 3, 4).
2. The knot vector for a non-uniform b-spline curve requires the following general condition:
tj+1 tj

(7)

One of the forms of a non-uniform knot vector is as follows:


tj

tj

jd+1

if

djn

tj

nd+2

if

j>n

if

j<d

(8)
(9)
(10)

Example: n = 2, d = 2 produces t = (t0 , t1 , t2 , t3 , t4 ) = (0, 0, 1, 2, 2).

Linear Uniform B-spline Curves

In b-spline, linear means that d = 2. Suppose we have 3 control points, implying n = 2. Hence, we can write
the linear uniform b-spline curves as:
Q(u)

2
X

Pj Bj,2 (u)

(11)

j=0

P0 B0,2 (u) + P1 B1,2 (u) + P2 B2,2 (u)

(12)

To be able to do the computation of the curves, we have to do the following steps:


1. Compute the knot vector, t.
2. Compute Bj,d (u), namely: B0,2 , B1,2 , B2,2 .
3. Compute Q(u) from Pj s and the all computed Bj,d (u).

3.1

Computing the knot vector

By considering that n = 2 and d = 2, we can have m = n + d + 1 = 5, which means t = (t0 , t1 , t2 , t3 , t4 ).


Since it is a uniform b-spline curve and we can assume k = 1, then:
t = (t0 , t1 , t2 , t3 , t4 ) = (0, 1, 2, 3, 4)

(13)

3.2

Computing Bj,d (u)

Considering the basis functions definition in Eq.(4) and the knot vector in Eq.(13) we can have the definition of
the uniform basis functions in the case of d = 2 and n = 2 as:
1. B0,2 :
t2 u
u t0
B0,1 (u) +
B1,1 (u)
t1 t0
t2 t1
= uB0,1 (u) + (2 u)B1,1 (u)

B0,2 (u)

(14)
(15)

2. B1,2 :
u t1
t3 u
B1,1 (u) +
B2,1 (u)
t2 t1
t3 t2
= (u 1)B1,1 (u) + (3 u)B2,1 (u)

B1,2 (u)

(16)
(17)

3. B2,2 :
u t2
t4 u
B2,1 (u) +
B3,1 (u)
t3 t2
t4 t3
= (u 2)B2,1 (u) + (4 u)B3,1 (u)

B2,2 (u)

(18)
(19)

As can be seen in Eq.(15),(17), and (19), to have a complete definition of the basis functions, we need the
definition of B0,1 (u), B1,1 (u), B2,1 (u), and B3,1 (u). Hence, we have to evaluate them, which are based on
Eq.(3):
1. B0,1 :

B0,1 (u) =

1
0

if t0 u < t1 , implying 0 u < 1


otherwise

(20)

1
0

if t1 u < t2 , implying 1 u < 2


otherwise

(21)

1
0

if t2 u < t3 , implying 2 u < 3


otherwise

(22)

1
0

if t3 u < t4 , implying 3 u < 4


otherwise

(23)

2. B1,1 :

B1,1 (u) =
3. B2,1 :

B2,1 (u) =
4. B3,1 :

B3,1 (u) =

Having obtained the definition of B0,1 (u), B1,1 (u), B2,1 (u), and B3,1 (u), we can write the complete definition of B0,2 , B1,2 , B2,2 as:
1. B0,2 :

B0,2 (u) = u1(0u<1) + (2 u)1(1u<2)


3

(24)

2. B1,2 :
B1,2 (u) = (u 1)1(1u<2) + (3 u)1(2u<3)

(25)

B2,2 (u) = (u 2)1(2u<3) + (4 u)1(3u<4)

(26)

3. B2,2 :

If we plot the function of B0,2 in a 2D space with x axis representing u and y axis representing B0,2 (u),
then we can obtain:

Figure 1: The plot of the basis function B0,2 (u)


.
If we plot all basis functions: B0,2 (u), B1,2 (u),and B2,2 (u), we will obtain:

Figure 2: The plot of all basis functions B0,2 (u), B1,2 (u) and B2,2 (u), which are represented by blue, red, and
green lines, respectively. This is the reason why this b-spline is called uniform.

3.3

Computing Q(u)

Given Pj s and the all computed Bj,d (u), the last step of computing the curve is to obtain the value of Q(u):

Q(u)

2
X

Pj Bj,2 (u)

(27)

j=0

= P0 B0,2 (u) + P1 B1,2 (u) + P2 B2,2 (u)




= P0 u1(0u<1) + (2 u)1(1u<2) + P1 (u 1)1(1u<2) + (3 u)1(2u<3) +

P2 (u 2)1(2u<3) + (4 u)1(3u<4)

(28)
(29)

According to Eq.(2) the range of u is:


td1

u tn+1

(30)

t1

u t3

(31)

Alternatively we can write Eq.(29) in a better way:


0 u < 1:

Q(u) = P0 u

1 u < 2:

Q(u) = P0 (2 u) + P1 (u 1)

2 u < 3:

Q(u) = P1 (3 u) + P2 (u 2)

3 u < 4:

Q(u) = P2 (4 u)

Note:
1. Aside from the identical shape for all basis functions as shown in Fig.(2), uniform also means that
each control point affects the same number of segments. For instance, P0 affects two segments: segment
0 u < 1 and segment 1 u < 2. Like P0 , both P1 and P2 also affect two segments.

3.4

Linear Uniform B-spline: Example

Given P0 = (0, 0), P1 = (1, 1) and P2 = (1, 0), the curve can be generated by computing:


0
0 u < 1:
Q(u) = P0 u =
u
0


 
0
1
1 u < 2:
Q(u) = P0 (2 u) + P1 (u 1) =
(2 u) +
(u 1)
0
1


 
1
1
2 u < 3:
Q(u) = P1 (3 u) + P2 (u 2) =
(3 u) +
(u 2)
1
0


1
3 u < 4:
Q(u) = P2 (4 u)=
(4 u)
0
Recall that the range of u as defined in Eq.(31) is t1 u t3 , implying 1 u 3. Hence, the curve, Q(u),
will look like:

Linear Non-uniform B-spline Curves

Similar to the linear uniform b-spline curves explained in Sect. 3, and assuming n = 2 (hence, 3 control points),
we can write the non-uniform b-spline equation for d = 2:

Q(u)

2
X

Pj Bj,2 (u)

(32)

j=0

P0 B0,2 (u) + P1 B1,2 (u) + P2 B2,2 (u)

To have the curve, we have to do the following steps:


5

(33)

1. Compute the knot vector, t.


2. Compute Bj,d (u), namely: B0,2 , B1,2 , B2,2 .
3. Compute Q(u) given Pj s and based on the all computed Bj,d (u).

4.1

Computing the knot vector

By considering that n = 2 and d = 2, we can have m = n + d + 1 = 5, which means t = (t0 , t1 , t2 , t3 , t4 ). For


a non-uniform b-spline curve as explained in Sect. 2.2, we can follow the following rules:
tj

tj

= jd+1

if

djn

(35)

tj

= nd+2

if

j>n

(36)

if

j<d

(34)

Based on the rules, for n = 2, d = 2, we can obtain t = (t0 , t1 , t2 , t3 , t4 ) = (0, 0, 1, 2, 2).

4.2

Computing Bj,d (u)

Considering the basis functions definition in Eq.(4) and the knot vector t = (t0 , t1 , t2 , t3 , t4 ) = (0, 0, 1, 2, 2),
we can have the definition of the uniform basis functions in the case
 of d = 2 and n = 2 as written below. Note
that in computing the basis functions we have to define: u0 = 0 , or anything divided by zero equals to zero.
1. B0,2 :
u t0
t2 u
B0,1 (u) +
B1,1 (u)
t1 t0
t2 t1
(1 u)
u
B0,1 (u) +
B1,1 (u)
=
0
1
= (1 u)B1,1 (u)

B0,2 (u)

(37)
(38)
(39)

2. B1,2 :
u t1
t3 u
B1,1 (u) +
B2,1 (u)
t2 t1
t3 t2
= (u 1)B1,1 (u) + (2 u)B2,1 (u)

B1,2 (u)

(40)
(41)

3. B2,2 :
t4 u
u t2
B2,1 (u) +
B3,1 (u)
t3 t2
t4 t3
(2 u)
= (u 1)B2,1 (u) +
B3,1 (u)
0
= (u 1)B2,1 (u)

B2,2 (u)

(42)
(43)
(44)

Unlike the uniform counterpart, the above equations require only the definition of B1,1 , B2,1 :
1. B1,1 :

B1,1 (u) =

1
0

if t1 u < t2 , implying 0 u < 1


otherwise
6

(45)

2. B2,1 :

B2,1 (u) =

1
0

if t2 u < t3 , implying 1 u < 2


otherwise

(46)

Having obtained the definition of B1,1 (u) and B2,1 (u), we can write the complete definition of B0,2 , B1,2 ,
B2,2 as:
1. B0,2 :

B0,2 (u) = (1 u)1(0u<1)

(47)

B1,2 (u) = u1(0u<1) + (2 u)1(1u<2)

(48)

B2,2 (u) = (u 1)1(1u<2)

(49)

2. B1,2 :

3. B2,2 :

If we plot all basis functions: B0,2 (u), B1,2 (u),and B2,2 (u), we will obtain:

Figure 3: The plot of all basis function B0,2 (u), B1,2 (u) and B2,2 (u). This is the reason why this b-spline is
called non-uniform.

4.3

Computing Q(u)

Given Pj s and the all computed Bj,d (u), the last step of computing the curve is to obtain the value of Q(u):

Q(u)

2
X

Pj Bj,2 (u)

(50)

j=0

=
=

P0 B0,2 (u) + P1 B1,2 (u) + P2 B2,2 (u)




P0 (1 u)1(0u<1) + P1 u1(0u<1) + (2 u)1(1u<2) +

P2 (u 1)1(1u<2)

Alternatively we can write the last equation in a clearer way:


0 u < 1:

Q(u) = P0 (1 u) + P1 u
7

(51)
(52)

1 u < 2:

Q(u) = P1 (2 u) + P2 (u 1)

Notes:
1. Aside from the different shapes of the basis functions as shown in Fig.(3), non-uniform also means that
each control point affects a different number of segments. For instance, P0 affects only one segments:
segment 0 u < 1, and P1 affects two segments: segment 0 u < 1 and segment 1 u < 2.
2. The latest point (P2 ) does not give any influence to the first segment (segment 0 u < 1 ).

You might also like