Lecture4 and 5

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 47

ME F318 Computer Aided Design

Lecture 4: B-spline curves

BITS Pilani Dr. Amit R. Singh


Pilani Campus

1 / 47
An excellent resource for Bézier and
B-spline curves

I came across a very nice website which has live demos of many
examples of Bézier and B-spline curves. Check it out:
https://pomax.github.io/bezierinfo.

2 / 47 BITS Pilani, Pilani Campus


Motivation for B-spline curves

• The whole Bézier curve changes if any of the control points is


changed due to the “global support” of Bernstein polynomials.

3 / 47 BITS Pilani, Pilani Campus


Motivation for B-spline curves

• The whole Bézier curve changes if any of the control points is


changed due to the “global support” of Bernstein polynomials.
• We discussed that we can make complex shapes using a
composition of multiple low order Bézier curves. But we need
to enforce some continuity conditions at the joints.

4 / 47 BITS Pilani, Pilani Campus


Motivation for B-spline curves

• The whole Bézier curve changes if any of the control points is


changed due to the “global support” of Bernstein polynomials.
• We discussed that we can make complex shapes using a
composition of multiple low order Bézier curves. But we need
to enforce some continuity conditions at the joints.
• Is it possible to have piecewise low order polynomial curves
that take care of continuity “on their own”?

5 / 47 BITS Pilani, Pilani Campus


Motivation for B-spline curves

• The whole Bézier curve changes if any of the control points is


changed due to the “global support” of Bernstein polynomials.
• We discussed that we can make complex shapes using a
composition of multiple low order Bézier curves. But we need
to enforce some continuity conditions at the joints.
• Is it possible to have piecewise low order polynomial curves
that take care of continuity “on their own”?
• B-spline curves address both these concerns.

6 / 47 BITS Pilani, Pilani Campus


Knot Vector

A B-spline of order k consists of multiple polynomial curves of


degree k − 1, “tied together” such that there is at most C k−2
continuity at the joints or knots.

7 / 47 BITS Pilani, Pilani Campus


Knot Vector

A B-spline of order k consists of multiple polynomial curves of


degree k − 1, “tied together” such that there is at most C k−2
continuity at the joints or knots.
Definition
A knot vector is a sequence of non-decreasing real numbers. It
parametrizes the “basis functions” or ‘B-splines’.

8 / 47 BITS Pilani, Pilani Campus


Knot Vector

A B-spline of order k consists of multiple polynomial curves of


degree k − 1, “tied together” such that there is at most C k−2
continuity at the joints or knots.
Definition
A knot vector is a sequence of non-decreasing real numbers. It
parametrizes the “basis functions” or ‘B-splines’.

For example, if t0 ≤ t1 ≤ . . . ≤ tm then

T = (t0 , t1 , . . . , tm )

is a knot vector.

9 / 47 BITS Pilani, Pilani Campus


Types of Knot Vectors

• Uniform / Periodic: Equally spaced e.g. (0, 1, 2, 3, 4, 5, 6, 7).

10 / 47 BITS Pilani, Pilani Campus


Types of Knot Vectors

• Uniform / Periodic: Equally spaced e.g. (0, 1, 2, 3, 4, 5, 6, 7).


• Open Uniform: Equally spaced except at the ends. e.g.
(0, 0, 0, 1, 2, 3, 3, 3). The first and the last knots are repeated
k times i.e. they have ‘multiplicity’ k.

11 / 47 BITS Pilani, Pilani Campus


Types of Knot Vectors

• Uniform / Periodic: Equally spaced e.g. (0, 1, 2, 3, 4, 5, 6, 7).


• Open Uniform: Equally spaced except at the ends. e.g.
(0, 0, 0, 1, 2, 3, 3, 3). The first and the last knots are repeated
k times i.e. they have ‘multiplicity’ k.
• Non-uniform: Either unequally spaced or having repeated
internal knots or both e.g. (0, 1, 1, 3, 4, 8, 9, 9)

12 / 47 BITS Pilani, Pilani Campus


Types of Knot Vectors

• Uniform / Periodic: Equally spaced e.g. (0, 1, 2, 3, 4, 5, 6, 7).


• Open Uniform: Equally spaced except at the ends. e.g.
(0, 0, 0, 1, 2, 3, 3, 3). The first and the last knots are repeated
k times i.e. they have ‘multiplicity’ k.
• Non-uniform: Either unequally spaced or having repeated
internal knots or both e.g. (0, 1, 1, 3, 4, 8, 9, 9)
• Clamped: The first and the last knots are repeated k times
i.e. they have ‘multiplicity’ k. E.g. (0, 0, 0, 1, 2, 5, 7, 7, 7).

Note: The knot vector elements don’t have to be integers. Any


sequence of non-decreasing real numbers is acceptable e.g. [-0.03
-0.01, 0.23, 1.414, 3.141].

13 / 47 BITS Pilani, Pilani Campus


B(asis)-splines

Definition
For a given knot vector T and order k, the associated B-spline
functions are
t − ti ti+k − t
Ni,k (t) = Ni,k−1 (t) + Ni+1,k−1 (t)
ti+k−1 − ti ti+k − ti+1

where k > 1 and i = 0, 1, . . . , n and when k = 1


(
1 for ti ≤ t < ti+1
Ni,1 (t) =
0 otherwise

14 / 47 BITS Pilani, Pilani Campus


B(asis)-splines

Definition
For a given knot vector T and order k, the associated B-spline
functions are
t − ti ti+k − t
Ni,k (t) = Ni,k−1 (t) + Ni+1,k−1 (t)
ti+k−1 − ti ti+k − ti+1

where k > 1 and i = 0, 1, . . . , n and when k = 1


(
1 for ti ≤ t < ti+1
Ni,1 (t) =
0 otherwise

In the context of Ni,k (t), division by zero is taken to be zero.

15 / 47 BITS Pilani, Pilani Campus


B(asis)-splines

Definition
For a given knot vector T and order k, the associated B-spline
functions are
t − ti ti+k − t
Ni,k (t) = Ni,k−1 (t) + Ni+1,k−1 (t)
ti+k−1 − ti ti+k − ti+1

where k > 1 and i = 0, 1, . . . , n and when k = 1


(
1 for ti ≤ t < ti+1
Ni,1 (t) =
0 otherwise

In the context of Ni,k (t), division by zero is taken to be zero.


How many elements should T have?

16 / 47 BITS Pilani, Pilani Campus


Properties of B-splines

1. Positivity: Ni,k (t) > 0, for ti < t < ti+k .

17 / 47 BITS Pilani, Pilani Campus


Properties of B-splines

1. Positivity: Ni,k (t) > 0, for ti < t < ti+k .


2. Local support: Ni,k (t) = 0 for t0 ≤ t ≤ ti , and
ti+k ≤ t ≤ tn+k .

18 / 47 BITS Pilani, Pilani Campus


Properties of B-splines

1. Positivity: Ni,k (t) > 0, for ti < t < ti+k .


2. Local support: Ni,k (t) = 0 for t0 ≤ t ≤ ti , and
ti+k ≤ t ≤ tn+k .
Pn
3. Partition of unity: i=0 Ni,k (t) = 1 for t ∈ [t0 , tm ]. Note:
the tm is not a typo!

19 / 47 BITS Pilani, Pilani Campus


Properties of B-splines

1. Positivity: Ni,k (t) > 0, for ti < t < ti+k .


2. Local support: Ni,k (t) = 0 for t0 ≤ t ≤ ti , and
ti+k ≤ t ≤ tn+k .
Pn
3. Partition of unity: i=0 Ni,k (t) = 1 for t ∈ [t0 , tm ]. Note:
the tm is not a typo!
4. Recursion: by definition!

20 / 47 BITS Pilani, Pilani Campus


Properties of B-splines

1. Positivity: Ni,k (t) > 0, for ti < t < ti+k .


2. Local support: Ni,k (t) = 0 for t0 ≤ t ≤ ti , and
ti+k ≤ t ≤ tn+k .
Pn
3. Partition of unity: i=0 Ni,k (t) = 1 for t ∈ [t0 , tm ]. Note:
the tm is not a typo!
4. Recursion: by definition!
5. Continuity: Ni,k (t) has C k−2 continuity at each “simple”
knot.

21 / 47 BITS Pilani, Pilani Campus


Properties of B-splines

1. Positivity: Ni,k (t) > 0, for ti < t < ti+k .


2. Local support: Ni,k (t) = 0 for t0 ≤ t ≤ ti , and
ti+k ≤ t ≤ tn+k .
Pn
3. Partition of unity: i=0 Ni,k (t) = 1 for t ∈ [t0 , tm ]. Note:
the tm is not a typo!
4. Recursion: by definition!
5. Continuity: Ni,k (t) has C k−2 continuity at each “simple”
knot.
6. Derivative: The derivative of Ni,k (t) is

dNi,k (t) k −1 k −1
= Ni,k−1 (t) − Ni+1,k−1 (t).
dt ti+k−1 − ti ti+k − ti+1

22 / 47 BITS Pilani, Pilani Campus


Examples of B-spline basis functions

Periodic or Uniform knot vector T = (0, 1, 2, 3, 4, 5, 6, 7)

0.6

0.5
N0,4 (t)
0.4
Ni,k (t)

N1,4 (t)
0.3 N2,4 (t)
N3,4 (t)
0.2

0.1

0.0
0 2 4 6
t

23 / 47 BITS Pilani, Pilani Campus


Examples of B-spline basis functions
(contd.)

Open Uniform knot vector T = (0, 0, 0, 0, 1, 2, 3, 4, 4, 4, 4)

1.0
N0,4 (t)
N1,4 (t)
0.8
N2,4 (t)
N3,4 (t)
0.6
Ni,k (t)

N4,4 (t)
N5,4 (t)
0.4
N6,4 (t)

0.2

0.0
0 1 2 3 4
t

24 / 47 BITS Pilani, Pilani Campus


Examples of B-spline basis functions
(contd.)

Non-uniform knot vector T = (0, 0, 1, 5, 8, 9, 9, 9, 10)


1.0
N0,4 (t)
N1,4 (t)
0.8
N2,4 (t)
N3,4 (t)
0.6
Ni,k (t)

N4,4 (t)

0.4

0.2

0.0
0 2 4 6 8 10
t

25 / 47 BITS Pilani, Pilani Campus


Examples of B-spline basis functions
(contd.)

Clamped knot vector T = (0, 0, 0, 1, 2, 5, 7, 7, 7)

1.0
N0,3 (t)
N1,3 (t)
0.8
N2,3 (t)
N3,3 (t)
0.6
Ni,k (t)

N4,3 (t)
N5,3 (t)
0.4

0.2

0.0
0 2 4 6
t

26 / 47 BITS Pilani, Pilani Campus


B-spline Curve

Definition
Given a set of n control points Pi , and an order 1 ≤ k ≤ n + 1, a
B-spline curve is defined as
n
X
P(t) = Pi Ni,k (t) for t ∈ [tk−1 , tn+1 ]
i=0

where Ni,k (t) are the B-spline basis functions and ti are elements
of a knot vector T = (t0 , t1 , . . . , tn+k ).

27 / 47 BITS Pilani, Pilani Campus


B-spline Curve

Definition
Given a set of n control points Pi , and an order 1 ≤ k ≤ n + 1, a
B-spline curve is defined as
n
X
P(t) = Pi Ni,k (t) for t ∈ [tk−1 , tn+1 ]
i=0

where Ni,k (t) are the B-spline basis functions and ti are elements
of a knot vector T = (t0 , t1 , . . . , tn+k ).

The point P(ti ) on the curve corresponding to ti ∈ T is called a


“knot point”. Portion of the curve between consecutive knot
points is called knot span.

28 / 47 BITS Pilani, Pilani Campus


B-spline Curve

Definition
Given a set of n control points Pi , and an order 1 ≤ k ≤ n + 1, a
B-spline curve is defined as
n
X
P(t) = Pi Ni,k (t) for t ∈ [tk−1 , tn+1 ]
i=0

where Ni,k (t) are the B-spline basis functions and ti are elements
of a knot vector T = (t0 , t1 , . . . , tn+k ).

The point P(ti ) on the curve corresponding to ti ∈ T is called a


“knot point”. Portion of the curve between consecutive knot
points is called knot span.
How many “control knobs” do B-spline curves have?

29 / 47 BITS Pilani, Pilani Campus


A Sample B-Spline Curve

8 B-spline curve
Control Polygon
7
Convex hull
Pi : (1, 1), (3, 8), (6, 3), (9, 6)
6 Knot Points
T = (0, 1, 2, 3, 4, 5, 6)
5

Note: Knot points 4


do not always lie 3
on the control
2
polygon.
1
2 4 6 8

30 / 47 BITS Pilani, Pilani Campus


Properties of B-spline curves

1. Geometry invariance: The shape of the curve remains


unchanged under rigid body transformation of the control
points.

31 / 47 BITS Pilani, Pilani Campus


Properties of B-spline curves

1. Geometry invariance: The shape of the curve remains


unchanged under rigid body transformation of the control
points.
8 B-spline curve 8 B-spline curve
Control Polygon Control Polygon
7 7

6 6

5 5

4 4

3 3

2 2

1 1
2 4 6 8 −8 −6 −4 −2

32 / 47 BITS Pilani, Pilani Campus


Properties of B-spline curves

2. Unlike Bézier curves, B-spline curves do not generally pass


through the first and last control points.

33 / 47 BITS Pilani, Pilani Campus


Properties of B-spline curves

2. Unlike Bézier curves, B-spline curves do not generally pass


through the first and last control points.
3. To make the end control points lie on the curve, we should
increase the multiplicity of the first and last knots to k. This
is the clamped knot vector. E.g. T = (0, 0, 0, 1, 2, 5, 7, 7, 7)
gives the following curve.

34 / 47 BITS Pilani, Pilani Campus


Properties of B-spline curves

2. Unlike Bézier curves, B-spline curves do not generally pass


through the first and last control points.
3. To make the end control points lie on the curve, we should
increase the multiplicity of the first and last knots to k. This
is the clamped knot vector. E.g. T = (0, 0, 0, 1, 2, 5, 7, 7, 7)
gives the following curve.

2 B-spline curve
Control Polygon

2 4 6 8 10 12 14

35 / 47 BITS Pilani, Pilani Campus


Properties of B-spline curves (contd.)

4. B-spline curve has a continuity of C k−p−1 at a knot with


multiplicity p. If a knot is repeated k − 1 times, the curve
coincides on the control polygon at that knot.

36 / 47 BITS Pilani, Pilani Campus


Properties of B-spline curves (contd.)

4. B-spline curve has a continuity of C k−p−1 at a knot with


multiplicity p. If a knot is repeated k − 1 times, the curve
coincides on the control polygon at that knot.
5. Local support: A single span of a B-spline curve is controlled
by k control points, and a single control point affects k spans.

37 / 47 BITS Pilani, Pilani Campus


Properties of B-spline curves (contd.)

4. B-spline curve has a continuity of C k−p−1 at a knot with


multiplicity p. If a knot is repeated k − 1 times, the curve
coincides on the control polygon at that knot.
5. Local support: A single span of a B-spline curve is controlled
by k control points, and a single control point affects k spans.
A control point Pi affects the curve in the parameter range
ti < t < ti+k , and the curve at a point t where tj < t < tj+1
is completely defined by control points Pj−(k−1) , . . . , Pj .
6. Convex Hull: Each span of the curve lies within the convex
hull of the control points affecting it.

38 / 47 BITS Pilani, Pilani Campus


Properties of B-spline curves (contd.)

4. B-spline curve has a continuity of C k−p−1 at a knot with


multiplicity p. If a knot is repeated k − 1 times, the curve
coincides on the control polygon at that knot.
5. Local support: A single span of a B-spline curve is controlled
by k control points, and a single control point affects k spans.
A control point Pi affects the curve in the parameter range
ti < t < ti+k , and the curve at a point t where tj < t < tj+1
is completely defined by control points Pj−(k−1) , . . . , Pj .
6. Convex Hull: Each span of the curve lies within the convex
hull of the control points affecting it.
7. B-spline curves also have variation diminishing property like
Bézier curves.

39 / 47 BITS Pilani, Pilani Campus


Example of Local Support and Convex
Hull

40 / 47 BITS Pilani, Pilani Campus


B-spline Curve generalizes Bézier Curve

• A B-spline curve of order k becomes a Bézier curve when


1. n + 1 = k i.e. k control points are used.
2. An open uniform knot vector is used

T = (t0 , t1 , . . . , tk−1 , tn+1 , . . . , tn+k )


where t0 = t1 = . . . = tk−1 = 0
and tn+1 = tn+2 = . . . = tn+k = 1

41 / 47 BITS Pilani, Pilani Campus


B-spline Curve generalizes Bézier Curve

• A B-spline curve of order k becomes a Bézier curve when


1. n + 1 = k i.e. k control points are used.
2. An open uniform knot vector is used

T = (t0 , t1 , . . . , tk−1 , tn+1 , . . . , tn+k )


where t0 = t1 = . . . = tk−1 = 0
and tn+1 = tn+2 = . . . = tn+k = 1

• There exists a generalization of the de Casteljau algorithm for


B-splines, called as the de Boor algorithm.

42 / 47 BITS Pilani, Pilani Campus


Calculating Ni,k (t)

t − ti
Ni,k (t) = Ni,k−1 (t)
ti+k−1 − ti
ti+k − t
+ Ni+1,k−1 (t)
ti+k − ti+1

where k > 1 and i = 0, 1, . . . , n


and when k = 1
(
1 for ti ≤ t < ti+1
Ni,1 (t) =
0 otherwise

43 / 47 BITS Pilani, Pilani Campus


Calculating Ni,k (t)

t − ti Ni,k
Ni,k (t) = Ni,k−1 (t) Ni,k−1 Ni+1,k−1
ti+k−1 − ti Ni,k−2 Ni+1,k−2 Ni+2,k−2
ti+k − t . . .
+ Ni+1,k−1 (t) . . .
ti+k − ti+1 Ni,1 Ni+1,1 ... Ni+k−1,1

where k > 1 and i = 0, 1, . . . , n


and when k = 1
(
1 for ti ≤ t < ti+1
Ni,1 (t) =
0 otherwise

44 / 47 BITS Pilani, Pilani Campus


Calculating Ni,k (t)

t − ti Ni,k
Ni,k (t) = Ni,k−1 (t) Ni,k−1 Ni+1,k−1
ti+k−1 − ti Ni,k−2 Ni+1,k−2 Ni+2,k−2
ti+k − t . . .
+ Ni+1,k−1 (t) . . .
ti+k − ti+1 Ni,1 Ni+1,1 ... Ni+k−1,1

where k > 1 and i = 0, 1, . . . , n


and when k = 1 Ni−k+1,k ... ... Ni,k
. .
. .
(
1 for ti ≤ t < ti+1 Ni−2,3 Ni−1,3 Ni,3
Ni,1 (t) = Ni−1,2 Ni,2
0 otherwise
Ni,1

45 / 47 BITS Pilani, Pilani Campus


Calculating Ni,k (t)

t − ti Ni,k
Ni,k (t) = Ni,k−1 (t) Ni,k−1 Ni+1,k−1
ti+k−1 − ti Ni,k−2 Ni+1,k−2 Ni+2,k−2
ti+k − t . . .
+ Ni+1,k−1 (t) . . .
ti+k − ti+1 Ni,1 Ni+1,1 ... Ni+k−1,1

where k > 1 and i = 0, 1, . . . , n


and when k = 1 Ni−k+1,k ... ... Ni,k
. .
. .
(
1 for ti ≤ t < ti+1 Ni−2,3 Ni−1,3 Ni,3
Ni,1 (t) = Ni−1,2 Ni,2
0 otherwise
Ni,1

This needs practice!

46 / 47 BITS Pilani, Pilani Campus


Self Study: Closed B-spline Curves

Don’t Skip It!


There are two techniques:
• Wrapping control points
• Wrapping knots
Study this webpage.

47 / 47 BITS Pilani, Pilani Campus

You might also like