Cad 02

You might also like

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

Computer Aided Design

Outline


Interpolation and polynomial approximation

Interpolation

Lagrange

Cubic Splines
Approximation

Bézier curves

B-Splines

1
Computer Aided Design


Some vocabulary (again ;)

Control point : Geometric point that serves as
support to the curve

Knot : a specific value of the parameter u
corresponding to a joint between pieces of a curve

Knot sequence : the set of knots values (in an
increasing order).

Wolfram research
2
Computer Aided Design


Interpolation

The curve passes through the control points

Approximation

The curve doesn't necessary passes through the
control points

But these have an influence ...

Statistic approaches ?

Least squares

« Kriging »

Not very adapted to geometric modelling

3
Computer Aided Design

Interpolation

4
Computer Aided Design
Interpolation

Interpolation

We want draw a regular and smooth parametric
curve through a certain number n of points Pi

Several families of base functions are available

Most obvious are polynomials

There are others -

Trigonometric functions (by mean of a Fourier decomposition for
instance)

Power functions

etc...

5
Computer Aided Design
Interpolation


We must choose the parametrization (nodal
sequence)

Uniform u2=2

u1=1

u0=0
un-1=n-1

6
Computer Aided Design
Interpolation


Or non-uniform u2=7

u1=2.5

u0=0
un-1=15

7
Computer Aided Design
Interpolation


Can we choose u as a curvilinear abscissa ?

In principle no since we don't know the final shape
of the curve beforehand (with the exception of
interpolation points)

We will see later that it is often impossible that u
corresponds with s exactly along the whole curve
using analytical functions.

But nothing forbids to get close to that –
numerically...

8
Computer Aided Design
Interpolation


Parametrization as an approximate arc length

u2=d1+d2

d2
u1=d1

d1 u0=0
dn-1
un-1=d1+...+dn-1

9
Computer Aided Design
Interpolation


In all cases, we want to have :
xu i = xi
P u i =P i ≡
{
y u i = y i

We are going to interpolate the functions x(u) and
y(u) with ONE polynomial with n parameters

This one must be of order p=n-1 :
n−1
2 n−1 j
x u=a 0a 1 ua 2 u ⋯a n−1 u =∑ a j u
j=0

We set the linear system and solve...
x u 1 =x 1

{ ⋮
x u n−1 =x n−1 10
Computer Aided Design
Interpolation


Vandermonde matrix
2 n−1
1 u0 u ⋯ u
a0 x0

( )( ) ( )
0 0
x u 1 =x 1

{ ⋮
x u n−1 =x n−1
1 u1
⋮ ⋮
u

2
⋯ u

2
1

n−1

1 u n−1 u n−1 ⋯ u n−1 a n−1
n−1
a1 = x 1
1

x n−1
Can be solved by classical numerical methods, but ...

The condition number of this matrix is VERY bad
 It must be solved for each RHS member ( ( xi ) or ( yi ) )
, or have to take the inverse of this matrix, or perform
an LU decomposition.

11
Computer Aided Design
Interpolation


Instead of setting the polynomial in x and in y
and solving, we can put it under the following
form : n−1

{
p
x u=∑ x i l i u n−1
0
n−1
⇔ P u=∑ P i l ip u
p 0
y u=∑ y l u
i i
0

, where the lip(u) are a polynomial basis of order p=n-1.



These polynomials verify, for an interpolation :
p
l u j = ij
i

We have only one computation to do for any
position of the interpolation points, knowing the ui
(the parametrization) 12
Computer Aided Design
Interpolation

 Lets determine the li(u) : they are of order n-1


and such that : l p u =1 ; i= j
l ip u j = ij ⇔
{ i
p
j

l u j =0 ; i≠ j
i

lip may be factored by (u-uj) for j≠i


p
l u=k u−u 0 u−u 1 ⋯u−u i−1 u−u i1 ⋯u−u n−1 
i
k is such that l ip ui =1
k =ui −u 0 ui −u 1 ⋯ui −u i−1 u i −u i1 ⋯ui −un−1 −1
n−1
p (u−u j )
l (u)=
i ∏
j=0, j≠i (ui −u j )

The lip are the Lagrange polynomials of order p


13
Computer Aided Design
Interpolation


Lagrange polynomials
p n−1
p l u u−u j 
l u= p '
i = ∏
l u i u−ui  j=0,i≠ j u i −u j 
n−1
p
l u=∏ u−u j 
j=0
n−1
p'
l (u i )= ∏ (u i −u j ) (first derivative w/r to u at u=u i )
j=0 , j≠i


Properties
n−1
Interpolation Partition of unity l
p
∑ i (u)=1
l ip u j = ij n−1
0

x(u)=∑ x i l ip (u) with x i =1∀i


0 14
Computer Aided Design
Lagrange polynomials


Order 4
 The ui are evenly
distributed between
u=0 and u=1

The sum is equal to 1
(partition of unity)

Presence of negative
values

15
Computer Aided Design
Lagrange polynomials


Order 10

Presence of huge
overshoots near the
boundaries

16
Computer Aided Design
Lagrange polynomials


The interpolation is represented by the following
form :
n−1 n−1
p p (u−u i )
P (u)=∑ P l (u) with l (u)=
i i i ∏
i=0 j=0, i≠ j (u j −u i )


Two things worth noting:

The curve depends linearly on the position of the
points

It is formed by a weighted sum of basis functions
that express the influence of each point on the
curve 17
Computer Aided Design
Lagrange polynomials


An experiment

We approximate a circle by an increasing number
of points

Simultaneously , approximation order increases
 In every case, the curve is C

18
Computer Aided Design
Lagrange polynomials

3 points, order 2 (a parabola !)

19
Computer Aided Design
Lagrange polynomials

5 points, order 4

20
Computer Aided Design
Lagrange polynomials

11 points, order 10

21
Computer Aided Design
Lagrange polynomials

21 points, order 20

22
Computer Aided Design
Lagrange polynomials


Does it work ?

The points were set exactly on the circle

What occurs if their position is inaccurate ?

Or if the approximated shape is not so simple ?

We are going to see two cases

The coordinates of the points are perturbed randomly

A deterministic increase and decrease of the radius

23
Computer Aided Design
Lagrange perturbation


Random perturbation

Each point is moved radially by a value between
-0.5 and +0.5 % of the circle's radius

24
Computer Aided Design
Lagrange polynomials

3 points, random perturbation 1%

25
Computer Aided Design
Lagrange polynomials

5 points, random perturbation 1%

26
Computer Aided Design
Lagrange polynomials

11 points, random perturbation 1%

27
Computer Aided Design
Lagrange polynomials

21 points, random perturbation 1%

28
Computer Aided Design
Lagrange polynomials


Runge phenomenon

Similar to Gibbs phenomenon of the
decompositions in harmonic functions

29
Computer Aided Design
Lagrange polynomials


Deterministic perturbation

Each point is moved radially by a value of -5 or +5
% of the circle's radius

30
Computer Aided Design
Lagrange polynomials

3 points, deterministic perturbation 10%

31
Computer Aided Design
Lagrange polynomials

5 points, deterministic perturbation 10%

32
Computer Aided Design
Lagrange polynomials

11 points, deterministic perturbation 10%

33
Computer Aided Design
Lagrange polynomials

21 points, deterministic perturbation 10%

34
Computer Aided Design
Lagrange polynomials


How to minimize Runge's phenomenon ?

The problem here is the use of a unique polynomial
and regular intervals between knots.

Instead, if we concentrate knots at the extremities,
the interpolation is less prone to Runge's
phenomenon.

Make use of Chebyshev knots:
2i −1
n
u =cos
i
2n( π ) in the interval [-1,1]

or uin = 1 + 1 cos 2i−1 π


( ) in the interval [0,1]
2 2 2n 35
Computer Aided Design
Lagrange polynomials

21 points, random perturbation 1%

Uniform nodal intervals – lagrange interpolation


36
Computer Aided Design
Lagrange polynomials

21 points, random perturbation 1%

Using Chebychev knots


37
Computer Aided Design
Lagrange polynomials


Perturbation of a point

We shift one point by a big displacement

38
Computer Aided Design
Lagrange polynomials

11 points, using Chebychev knots

39
Computer Aided Design
Lagrange polynomials

11 points, using Chebychev knots

40
Computer Aided Design
Lagrange polynomials

99 points, using Chebychev knots

41
Computer Aided Design
Lagrange polynomials

499 points, using Chebychev knots

42
Computer Aided Design
Lagrange polynomials


Even without perturbations, we still do
numerical approximations

Up to how many points can we pass through ?

43
Computer Aided Design
Lagrange polynomials

51 points (lagrange polynomial of order 50)


44
Computer Aided Design
Lagrange polynomials

61 points (lagrange polynomial of order 60)


45
Computer Aided Design
Lagrange polynomials


Here it has nothing to do with Runge's phenomenon

It's rather an accumulation of errors due to
arithmetic calculations done in finite precision

In our case, near the boundaries, we do an inexact sum
of very big numbers in absolute value, but whose sum
(the exact sum) is close to the unit (partition of unity).
n−1 n−1
p p (u−u i )
P (u)=∑ P l (u) with l (u)=
i i i ∏
i=0 j=0, i≠ j (u j −u i )

Big numbers in absolute value,


computed with a good relative accuracy

Sum increasing the relative error


46
Computer Aided Design
Lagrange polynomials


How to evaluate a polynomial ?

Under its Lagrange form (here) : robust except at the
boundaries

Alternative : newton's formula and divided differences

Horner's scheme
n−1
P u=∑ i u i ⇔ P u=a 0ua 1 ua 2u a n−1 
i=0

Optimal method with respect to the number of arithmetic operations
for a polynomial expressed as a sum of monomials – may be
numerically unstable

Others techniques adapted to particular forms of
polynomials later in the course e.g.

Algorithm of De Casteljau for Bernstein polynomials

Algorithm of De Boor for the evaluation of Bsplines

In any case, one should be cautious with numerical errors !47
Computer Aided Design
Numerical errors


Numerical errors

Floating point calculations are (most of the time)
inaccurate

Analysis of the rounding done during operations in
floating point :
x⊖ y= x− y 11  , ∣ 1∣≤2 
x⊕ y= x y 1 2  , ∣ 2∣≤2
x⊗ y= xy1 3  , ∣ 3∣≤

Mathematically equivalent calculations but
expressed differently give distinct results

An example with x 2 − y 2 = x y x− y
48
Computer Aided Design
Numerical errors


Error made with the expression  x y x− y
 x⊕ y⊗ x⊖ y  =  x− y 1 1  x y1 2 13 
=  x y  x− y 1 1 2  3 1  2  2  3 1  3 1  2 3 
≈ 5


No catastrophic increase of the relative error

Error made with the expression x 2 − y 2
( x⊗ x)⊖( y⊗ y) = [ x 2 (1+ δ1 )− y 2 (1+ δ 2 )](1+ δ3 )
= (( x 2− y 2 )(1+ δ 1)+ (δ1−δ 2 ) y 2 )(1+ δ 3 )
2 2 2 2
= (( x − y )(1+ δ1+ δ3+ (δ1−δ2 ) y + δ1 δ3 + (δ1 −δ 2 ) y δ 3 ))

When x is close to y, the error can be of the order of
magnitude of the theoretical result... 49
Computer Aided Design
Numerical errors


Some useful rules (not a comprehensive list !)
2 2

Prefer  x y x− y to x −y

Lagrange form more accurate than
N
horner's scheme …

E. g. sum of many terms S =∑ X [ j ]
j=1

Naive algorithm :
S=0;
for (j=1;j<=N;j++){ S=S+X[j] ; }
return S ;
involves an error ≈ N 

Kahan's summation algorithm
S=X[1];C=0
for (j=2;j<=N;j++)
{ Y=X[j]-C; T=S+Y; C=(T-S)-Y; S=T }
return S ;

involves an error ≈2  50
Computer Aided Design
Numerical errors

Example of catastrophic rounding
nx*ny samples

Computation of an integral :
ymax

S= ∫ f ( x , y)dxdy with f (x , y)=x + y


Ω
2 2


nx−1 ny−1
S≈ ∑ ∑ f  x i , y  j det J
i=0 j=0 ymin
xmin xmax
dx= x max− x min / nx y
x
dy= y max− y min / ny
x i = x min i dxdx / 2
y  j = y min j dydy /2
det J =dx dy 51
Computer Aided Design
Numerical errors

Computations made with the following
parameters:
xmin= ymin= 0.0 ; xmax= ymax= 1.0 ; nx = ny = 10, Sexact=2/3
1) Single precision floating point numbers
2) Double precision floating point numbers
3) Quad precision floating point numbers
4) Single precision floating points numbers with
Kahan's summation algorithm
bechet@yakusa:floating_error$ ./test 10
1) sum (float )=0.66500002145767211914
2) sum (double )=0.66500000000000025757
3) sum (ldouble)=0.66499999999999999997
4) sum (kahan )=0.66499999999999999997
Note : Program should be compiled without optimization ! 52
Computer Aided Design
Numerical errors
bechet@yakusa:floating_error$ ./test 100
1) sum (float )=0.66664981842041015625
2) sum (double )=0.66665000000000051994
3) sum (ldouble)=0.66665000000000000093
4) sum (kahan )=0.66664993762969970703

bechet@yakusa:floating_error$ ./test 1000


1) sum (float )=0.66668075323104858398
2) sum (double )=0.66666649999999805232
3) sum (ldouble)=0.66666649999999999982
4) sum (kahan )=0.66666668653488159180

53
Computer Aided Design
Numerical errors
bechet@yakusa:floating_error$ ./test 10000
1) sum (float )=0.36836880445480346680
2) sum (double )=0.66666666499985449690
3) sum (ldouble)=0.66666666499999997623
4) sum (kahan )=0.66666656732559204102

bechet@yakusa:floating_error$ ./test 100000


1) sum (float )=0.00390625000000000000
2) sum (double )=0.66666666665538221181
3) sum (ldouble)=0.66666666665000055245
4) sum (kahan )=0.66666662693023681641

Compensated summation algorithm coming from :

William Kahan. Further remarks on reducing truncation errors. Comm. ACM, 8(1):40,1965.
54
Computer Aided Design
Numerical errors

y=p(x)=(1-x)n
for x=1.333
and 2<n<41

S. Graillat, Ph.
Langlois, N.
Louvet
Compensated
Horner Scheme
Research Report
RR2005-04, LP2A,
University of
Perpignan, France,
july 2005
55
Computer Aided Design
Numerical errors

Definition of the condition number of a
numerical expression

Ratio of the direct error to the inverse error

∣ y∣
K P , x=lim sup
 
  0  x∈ D  ∣ x∣ inverse
x p y= p( x )

error δ x

For a polynomial ̃p
δy
x +δ x
direct
( monomial form ) p
error

n i ̃y = ̃p ( x )= y +δ y
∑i=0 ∣ai∣∣x∣ = p( x +δ x )
K  P , x= n
∣ a
∑i=0 i x i
∣ 56
Computer Aided Design
Numerical errors


There are various compensated algorithms to
carry out calculations on floating point numbers.

Ex. Kahan summation, Compensated Horner
scheme ...

In general, they allow to have similar results as
when using internal floating point with a
precision twice that of the input data, following
by a final rounding.

See references available on the course's
website for the compensated Horner scheme
and other documents.
57
Computer Aided Design
Lagrange polynomials

Morality :

Lagrange interpolation is not suited beyond 10's of
control points because of the Runge phenomenon

A modification of the position of a control point
leads to global changes of the curve.

The evaluation of high order polynomials expressed
as monomials leads to numerical problems.

No control of the slopes at the boundary of the
curve (start and finish).

65
Computer Aided Design

Splines

66
Computer Aided Design
Splines


Motivation
Let us imagine that we have many (100's of)
control points

But we don't want a Lagrange interpolation !

We should stay with a low order scheme but
conserve enough freedom to pass through every
point

Curve defined by pieces ... and of low order (1)

67
Computer Aided Design
Splines


We are going to build a low order interpolation
for each knot interval, such that we can impose
slopes at the knots.

P'=P'i
P=Pi+1
u=ui
P'=P'i+1
P=Pi
u=ui+1

68
Computer Aided Design
Splines


In each range [i,i+1] , we want to have an
independent polynomial

We have 4 parameters : position at each knot
and associated tangents.

The basis must have 4 degrees of freedom, thus be
of order 3 in the case of polynomials.
x (u i )=x i

{
P (ui )=P i ≡ y (u i )= y i
...

x [i ] u= A[i ]0  A[i ]1 u A[i ]2 u2  A[i ]3 u3 , u∈[ui , u i1 ]


69
Computer Aided Design
Splines


First, every interval has a unit length i.e.
ui1 −ui =1

Then we ensure identical intervals [0...1] between
each interpolation point :
u−u i d u
u = =u−u i =1
u i1−u i du


On each interval i , we thus have the following
relation:
2 3
x[i] ( u
̄ )=a[i] 0 + a u
[i]1 ̄ +a u
[i ]2 ̄ + a u
[i] 3 ̄ ,u
̄ ∈[0,1]

70
Computer Aided Design
Splines

P'=P'i
P=Pi+1
P'=P'i+1 u
 =0
P=Pi
u
 =1

71
Computer Aided Design
Splines


We pass through both control points:
2 3
P ( ū=0)=P i ⇔ a [i ]0 +a [i ]1 ū+ a[i ]2 ū + a[i ]3 ū =x i
2 3
P ( ū=1)=P i+1 ⇔ a [i]0 +a [i]1 ū+a [i] 2 ū +a [i ]3 ū = x i+1

We impose both slopes :
P ' ( ū 0 =0)=P 'i ⇔ a[i ]1 +2 a [i ]2 ū+3 a [i ]3 ū 2= xi'
' 2 '
P ( ū=1)=P 'i+1 ⇔ a[i ]1 +2 a [i] 2 ū+3 a[i ]3 ū = x i +1

At the end :
a[i]0 = xi

{ a[i]1 =x 'i
a[i] 2=3 xi1− x i −2 x'i −x 'i1
a[i]3 =2 xi −x i1  xi' x 'i1 72
Computer Aided Design
Splines


We have continuity

We have continuity of the derivatives

But how to choose the slopes ?

Let the user choose ( “artistic” freedom)

Automatically ...

73
Computer Aided Design
Splines


By finite differences with three points :
' xi1− xi xi − xi−1
x=
i 
2u i1−u i  2u i −u i−1 

At the boundaries, we use finite differences (asymmetric)
' x1 −x 0 ' x n−1− x n−2
x=
0 x n−1 =
u 1 −u0 u n−1−u n−2

The result depends on the parametrization !

Cardinal spline x '0=(1−c)( x 1− x 0 )
' x i1− xi−1
x =1−c
i , 0≤c≤1 '
x n−1 =(1−c)( x n−1 − x n−2 )
2

c is a « tension » parameter. c=0 gives yields the so called
“Catmull-Rom” spline, c=1 a zigzagging line.
74
Computer Aided Design
Splines

Continuity of the curve/parameter


but loss of regularity (and of geometric continuity
in many cases)

5 points, finite differences by varying the parametrization


[0..1] , [0..2] , [0..5] , [0..10]

75
Computer Aided Design
Splines

5 points, Cardinal Spline (Catmull-Rom) c=0

76
Computer Aided Design
Splines

Catmull-Rom Splines are widely used in computer graphics



Simple to compute, effective

Local control (price to pay : discontinuous secd derivative)

Animations with keyframing

Ensures a fluid motion because of the continuity of the slope

77
Computer Aided Design
Splines

5 points, Cardinal Spline c=0.25

78
Computer Aided Design
Splines

5 points, Cardinal Spline c=0.5

79
Computer Aided Design
Splines

5 points, Cardinal Spline c=0.75

80
Computer Aided Design
Splines

5 points, Cardinal Spline c=1.0

81
Computer Aided Design
Splines


We can impose the continuity of second derivatives...

On a curve with n points, we have n extra relations to
impose

We may impose the continuity of the second derivative only
on the n-2 interior knots
What about the 2 points on the boundary ?

Impose a vanishing second derivative.
We obtain what is called « natural spline »

We could also impose the slopes (i.e. only n-2 relations remaining)

Or , impose that the third derivative is zero on the points 1 and n-2

That means a single polynomial expression for the first two knot
intervals, and the last two.

82
Computer Aided Design
Splines


Natural Spline : mathematical approximation of the
spline historically used in naval construction.

C. DeBoor
83
Computer Aided Design
Splines

Boeing
84
Computer Aided Design
Splines


We impose the continuity of the second derivatives
''
x[i−1] 1=x ''[i ] 0⇔ 2a[i−1] 26a [i−1]3 =2a [i ]2

We substitute in the “internal” equations
2[3 x i − x i−1 −2 x 'i−1 − x 'i ]6[2 x i−1− x i  x 'i−1 x 'i ]
' '
=2[3 x i1 − x i −2 x i − x i1 ]

Finally we obtain :
' ' '
x i−1 4 x  x
i i1 =3 xi1 −x i−1 

85
Computer Aided Design
Splines


At the boundaries we want
'' ' '
x [0] 0=0⇔ 2a[0] 2=0 2 x0  x1 =3 x 1− x0 
'' ' '
x [n−2] 1=0⇔ 2a[n−2] 26a[ n−2] 3=0 x n−2 2 x n−1=3 x n−1− x n−2 


We have then a linear system with n unknowns :
'
x0

   
2 1 3 x 1− x0 

 1 4 1 x '1 3 x 2− x0 
1 4 1 x '2 = 3 x 3− x1 
⋱ ⋮ ⋮
1 4 1 x' 3 x n−1− x n−3 
n−2
1 2 ' 3 x n−1−x n−2 
x n−1
86
Computer Aided Design
Splines


By solving the system, we have :
x '0


a [i]0 = xi

{
'
x 1 '
' , which is substituted in a [i]1 =x i
x 2 ' '
a [i] 2=3 xi1− x i −2 xi −x i1
⋮ ' '
'
x n−2 a [i]3 =2 xi −x i1  xi x i1
x 'n−1

,to get the polynomial in each portion :


x [i ]  u =a [i] 0a[i ]1 u a [i ]2 u2 a[i]3 u 3 , 0≤u 1
From the global parameter u, we have to find in which portion we are ( the
value of i ) , then compute right polynomial... 87
Computer Aided Design
Splines
Catmull-Rom spline

5 control points, natural spline

88
Computer Aided Design
Splines


Another experiment

We approximate a circle by a number of increasing
points

Simultaneously , the order of the approximation the
number of pieces increases.
 In all the cases, the curve is C C2

89
Computer Aided Design
Splines

3 points, order 3!

90
Computer Aided Design
Splines

5 points

91
Computer Aided Design
Splines

11 points

92
Computer Aided Design
Splines

21 points

93
Computer Aided Design
Splines


Random perturbation

Each point is moved radially by a value between
-0.5 and +0.5 % of the circle's radius

94
Computer Aided Design
Splines

3 points, random perturbation 1%

95
Computer Aided Design
Splines

5 points, random perturbation 1%

96
Computer Aided Design
Splines

11 points, random perturbation 1%

97
Computer Aided Design
Splines

21 points, random perturbation 1%

98
Computer Aided Design
Splines


Deterministic perturbation

Each point is shifted radially depending on its
position by -5 or +5 % of the circle's radius

99
Computer Aided Design
Splines

3 points, deterministic perturbation 5%

100
Computer Aided Design
Splines

5 points, deterministic perturbation 5%

101
Computer Aided Design
Splines

11 points, deterministic perturbation 5%

102
Computer Aided Design
Splines

21 points, deterministic perturbation 5%

103
Computer Aided Design
Splines
non local
control

11 points

104
Computer Aided Design
Splines

105
Computer Aided Design
Splines


Perturbation of a point

We shift one point by a significant amount

106
Computer Aided Design
Splines

21 points

107
Computer Aided Design
Splines

99 points

108
Computer Aided Design
Splines

999 points

109
Computer Aided Design
Splines


Stable interpolation scheme

Weak Runge phenomenon

The displacement of a point yet affects all the
curve

Nevertheless, the perturbation fades very quickly
further away from the shifted point

« Overshoots » are limited.

110
Computer Aided Design
Splines


Closed curve ?

The curve can be closed, just impose everywhere
that the second derivative is continuous.

111
Computer Aided Design
Splines


Instead of
''
x [0] 0=0⇔ 2a[0] 2=0
x ''[n−2] 1=0⇔ 2a[n−2] 26a[ n−2] 3=0
... we have
'' ''
x [n−2] (1)= x (0)⇔ 2a[ n−2 ]2 +6a[ n−2 ]3=2a [0] 2
[0 ]

'
4 1 1 x 3( x1 − x n−2 )0

( )( ) ( )
'
1 4 1 x 3( x 2 − x 0 )1
Circulant 1 4 1 x = 3( x 3 − x 1) '
2 x n−1 = x 0
matrix ⋱ ⋮ ⋮ and ' '
x n−1 = x 0
1 4 1 x 'n−3 3( x n−2− x n−4 )
1 1 4 x' 3( x 0− x n−3 )
n−2 112
Computer Aided Design
Splines

General case : arbitrary parametrization

x (ui )= xi
P (ui )= P i ≡
{ y (ui )= y i
x[i] (u)= A[i] 0 + A[i ]1 u+ A[i ] 2 u 2 + A[i ]3 u 3 , u∈[u i , u i+1 ]


We again change the parametrization...
u−ui du
̄= 1 = 1
̄u = du u i+1−ui hi
u i +1−u i

2 3
x[i] ( u
̄ )=a[i] 0 + a u
[i]1 ̄ +a u
[i ]2 ̄ + a u
[i] 3 ̄ ,u
̄ ∈[0,1]

113
Computer Aided Design
Splines


We pass through both points :
2 3
P 
u0 =0= P i ⇔ a [i ]0 a [i]1 
u 0a [i ] 2 
u a [i ]3 
0 u = xi
0
2 3
P 
u1=1= P i1 ⇔ a [i ]0a [i ]1  u1 a [i] 2 
u 1 a [i]3 
u1= x i1

We impose both slopes :
' dP dP 1 2 '
P  u0 =0= 0= 0 = P 'i ⇔ a[i ]12a [i] 2 u0 3a [i] 3 u0 = x i hi
du d u hi
dP dP 1
P '  u1=1= 1= 1 = P ' i1 ⇔a [i ]12a[i ]2 u 13a[i ]3 u 21 = x 'i1 h i
du d u hi
a[i ]0 = x i

{
Finally : a = x ' h

[i ]1 i i

a[i ]2 =3 x i1− xi −2 x 'i h i − x 'i1 h i


' '
a[i ]3=2 x i − x i1  x h i  x
i i1 hi 114
Computer Aided Design
Splines


We impose the second derivative for a natural
spline 2
d P [i]
2 2
d P [i] d 2 u d P [i] 1
2
 u = 2 2
= 2 2
du d u d u d u hi
'' '' 2a[i−1] 2 6a [i−1] 3 2a [i] 2
x[i−1] 1= x[i ] 0⇔ 2
= 2
hi−1 hi


We substitute in the internal equations
2[3 xi − x i−1 −2 x 'i−1 hi−1 − x 'i hi−1 ]6[ 2 x i−1− x i  x 'i−1 hi−1  x 'i hi−1 ]
2
h i−1

2[3 x i1 − x i −2 x 'i hi − x 'i1 hi ]


= 2
hi 115
Computer Aided Design
Splines

We obtain finally :

x 'i−1 2 x 'i 2 x 'i  x 'i1  x i − x i−1   x i1 − x i 


 =3 3
hi−1 hi 2
hi−1 hi2

' ' ' ' hi hi−1


hi  x i−1 2 x hi−1 2 x  x
i i i1 =3  x i − x i−1 3  x i1 − x i 
h i−1 hi

116
Computer Aided Design
Splines


At the boundaries we want a vanishing second
derivative …
'' 2a [0] 2
x (0)=0 ⇔
[0] 2
=0
(h ) 0 h0 (2 x '0 + x '1)=3( x 1− x 0 )
'' 2a[ n−2 ]2 +6a[ n−2 ]3 ' '
h n−2 ( x n−2 +2 x n−1 )=3( x n−1− x n−2 )
x [n−2] (1)=0⇔ 2
=0
(h n−2 )


We have then a linear system of n unknowns:
(next page)
117
Computer Aided Design
Splines
'
2 h0 h0 x
0

( )( )
'
h1 2 h1 + 2 h 0 h0 x
1
⋱ ⋮ =
h n−2 2 hn−2 + 2 h n−3 h n−3 x 'n−2
h n−2 2 h n−2 x 'n−1

3( x 1 − x 0 )

( )
h1 h0
3 ( x 1− x 0 )+3 ( x 2− x 1 )
h0 h1

h n−2 h n−3
3 ( x n−2 − x n−3 )+3 ( x n−1 − x n−2 )
h n−3 h n−2
3( x n−1− x n−2 )
118
Computer Aided Design
Splines
Natural Spline
u=3 (uniform parametrization)

u=4 u=1

u=4
u=5 u=2 u=0

Natural Spline
(non uniform parametrization)

119
Computer Aided Design
Splines


Compact notation

We would like a compact representation as for the
Lagrange interpolation. a [i]0 = xi

0≤ ū <1

n n
2
x [i ] ( ū)=a [i ]0 +a [i]1 ū+a [i ]2 ū +a [i ]3 ū
3

{ '
a [i]1 =x i
' '
a [i] 2=3 xi1− x i −2 xi −x i1
a [i]3 =2 xi −x i1  xi' x 'i1

{
p ' p
x[i] ( ū)=∑ xi h ( ū)+ ∑ x h ( ū)
i0 i i1
0 0 n n
n n p ' p
p ' p ⇔ P [i ] ( ū)=∑ P i h ( ū)+∑ P h ( ū)
i0 i i1
y[i ] ( ū)=∑ yi h ( ū)+ ∑ y h ( ū)
i0 i i1 0 0
0 0
...
This on each interval [i,i+1].
120
Computer Aided Design
Splines


We have on each interval :
a [i]0 = xi

{ a [i]1 =x 'i
' '
a [i] 2=3 xi1− x i −2 xi −x i1
a [i]3 =2 xi −x i1  xi' x 'i1

x [i ]  u = xi  x 'i u 3 x i1 −x i −2 x 'i − x'i1  u 22 xi − x i1  x'i  x 'i1  u 3


By rearranging equations
x [i ]  u = xi 1−3 u 2 2 u 3 x 'i  u −2 u 2 u 3 
2 3 ' 2 3
 x i1 3 u −2 u  xi1 −u  u 
121
Computer Aided Design
Splines


Hermite polynomials (for two points)
p
h 00 =1−3 u 22 u 3

{ p

p
2
h10 =3 u −2 u
p

2
h11=−u  u
2
3

h 01=u −2 u  u
3
3

122
Computer Aided Design
Splines


The more general Hermite basis of degree 2n-1
allows to do an interpolation of n points on an
interval, as the Lagrange basis, additionally
imposing slopes at each point.
n ''
l (u i )

n
[
hi0n (u)= 1− n'
l (u i )
n 2
]
(u−ui ) [l in (u)]2

h u=u−ui [l u]


i1 i
n n−1
n l u u−ui 
l i u= n ' = ∏
l ui u−ui  j=0,i≠ j u j −u i 
n−1
n
l u=∏ u−u j 
j=0
123
Computer Aided Design
Splines


Properties of the Hermite basis
Interpolation
of the
hi0n u j = ij positions

h i0n ' u j =0


n
hi1 u j =0
h i1n ' u j =ij
Interpolation
of the slopes

n
∑h i0 u=1
i

124
Computer Aided Design
Splines


Property of affine invariance

It is a useful property such that the curves we
define for a set of control points can undergo linear
affine transformations without hassle.
 Let Pi* the affine transformation of the control points Pi
 Let P*(u,Pi) the affine transformation of the points of the
curve P(u,Pi) defined from the original points Pi
 Let P(u,Pi*) the new curve based on the modified control
points Pi* , with the same parametrization.
 The affine invariance is verified iff P*(u,Pi) = P(u,Pi*)
for all u.
125
Computer Aided Design
Splines


Affine transformations  P ≡A⋅P u
Translation a 1 0 0
Scaling
3 rotations
[] [ ]
u= b ; A= 0 1 0
c 0 0 1
d 0 0
Shear

1 g h
[ ]
u=0 ; A= 0 e 0
0 0 f

[ ]
u=0 ; A= 0 1 i
0 0 1
cos  −sin  0
[ ]
u=0 ; A= sin  cos  0 ⋯
0 0 1

12 degrees of freedom

126
Computer Aided Design
Splines

Let P a parametric curve built this way :


n−1
P (u , P i )=∑ P i K ni (u)
0


Let's verify the invariance by a translation t:
n−1 n−1 n−1
* n n n
P (u , P )=∑ ( P i +t) K (u)=∑ P i K (u)+ ∑ t K (u)
i i i i
0 0 0
n−1
n
= P (u , P i )+ ∑ t K (u) i Partition of unity
0
n−1
= P (u , P i )+t=P * (u , P i ) iff K n
∑ i (u)=1
0 127
Computer Aided Design
Splines


For the other multiplicative transformations
n−1 n−1
* n n
P (u , P )=∑ (A⋅P i ) K (u)=A⋅∑ P i K (u)
i i i
0 0

=A⋅P (u , P i )=P * (u , P i )
(no particular conditions except linearity
with respect to the coordinates of the control points)
Consequently, iff the basis functions form a partition of unity,
and the dependence with respect to the control points is
linear, then the representation is invariant by any affine
transformation.

128
Computer Aided Design
Splines


Do Hermite's basis form a partition of unity ?
n−1 p
h 00 =1−3 u 22 u 3

{
n
h
∑ ?? u=1 p 2 3
0 h10 =3 u −2 u
p 2 3
h 01=u −2 u  u
p 2 3
F u=1 h11=−u  u

'
F 1=1 ' F 1=0
F 0=1 F 0=0

129
Computer Aided Design
Splines


Let's check the invariance
 If we apply a translation to the control points Pi, the
derivatives Pi' should not change ...
* '* '
P = P i +t
i P =P
i i
1 1
P ( P *i )=∑ ( P i +t ) h ni0 (u)+ ∑ P i' hi1n (u)
0 0

1 1 1
n n ' n
=∑ th (u)+ ∑ P i h (u)+ ∑ P h (u)
i0 i0 i i1
0 0 0

*
=t + P (P i )= P ( P i )

130
Computer Aided Design
Splines

We must also check the invariance for the other
multiplicative transformations : those affect both
the coordinates and the derivatives
* '* '
P i = A⋅P i P i = A⋅P i
1 1
* n ' n
P  P i =∑  A⋅P i h i0 u∑  A⋅P i  hi1 u
0 0

1 1

 n
= A⋅ ∑ P i h u∑ P h u
0
i0
0
'
i
n
i1 
*
= A⋅P ( P i )= P (P i )
QED
131
Computer Aided Design
Splines
 Beware of the computation of the slopes x'i ...

Natural Splines :
'
x

   
2 1 3 x 1− x0 
0


'
1 4 1 x 3 x 2− x0 
1
'
1 4 1 x = 3 x 3− x1 
2
⋱ ⋮ ⋮
1 4 1 x' 3 x n−1− x n−3 
n−2
1 2 ' 3 x n−1−x n−2 
x n−1
Linear operator

P 'i = L( P i − P j )⇒ P 'i * = L (P *i − P *j )= L(( A⋅P i +t)−( A⋅P j +t))


'
= A⋅L( P i − P j )= A⋅P i It is OK in this case 132
Computer Aided Design
Splines


Rotation of 45°

Scaling x direction
(times 0.5)

Followed by a
translation
133
Computer Aided Design
Splines


3D Curves

Minimal order so that a curve can have a torsion
(non planar curve) n−1
p

Let's consider a Lagrange interpolation P u= ∑P i l i u
i=0

2 points → on a straight line (no curvature)

3 points → in a plane (no torsion)

4 points → torsion becomes possible

Minimal order to join smoothly two arbitrarily
oriented curves = 3

134

You might also like