Sei sulla pagina 1di 15

AML710 CAD

LECTURE 12

CUBIC SPLINE CURVES

Cubic Splines
Matrix formulation
Normalised cubic splines
Alternate end conditions
Parabolic blending

CUBIC SPLINE
The name spline comes from the physical (instrument) spline draftsmen
use to produce curves
A general cubic polynomial is represented by:

y = Ax 3 + Bx 2 + Cx + D
Mathematically spline is a piecewise polynomial of degree k with continuity
of derivatives of order k-1 at the common joints between the segments.
Thus, the cubic spline has second order or C2 continuity
Parametric representation of cubic spline:
A single segment of cubic spline is represented as
4

P(t ) = Bi t i 1
i =1

t1 t t 2

P(t ) = [x(t )

y (t ) z (t )]

x(t ) = Bi x t i 1
i =1

4
i 1
y (t ) = Bi y t t1 t t 2
i =1

z (t ) = Bi z t i 1
i =1

CUBIC SPLINE (contd.)


Here t1 and t2 are the values of the parameter at the two ends of the curve
segment. We can write the expanded form of the cubic spline as follows

P(t ) = B1 + B2t + B3t 2 + B4t 3

t1 t t 2

The tangent vectors are obtained by differentiating the above expression


4

P(t ) = [x(t )

y(t ) z (t )] = Bi (i 1)t i 2
i =1

t1 t t 2

P2
P2(t2)
P1
P1(t1)

Parametric Form of Cubic Spline


Without loss of generality we can assume t1=0 and write the new range as

0 t t2

P(0) = B1 = P1
P(0) = B2 = P1
P (t 2 ) = B1 + B2t 2 + B3t 22 + B4t 23
P(t 2 ) = B2 + 2 B3t 2 + 3B4t 22
Solving for B3,B4 gives

3( P2 P1 ) 2 P1 P2

t 22
t2
t2
2( P1 P2 ) P1 P2
B4 =
+ 2+ 2
t 23
t2 t2
B3 =

Parametric Form of Cubic Spline


3( P P ) 2 P P
2( P P ) P P
P(t ) = P1 + P1t + 2 2 1 1 2 t 2 + 1 3 2 + 21 + 22 t 3
t2
t2 t2
t2
t2
t2

0 t t2
Pk+2

Pk+2

Multiple Segment Spline curve

tk+2

Pk+1

Pk+1
tk+1
Pk
Pk
tk

Curvature of parametric Cubic Spline


4

P(t ) = (i 1)(i 2) Bi t i 3
i =1

Curvature at t= tk+1 is continuous


Pk+1

t1 t t 2
Pk+2
tk+2

Pk+1
tk+1
Pk
Pk
tk

Multi-segment Cubic Spline

P(t = t 2 ) = P(t = 0)

6 B4t 2 + 2 B3 = 2 B3
2( P P ) P P 3( P P ) 2 P P
3( P P ) 2 P P
6t 2 1 3 2 + 21 + 22 + 2 2 2 1 1 2 = 2 3 2 2 2 3
t2
t2 t2
t2
t2
t2
t2
t2
t2

Multiplying both sides by t2t3

t3 P1 + 2(t3 + t 2 ) P2 + t 2 P3 =

3 2
t 2 ( P3 P2 ) + t32 ( P2 P1 )
t 2t3

First-segment
2( P P ) P P
3( P P ) 2 P P
Pk (t ) = Pk + Pkt + k +21 k k k +1 t 2 + k 3 k +1 + 2k + 2k +1 t 3
t k +1
t k +1 t k +1
t k +1
t k +1 t k +1

Second-segment
3( P P ) 2 P
2( P P ) P
P
P
Pk +1 (t ) = Pk +1 + Pk+1t + k + 22 k +1 k +1 k + 2 t 2 + k +13 k + 2 + 2k +1 + 2k + 2 t 3
tk +2
tk + 2
tk +2
tk +2
tk + 2 tk + 2

With curvature continuity ensured by


t k + 2 Pk + 2(t k +1 + t k + 2 ) Pk+1 + t k +1 Pk+ 2 =

3
t k2+1 ( Pk + 2 Pk +1 ) + t k2+ 2 ( Pk +1 Pk )
t k +1t k + 2

Matrix form for calculating interior tangent vectors


t3
0

.
.

2(t 2 + t3 )
t2
2(t3 + t 4 )
t4
0
.

t5
.

.
.

.
.

0
t3

.
0

2(t 4 + t5 ) t 4
.
.

0
.

.
.

.
0

. P1
P
2
P3

.
. .
.
. .

2(t n + tn 1 ) tn 1 Pn
.

.
tn

3 2

t2 ( P3 P2 ) + t32 ( P2 P1 )

t 2t3

3 2

t3 ( P4 P3 ) + t 42 ( P3 P2 )

t 3t 4

.
=

t n21 ( Pn Pn 1 ) + t n2 ( Pn 1 Pn 2 )

t n 1t n

Properties ?

Matrix form for calculating interior tangent vectors


1 0
0 t
3

0 0
0 0

. .
. .

. .

2(t 2 + t3 )
t2
2(t3 + t 4 )
t4
0
.

t5
.

t3
2(t 4 + t5 ) t 4
.
.
.
0

.
tn

P1
.
P
2
P3


.
.

.
. .
2(t n + t n 1 ) t n 1 .

0
1 Pn
.

P1

3
2
2

t 2 ( P3 P2 ) + t3 ( P2 P1 )
t 2 t3

3 2
2
t
(
P
P
)
t
(
P
P
)

3
4
3
4
3
2
t3t 4

3 2
2
t
P
P
t
P
P
(
)
(
)

n
n 1
n2
t t n 1 n n 1
n

1
n

Pn

[M ][P] = [R]

[P] = [M ] [R ]
1

Generalizing Coefficients
B1k = Pk
B2 k = Pk
3( Pk +1 Pk ) 2 Pk Pk+1

t k2+1
t k +1 t k +1
2( Pk Pk +1 ) Pk Pk+1
B4 k =
+ 2 + 2
t k3+1
t k +1 t k +1
B3k =

Pk (t ) = Bik t i 1
i =1

0 t t k +1

1 k n 1

Coefficient Matrix and Blending functions


1
B1k 0
B 3
[B] = 2k = t 2
B3k k +1
2
B4 k 3
t k +1
4

Pk (t ) = Bik t i 1
i =1

1
2

t k +1
1
t k2+1

0
3

0 t t k +1

t k2+1
2
3
t k +1

0
P
0 k

1
Pk
t k +1 Pk +1
1 P
k +1
t k2+1

1 k n 1

Blending functions
4

Pk (t ) = Bik t i 1
i =1

P k (t ) = 1 t t 2

0 t t k +1

1 k k n 1

B1k
B
3 2k
t
B3k

B4 k

0 t t k +1

Substituting from previous eqn for [B]


Pk
P
P k ( ) = [F1 ( ) F2 ( ) F3 ( ) F4 ( )] k +1 0 1
Pk

Pk+1

where

1 k n 1

= t / t k +1

Blending functions
F1k ( ) = 2 3 3 2 + 1
F2 k ( ) = 2 3 + 3 2
F3k ( ) = ( 2 2 + 1)t k +1
F4 k ( ) = ( 2 )t k +1

Using the definition of blending functions

P k ( ) = [F ][G ]
where

[F ] = [F1 ( )

F2 ( ) F3 ( ) F4 ( )]

Pk
P
[G ] = k +1
Pk

Pk+1

Blending functions
1.2

F1k ( ) = 2 3 3 2 + 1

f1
f2
f3
f4

F2 k ( ) = 2 3 + 3 2
F3k ( ) = ( 2 2 + 1)t k +1

0.8

F4 k ( ) = ( 2 )t k +1

0.6

0.4

F1k

0.2

-0.2

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

=0
F1k (0) = 1, F2 k (0) = F3k (0) = F4 k (0) = 0
=1
F2 k (1) = 1, F1k (1) = F3k (1) = F4 k (1) = 0
F2 k ( ) = 1 F1k ( )

Spline Properties
The curve is produced with 2 end points 2 tangent vectors
and values of the parameter tk
The curvature matching at the internal joins itself is not
sufficient to ensure the smoothness
To get a smooth curve the right choice of tks to minimize the
B3 and B4 values is recommended
As it increases the computational effort, for many practical
F1k
applications we
can get smooth splines by chord length
approximation

Algebraic form to Geometric form


Let us consider the algebraic form of a cubic Hermite curve

P(t ) = B1 + B2t + B3t 2 + B4t 3

t1 t t 2

Without loss of generality we can assume t1=0 and write the new range as

0 t 1

P(0) = B1 = P0
P(0) = B2 = P0
P(1) = P0 + P0 + B3 + B4 = P1
P(1) = P0 + 2 B3 + 3B4 = P1

Solving for algebraic coefficients B3,B4 gives

B3 = 2 P0 + P0 2 P1 + P1
B4 = 3P0 2 P0 + 3P1 P1
Substituting in the algebraic form and rearranging terms:
P (t ) = (2t 3 3t 2 + 1) P0 + (2t 3 + 3t 2 ) P1 + (t 3 2t 2 + t ) P0 + (t 3 t 2 ) P1 0 t 1
This can be simplified to the following geometric form:

P(t ) = F1 (t ) P0 + F2 (t ) P1 + F3 (t ) P0 + F4 (t ) P1

0 t 1

Where P1 , P1, P2 , P2 are called geometric coefficients.

Normalized Cubic Splines


If data points are uniformly distributed then acceptably smooth curves can
be obtained by normalising i.e., taking tk=1 for each segment. The Hermite
basis functions or blending functions are now given as follows:

F1 (t ) = 2t 3 3t 2 + 1

0 t 1

F2 (t ) = 2t 3 + 3t 2
F3 (t ) = t 3 2t 2 + 1
F4 (t ) = t 3 t 2

[F ] = [T ][N ] = [t 3

t2

1
2 2 1
3 3 2 1

t 1
0
0
1
0

0
0
0
1

P(t ) = [F ][G ] = [T ][N ][G ]

Normalized Cubic Splines

P(t ) = [F ][G ] = [T ][N ][G ]


Here [T] and [N] are constant for all segments
We need to determine [G] for each of them
1 0 . . . . P1 3[( P3 P2 ) + ( P2 P1 )]
1 4 1 0 . . P 3[( P P ) + ( P P )]
4
3
3
2

0 1 4 1 0 . P3
.

=
.

. . . . . . .

. . 0 1 4 1 .
.


. . . . 0 1 Pn 3[( Pn Pn 1 ) + ( Pn 1 Pn 2 )]

Normalized Cubic Splines - Example


The position vectors of a normalized cubic spline
are given as (0 0), (1 1), (2 -1) and (3 0). The tangent
vectors at the ends are both (1 1).
The 2 internal tangent vectors are calculated
and both are equal to (1 0.8). Calculate the points
on the curve at t=1/3 and 2/3 for at least one segments.

P(t ) = [F ][G ] = [T ][N ][G ]


at t=1/3 -> P(t)= [1/3 63/135]=[0.333 0.467] and
at t=2/3 -> P(t)= [2/3 126/135]=[0.667 0.933]

10

Cubic Spline End Conditions


Clamped End conditions
Example
This illustrates the use of clamped or complete spline interpolation
where end slopes are prescribed. Zero slopes at the ends of an
interpolant to the values of a certain distribution are enforced.
x = -4:4; y = [0 .15 1.12 2.36 2.36 1.46 .49 .06 0];
cs = spline(x,[0 y 0]);
xx = linspace(-4,4,101);
plot(x,y,'o',xx,ppval(cs,xx),'-');

Alternate End Conditions


Relaxed End conditions
If the curvature at the ends are assumed zero
relaxed or natural end condition results

P(0) = P(t n ) = 0

3( P P ) 2 P P
P(0) = 2 B3 = 2 2 2 1 1 2 = 0
t2
t2
t2

P1 +

3( P P ) 2 P P
P(t n ) = 2 B3 + 6 B4t n = 2 2 2 1 1 2 = 0
t2
t2
t2

P2 3( P2 P1 )
=
2
2t 2

2 Pn1 + 4 Pn =

6( Pn Pn 1 )
tn

The first and last rows of matrices [M] and [R] are
modified respectively as

[1

3( P P )
1 / 2 0 L][P1] = 2 1
2t 2

and

[L

6( P P )
0 2 4][Pn] = n n 1
tn

Clamped and Relaxed end conditions can be mixed

11

Alternate End Conditions


Cyclic end conditions
This requires both the tangent vector and the
curvatures at the ends be equal. These conditions
are useful to produce closed or repeating cubic
curves

P(0) = P(t n )
P(0) = P(t n )

Anti-cyclic end conditions

P(0) = P(t n )
P(0) = P(t n )

Effect of End Tangent Vector

12

Effect of Tangent Vector Magnitude

Effect of Tangent Vector Magnitude

13

Effect of Tangent Vector Magnitude

Limitations of Cubic Splines


If the number of data points are large
computation time required to invert tangent
vector matrix can be excessive.
Parametric cubic curves cannot represent conic
sections exactly.
They poorly approximate asymptotic curves.
If not controlled properly, exhibit spurious
oscillations.
Discontinuities in third derivative may give rise to
unwanted inflection points
Solutions:
1. Adding physical analog of longitudinal tension
2. Modifying the blending functions (Parabolic)

14

Parabolic Blending
A parabolically blended
curve can be
represented as: C (t ) = (1 t ) p (r ) + tq ( s )
P1
where r, s and t are
parameters. P(r), q(s)
are parametric
P2
parabola through P1,
P3
P2, P3 and P2, P3,
P4 respectively as
shown

P4

15

Potrebbero piacerti anche