L12 Cubic Spline
L12 Cubic Spline
L12 Cubic Spline
LECTURE 12
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
t1 t t 2
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)
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 =
0 t t2
Pk+2
Pk+2
tk+2
Pk+1
Pk+1
tk+1
Pk
Pk
tk
P(t ) = (i 1)(i 2) Bi t i 3
i =1
t1 t t 2
Pk+2
tk+2
Pk+1
tk+1
Pk
Pk
tk
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
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
3
t k2+1 ( Pk + 2 Pk +1 ) + t k2+ 2 ( Pk +1 Pk )
t k +1t k + 2
.
.
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 ?
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
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
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
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
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
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
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
0 1 4 1 0 . P3
.
=
.
. . . . . . .
. . 0 1 4 1 .
.
. . . . 0 1 Pn 3[( Pn Pn 1 ) + ( Pn 1 Pn 2 )]
10
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
11
P(0) = P(t n )
P(0) = P(t n )
P(0) = P(t n )
P(0) = P(t n )
12
13
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