Vous êtes sur la page 1sur 33

Computer Graphics

Computer Graphics

Lecture 14

Curves and Surfaces II

Computer Graphics Computer Graphics Lecture 14 Curves and Surfaces II

Computer Graphics

Spline

A long flexible strips of metal used by draftspersons to lay out the surfaces of

Computer Graphics Spline • A long flexible strips of metal used by draftspersons to lay outf airplanes, cars and ships • Ducks weights attached to the splines were used to pull the spline in differe nt directions • The metal splines had second order continuity 10/10/2008 Lecture 5 2 " id="pdf-obj-1-13" src="pdf-obj-1-13.jpg">

airplanes, cars and ships

Ducks weights attached to the splines were used to pull the spline in different directions

The metal splines had second order continuity

Computer Graphics Spline • A long flexible strips of metal used by draftspersons to lay outf airplanes, cars and ships • Ducks weights attached to the splines were used to pull the spline in differe nt directions • The metal splines had second order continuity 10/10/2008 Lecture 5 2 " id="pdf-obj-1-27" src="pdf-obj-1-27.jpg">

10/10/2008

Lecture 5

2

Computer Graphics

B-Splines (for basis splines)

B-Splines

Another polynomial curve for modelling curves and surfaces

Consists of curve segments whose polynomial coefficients only depend on just a few control points

Computer Graphics B-Splines (for basis splines) • B-Splines – Another polynomial curve for modelling curves and

Local control

Segments joined at knots

10/10/2008

Lecture 5

Computer Graphics B-Splines (for basis splines) • B-Splines – Another polynomial curve for modelling curves and

3

Computer Graphics

B-splines

The curve does not necessarily pass through the control points

The shape is constrained to the convex hull made by the control points

Uniform cubic b-splines has C2 continuity

Computer Graphics B-splines • The curve does not necessarily pass through the control points • The

Higher than Hermite or Bezier curves

Computer Graphics B-splines • The curve does not necessarily pass through the control points • The

Computer Graphics

Basis Functions

12 4 8 t
12
4
8
t

knots

We can create a long curve using many knots and B-splines The unweighted cubic B-Splines have been shown for clarity.

These are weighted and summed to produce a curve of the desired shape

Computer Graphics Basis Functions 12 4 8 t knots • We can create a long curve

10/10/2008

Lecture 5

Computer Graphics

Generating a curve

X(t)‏ t
X(t)‏
t
Computer Graphics Generating a curve X(t)‏ t t Lecture 5 10/10/2008 Opposite we see an example
t Lecture 5 10/10/2008
t
Lecture 5
10/10/2008

Opposite we see an example of a shape to be

generated.

Here we see the curve again with the weighted B-Splines which

generated the required

shape.

6

Computer Graphics

The basic one:

Uniform Cubic B-Splines

Cubic B-splines with uniform knot-vector is the most commonly used form of B-splines

Computer Graphics The basic one: Uniform Cubic B-Splines • Cubic B-splines with uniform knot-vector is the

( )

X

t

t

T

MQ

(i)

 

where

:

Q

(i)

x

(

i

1

3

3

 

1

3

6

3

 

M

t

T

6

(

3

1

t

t

i

)

, (

4

0

t

3

t

3

1

2

)

i

,

t

i

: knots,

 

3

i

10/10/2008

3

t

 t ) i t i t     0 0 ,  i
t
)
i
t
i
t
0
0
,
i  1
0
1
, ...,
for
,1
x
i
 
t
Lecture 5
7

Computer Graphics

Cubic B-Splines

The unweighted spline set of 10 control points, 10 splines, 14 knots, and but only 7 intervals.

You can see why t 3 to t 4 is the first interval with a curve since it is the first with all four B-Spline functions.

t 9 to t 10 is the last interval

Computer Graphics Cubic B-Splines • The unweighted spline set of 10 control points, 10 splines, 14
m 8 10/10/2008 Lecture 5 6 m+1 4 0 8 3 t
m
8
10/10/2008
Lecture 5
6
m+1
4
0
8
3
t
Computer Graphics Domain of the function • Order k, Degree k-1 • Control points Pi (i=0,…,m)
Computer Graphics
Domain of the function
• Order k, Degree k-1
• Control points Pi (i=0,…,m)
Knots : tj, (j=0,…, k + m)
• The domain of the function tk-1 ≦ t≦ tm+1
– Below, k = 4, m = 9,
domain, t3 ≦ t≦ t10
0
t
m+1
3

Computer Graphics

Cubic Uniform B-Spline

2D example

For each i 4 , there is a knot between Q i-1 and Q i at t = t i .

Initial points at t 3 and t m+1 are also knots. The following illustrates an example with control points set P 0 …‏P 9 :

Computer Graphics Cubic Uniform B-Spline 2D example • For each i  4 , there is
Lecture 5 10/10/2008
Lecture 5
10/10/2008
Computer Graphics Cubic Uniform B-Spline 2D example • For each i  4 , there is
Computer Graphics Cubic Uniform B-Spline 2D example • For each i  4 , there is

Control point.

Knot.

10

Computer Graphics

Uniform Non-rational B-Splines.

First segment Q 3 is defined by point P 0 through P 3 over the

range t 3 = 0 to t 4 = 1.

So m at least 3 for cubic spline.

Computer Graphics Uniform Non-rational B-Splines. • First segment Q is defined by point P through P
Q 3 P0 P2 P3 P1 Lecture 5 10/10/2008
Q 3
P0
P2
P3
P1
Lecture 5
10/10/2008
Computer Graphics Uniform Non-rational B-Splines. • First segment Q is defined by point P through P
Computer Graphics Uniform Non-rational B-Splines. • First segment Q is defined by point P through P

Control point.

Knot.

11

Computer Graphics

Uniform Non-rational B-Splines.

Second segment Q 4 is defined by point P 1 through P 4 over the range t 4 = 1 to t 5 = 2.

Computer Graphics Uniform Non-rational B-Splines. • Second segment Q is defined by point P through P
P3 P4 Q 4 P2 P1 Lecture 5 10/10/2008
P3
P4
Q 4
P2
P1
Lecture 5
10/10/2008
Computer Graphics Uniform Non-rational B-Splines. • Second segment Q is defined by point P through P
Computer Graphics Uniform Non-rational B-Splines. • Second segment Q is defined by point P through P

Control point.

Knot.

12

Computer Graphics B-Spline : A more general definition A Bspline of order k is a parametric
Computer Graphics
B-Spline :
A more general definition
A Bspline of order k is a parametric curve composed of a linear
combination of basis B-splines Bi,n
Pi (i=0,…,m) the control points
Knots: tj, j=0,…, k + m
The B-splines can be defined by
m
p t
( )
P B
( )
t
i
i n
,
i  0
1, t
 
t
t
i
i
1
B
( ) 
t
i ,1
0, otherwise
t
t
t
t
i
i
k
B
( )
t
B
( )
t
B
( )
t
i k
,
i
,
k 
1
i
1,
k
1
t
t
t
t
10/10/2008
i
  1
k
Lecture 5
i
i
  1
k
i
13

Computer Graphics

The shape of the basis functions

Bi,2 : linear basis functions Order = 2, degree = 1 C0 continuous

Computer Graphics The shape of the basis functions B i,2 : linear basis functions Order =
Computer Graphics The shape of the basis functions B i,2 : linear basis functions Order =

10/10/2008

http://www.ibiblio.org/e-notes/Splines/Basis.htm

Lecture 5

14

Computer Graphics

The shape of the basis functions

Bi,3 : Quadratic basis functions Order = 3, degree = 2 C1 continuous

Computer Graphics The shape of the basis functions B i,3 : Quadratic basis functions Order =

10/10/2008

Computer Graphics The shape of the basis functions B i,3 : Quadratic basis functions Order =

http://www.ibiblio.org/e-notes/Splines/Basis.htm

Lecture 5

15

Computer Graphics

The shape of the basis functions

Bi,4 : Cubic basis functions Order = 4, degree = 3 C2 continuous

Computer Graphics The shape of the basis functions B i,4 : Cubic basis functions Order =

10/10/2008

Computer Graphics The shape of the basis functions B i,4 : Cubic basis functions Order =

http://www.ibiblio.org/e-notes/Splines/Basis.htm

Lecture 5

16

Computer Graphics

Uniform / non-uniform B-splines

Uniform B-splines

The knots are equidistant / non-equidistant The previous examples were uniform B-splines

t

0

,

t

1

,

t

2

,...,

t

m

were equidistant, same interval

Parametric interval between knots does not have to be equal.

Computer Graphics Uniform / non-uniform B-splines • Uniform B-splines – The knots are equidistant / non-equidistant
Computer Graphics Uniform / non-uniform B-splines • Uniform B-splines – The knots are equidistant / non-equidistant

Non-uniform B-splines

Computer Graphics

Non-uniform B-splines.

Blending functions no longer the same for each interval. Advantages

Continuity at selected control points can be reduced to C 1 or lower allows us to interpolate a control point without side-effects.

Can interpolate start and end points. Easy to add extra knots and control points.

Good for shape modelling !

Computer Graphics Non-uniform B-splines. • Blending functions no longer the same for each interval. • Advantages

10/10/2008

Computer Graphics

Controlling the shape of the curves

Can control the shape through

Control points

Overlapping the control points to make it pass through a specific point

Knots

Changing the continuity by increasing the multiplicity at some knot (non-uniform bsplines)

Computer Graphics Controlling the shape of the curves • Can control the shape through – Control

Computer Graphics

Controlling the shape through

control points

P2 P0 P3 P1
P2
P0
P3
P1

First knot shown with 4 control points, and their convex hull.

Computer Graphics Controlling the shape through control points P2 P0 P3 P1 First knot shown with

10/10/2008

Lecture 5

20

Computer Graphics

Controlling the shape through

control points

P0
P0
P2
P2
P4 P3 P1
P4
P3
P1

intersection of the 2 convex hulls.

shown with their respective convex hulls.

First two curve segments

Centre Knot must lie in the

Computer Graphics Controlling the shape through control points P0 P2 P4 P3 P1 intersection of the

10/10/2008

Lecture 5

21

Computer Graphics

Repeated control point.

Computer Graphics Repeated control point. P0 P1=P2 P4 P3 Lecture 5 10/10/2008 shown with their respective
P0 P1=P2 P4 P3 Lecture 5 10/10/2008
P0
P1=P2
P4
P3
Lecture 5
10/10/2008

shown with their respective convex hulls.

First two curve segments

the line that joins the 2

The curve is forced to lie on

convex hulls.

22

Computer Graphics

Triple control point.

Computer Graphics Triple control point. P0 P1=P2=P3 P4 Lecture 5 10/10/2008 Both convex hulls collapse to
P0 P1=P2=P3 P4 Lecture 5 10/10/2008
P0
P1=P2=P3
P4
Lecture 5
10/10/2008

Both convex hulls collapse to straight lines all the curve must lie on these lines.

shown with their respective

First two curve segments

convex hulls.

23

Computer Graphics Controlling the shape through knots • Smoothness increases with order k in B i,k
Computer Graphics
Controlling the shape through knots
• Smoothness increases with order k in B i,k
Quadratic, k = 3, gives up to C 1 continuity.
– Cubic, k = 4 gives up to C 2 continuity.
However, we can lower continuity order too with Multiple
Knots,
ie.
Knots are coincident and so
t i = t i+1 = t i+2 = …
now we have non-uniform knot intervals.
• A knot with multiplicity p is continuous to the
(k-1-p)th derivative.
• A knot with multiplicity k has no continuity at all, i.e. the
curve is broken at that knot.
 1, t
 
t
t
i
i
1
B
( ) 
t
i ,1
0, otherwise
t
t
t
t
i
i
k
10/10/2008
Lecture 5
B
( )
t
B
( )
t
B
( )
t
24
i k
,
i
,
k 
1
i
1,
k
1
t
t
t
t
i
  1
k
i
i
  1
k
i

Computer Graphics

B-Splines at multiple knots

Cubic B-spline Multiplicities are indicated

Computer Graphics B-Splines at multiple knots • Cubic B-spline • Multiplicities are indicated

Computer Graphics

Knot multiplicity

Consider the uniform cubic (n=4) B-spline curve, t={0,1,‏…‏,13}, m=9 , n=4, 7 segments

Computer Graphics Knot multiplicity • Consider the uniform cubic (n=4) B-spline curve, t={ 0,1,‏…‏,13} , m=9

Computer Graphics

Knot multiplicity

Double knot at 5, knot ={0,1,2,3,4,5,5,6,7,8,9,10,11,12} 6 segments, continuity = 1

Computer Graphics Knot multiplicity • Double knot at 5, • knot ={0,1,2,3,4,5,5,6,7,8,9,10,11,12} • 6 segments, continuity
Computer Graphics Knot multiplicity • Double knot at 5, • knot ={0,1,2,3,4,5,5,6,7,8,9,10,11,12} • 6 segments, continuity

Computer Graphics Knot multiplicity

Triple knot at 5 knot={0,1,2,3,4

,5,5,5,6,7,8,9,10

,11}

5 segments

Computer Graphics Knot multiplicity • Triple knot at 5 • knot={0,1,2,3,4 ,5,5,5,6,7,8,9,10 ,11} • 5 segments
Computer Graphics Knot multiplicity • Triple knot at 5 • knot={0,1,2,3,4 ,5,5,5,6,7,8,9,10 ,11} • 5 segments
   

Computer Graphics

Knot multiplicity

Quadruple knot at 5

• 4 segments

4 segments

Computer Graphics

Summary of B-Splines.

Functions that can be manipulated by a series of control points with C 2 continuity and local control.

• Don’t‏pass‏through‏their‏control‏points,‏although‏can‏be‏ forced. Uniform

Knots are equally spaced in t.

Non-Uniform

Knots are unequally spaced

– – Allows addition of extra control points anywhere in the set.

Computer Graphics Summary of B-Splines. • Functions that can be manipulated by a series of control

10/10/2008

Lecture 5

30

Computer Graphics

Summary cont.

Do not have to worry about the continuity at the join points

For interactive curve modelling

B-Splines are very good.

Computer Graphics Summary cont. • Do not have to worry about the continuity at the join

10/10/2008

Lecture 5

31

Computer Graphics

2 nd Practical

Use OpenGL to draw the teapot

You must extend your code in the first assignment

Bonus marks for making it nice

Bump mapping Texture mapping Or whatever

Computer Graphics 2 Practical • Use OpenGL to draw the teapot • You must extend your

Deadline : 10 th December

Computer Graphics

Reading for this lecture

Foley at al., Chapter 11, sections 11.2.3, 11.2.4, 11.2.9, 11.2.10, 11.3 and 11.5.

Introductory text, Chapter 9, sections 9.2.4, 9.2.5, 9.2.7, 9.2.8 and 9.3.

.

Computer Graphics Reading for this lecture • Foley at al., Chapter 11, sections 11.2.3, 11.2.4, 11.2.9,

10/10/2008

Lecture 5

33