interpolation and polynomial approximation interpolation - … · 2019-07-15 · 1 computer aided...

127
1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange Cubic Splines Approximation Bézier curves B-Splines

Upload: lethien

Post on 25-Jul-2019

255 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

1

Computer Aided Design

Outline

Interpolation and polynomial approximation Interpolation

Lagrange Cubic Splines

Approximation Bézier curves B-Splines

Page 2: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

2

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

Page 3: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

3

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

Page 4: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

4

Computer Aided Design

Interpolation

Page 5: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

5

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...

Page 6: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

6

Computer Aided Design

Interpolation

We must choose the parametrization (nodal sequence)

Uniform

u0=0

u1=1

u2=2

un-1

=n-1

Page 7: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

7

Computer Aided Design

Interpolation

Or non-uniform

u0=0

u1=2.5

u2=7

un-1

=15

Page 8: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

8

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...

Page 9: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

9

Computer Aided Design

Interpolation

Parametrization as an approximate arc length

u0=0

u1=d

1

u2=d

1+d

2

d1

dn-1

d2

un-1

=d1+...+d

n-1

Page 10: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

10

Computer Aided Design

Interpolation

In all cases, we want to have :

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 :

We set the linear system and solve...

P ui=P i ≡ {xui=xi

y ui= y i

x u=a0a1 ua2 u2⋯an−1 un−1

=∑j=0

n−1

a j uj

{x u1=x1

x un−1=xn−1

Page 11: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

11

Computer Aided Design

Interpolation

Vandermonde matrix

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 ( y

i ) )

, or have to take the inverse of this matrix, or perform an LU decomposition.

{x u1=x1

x un−1=xn−1 (1 u0 u0

2⋯ u0

n−1

1 u1 u12

⋯ u1n−1

⋮ ⋮ ⋮ ⋮ ⋮

1 un−1 un−12

⋯ un−1n−1)(

a0

a1

⋮an−1

)=(x0

x1

⋮xn−1

)

Page 12: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

12

Computer Aided Design

Interpolation

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

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

These polynomials verify, for an interpolation :

We have only one computation to do for any position of the interpolation points, knowing the u

i

(the parametrization)

{x u=∑

0

n−1

x i l ipu

y u=∑0

n−1

yi l ipu

⇔ P u=∑0

n−1

Pi l ipu

l ipu j= ij

Page 13: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

13

Computer Aided Design

Interpolation

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

and such that :l i

pu j= ij⇔{l i

pu j=1 ; i= j

l ipu j=0 ; i≠ j

lip may be factored by (u-u

j) for j≠i

l ipu =k u−u0u−u1⋯u−ui−1u−ui1⋯u−un−1

k is such that l ipui=1

k=ui−u0ui−u1⋯ui−ui−1ui−ui1⋯ui−un−1−1

l ip(u)= ∏

j=0, j≠i

n−1 (u−u j)

(ui−u j)

The lip are the Lagrange polynomials of order p

Page 14: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

14

Computer Aided Design

Interpolation

Lagrange polynomials

Properties

Interpolation Partition of unity

l ipu=

l pu

l p 'uiu−ui

= ∏j=0, i≠ j

n−1 u−u j

ui−u j

l pu=∏

j=0

n−1

u−u j

l ipu j=ij

l p '(ui)= ∏

j=0 , j≠i

n−1

(ui−u j) (first derivative w/r to u at u=ui)

∑0

n−1

l ip(u)=1

x(u)=∑0

n−1

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

Page 15: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

15

Computer Aided Design

Lagrange polynomials

Order 4 The u

i are evenly

distributed between u=0 and u=1

The sum is equal to 1 (partition of unity)

Presence of negative values

Page 16: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

16

Computer Aided Design

Lagrange polynomials

Order 10 Presence of huge

overshoots near the boundaries

Page 17: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

17

Computer Aided Design

Lagrange polynomials

The interpolation is represented by the following form :

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

P (u)=∑i=0

n−1

P i l ip(u) with l i

p(u)= ∏

j=0, i≠ j

n−1 (u−ui)

(u j−ui)

Page 18: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

18

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

Page 19: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

19

Computer Aided Design

3 points, order 2 (a parabola !)

Lagrange polynomials

Page 20: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

20

Computer Aided Design

5 points, order 4

Lagrange polynomials

Page 21: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

21

Computer Aided Design

11 points, order 10

Lagrange polynomials

Page 22: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

22

Computer Aided Design

21 points, order 20

Lagrange polynomials

Page 23: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

23

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

Page 24: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

24

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

Page 25: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

25

Computer Aided Design

3 points, random perturbation 1%

Lagrange polynomials

Page 26: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

26

Computer Aided Design

5 points, random perturbation 1%

Lagrange polynomials

Page 27: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

27

Computer Aided Design

11 points, random perturbation 1%

Lagrange polynomials

Page 28: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

28

Computer Aided Design

21 points, random perturbation 1%

Lagrange polynomials

Page 29: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

29

Computer Aided Design

Lagrange polynomials

Runge phenomenon Similar to Gibbs phenomenon of the

decompositions in harmonic functions

Page 30: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

30

Computer Aided Design

Lagrange polynomials

Deterministic perturbation Each point is moved radially by a value of -5 or +5

% of the circle's radius

Page 31: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

31

Computer Aided Design

3 points, deterministic perturbation 10%

Lagrange polynomials

Page 32: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

32

Computer Aided Design

5 points, deterministic perturbation 10%

Lagrange polynomials

Page 33: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

33

Computer Aided Design

11 points, deterministic perturbation 10%

Lagrange polynomials

Page 34: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

34

Computer Aided Design

21 points, deterministic perturbation 10%

Lagrange polynomials

Page 35: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

35

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:

in the interval [-1,1]

or in the interval [0,1]

uin=cos ( 2 i−1

2 nπ)

uin=

12

+12

cos( 2 i−12 n

π)

Page 36: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

36

Computer Aided Design

21 points, random perturbation 1%

Uniform nodal intervals – lagrange interpolation

Lagrange polynomials

Page 37: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

37

Computer Aided Design

21 points, random perturbation 1%

Using Chebychev knots

Lagrange polynomials

Page 38: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

38

Computer Aided Design

Lagrange polynomials

Perturbation of a point We shift one point by a big displacement

Page 39: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

39

Computer Aided Design

11 points, using Chebychev knots

Lagrange polynomials

Page 40: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

40

Computer Aided Design

11 points, using Chebychev knots

Lagrange polynomials

Page 41: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

41

Computer Aided Design

99 points, using Chebychev knots

Lagrange polynomials

Page 42: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

42

Computer Aided Design

499 points, using Chebychev knots

Lagrange polynomials

Page 43: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

43

Computer Aided Design

Lagrange polynomials

Even without perturbations, we still do numerical approximations

Up to how many points can we pass through ?

Page 44: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

44

Computer Aided Design

51 points (lagrange polynomial of order 50)

Lagrange polynomials

Page 45: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

45

Computer Aided Design

61 points (lagrange polynomial of order 60)

Lagrange polynomials

Page 46: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

46

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).

Big numbers in absolute value, computed with a good relative accuracy

Sum increasing the relative error

P (u)=∑i=0

n−1

P i l ip(u) with l i

p(u)= ∏

j=0, i≠ j

n−1 (u−ui)

(u j−ui)

Page 47: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

47

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

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 !

P u=∑i=0

n−1

i ui⇔ P u =a0u a1ua2u an−1

Page 48: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

48

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 :

Mathematically equivalent calculations but expressed differently give distinct results

An example with

x⊖ y=x− y 11 , ∣1∣≤2

x⊕ y= x y 12 , ∣2∣≤2

x2− y2

=x yx− y

x⊗ y= xy13 , ∣3∣≤

Page 49: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

49

Computer Aided Design

Numerical errors

Error made with the expression

No catastrophic increase of the relative error Error made with the expression

When x is close to y, the error can be of the order of magnitude of the theoretical result...

x2− y2

(x⊗ x)⊖( y⊗ y) = [ x2(1+ δ1)− y2

(1+ δ2)](1+ δ3)

= ((x2− y2

)(1+ δ1)+ (δ1−δ2) y2)(1+ δ3)

x yx− y

x⊕ y⊗x⊖ y = x− y 11x y1213

= x y x− y 1123122 31312 3

≈ 5

= ((x2− y2

)(1+ δ1+ δ3+ (δ1−δ2) y2+ δ1 δ3+ (δ1−δ2) y2

δ3))

Page 50: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

50

Computer Aided Design

Numerical errors

Some useful rules (not a comprehensive list !) Prefer to

Lagrange form more accurate than horner's scheme … E. g. sum of many terms

Naive algorithm :

involves an error Kahan's summation algorithm

involves an error

x2− y2x yx− y

S=0;for (j=1;j<=N;j++){ S=S+X[j] ; }return S ;≈ N

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

≈2

S=∑j=1

N

X [ j ]

Page 51: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

51

Computer Aided Design

Numerical errors

Example of catastrophic rounding Computation of an integral :

S=∫Ω

f (x , y)dxdy with f (x , y)=x2+ y2

x

y

S≈ ∑i=0

nx−1

∑j=0

ny−1

f x i , y j det J

dx=xmax−xmin/nxdy= ymax− ymin/ny

x i =xmini dxdx /2y j = ymin j dydy /2

det J =dx dy

nx*ny samples

xmin

xmax

ymin

ymax

Page 52: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

52

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 numbers2) Double precision floating point numbers3) Quad precision floating point numbers4) Single precision floating points numbers with Kahan's summation algorithm

bechet@yakusa:floating_error$ ./test 101) sum (float )=0.665000021457672119142) sum (double )=0.665000000000000257573) sum (ldouble)=0.664999999999999999974) sum (kahan )=0.66499999999999999997Note : Program should be compiled without optimization !

Page 53: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

53

Computer Aided Design

Numerical errors

bechet@yakusa:floating_error$ ./test 1001) sum (float )=0.666649818420410156252) sum (double )=0.666650000000000519943) sum (ldouble)=0.666650000000000000934) sum (kahan )=0.66664993762969970703

bechet@yakusa:floating_error$ ./test 10001) sum (float )=0.666680753231048583982) sum (double )=0.666666499999998052323) sum (ldouble)=0.666666499999999999824) sum (kahan )=0.66666668653488159180

Page 54: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

54

Computer Aided Design

Numerical errors

bechet@yakusa:floating_error$ ./test 100001) sum (float )=0.368368804454803466802) sum (double )=0.666666664999854496903) sum (ldouble)=0.666666664999999976234) sum (kahan )=0.66666656732559204102

bechet@yakusa:floating_error$ ./test 1000001) sum (float )=0.003906250000000000002) sum (double )=0.666666666655382211813) sum (ldouble)=0.666666666650000552454) sum (kahan )=0.66666662693023681641

William Kahan. Further remarks on reducing truncation errors. Comm. ACM, 8(1):40,1965.

Compensated summation algorithm coming from :

Page 55: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

55

Computer Aided Design

Numerical errors

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

S. Graillat, Ph. Langlois, N. LouvetCompensated Horner SchemeResearch Report RR2005-04, LP2A, University of Perpignan, France, july 2005

Page 56: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

56

Computer Aided Design

Numerical errors

Definition of the condition number of a numerical expression

Ratio of the direct error to the inverse error

For a polynomial

( monomial form )

K P , x=lim 0

sup x∈D

∣ y∣∣ x∣

K P , x=∑i=0

n

∣ai∣∣x∣i

∣∑i=0

nai x i∣

x y= p(x)

y= p(x)= y+δ y= p(x+δ x)

x+δ x

p

p

p

δ x

δ ydirecterror

inverseerror

Page 57: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

57

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.

Page 58: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

65

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).

Page 59: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

66

Computer Aided Design

Splines

Page 60: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

67

Computer Aided Design

Splines

MotivationLet 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)

Page 61: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

68

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.

u=ui+1

u=ui

P=Pi+1

P=Pi

P'=P'i

P'=P'i+1

Page 62: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

69

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 [i ]u=A[i ]0A[i ]1 uA[ i ]2 u2A[i ]3 u3 , u∈[ui , ui1]

P (ui)=P i ≡ {x (ui)=x i

y (ui)= y i

...

Page 63: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

70

Computer Aided Design

Splines

First, every interval has a unit length i.e.

Then we ensure identical intervals [0...1] between each interpolation point :

On each interval i , we thus have the following relation:

ui1−ui=1

u=u−ui

u i1−ui

=u−ui

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

d udu

=1

Page 64: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

71

Computer Aided Design

Splines

P=Pi+1

P=Pi

P'=P'i

P'=P'i+1

u=0

u=1

Page 65: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

72

Computer Aided Design

Splines

We pass through both control points:

We impose both slopes :

At the end :

P (u=0)=P i ⇔a[ i ]0+a[ i ]1 u+a[ i ]2 u2+a[ i ]3 u3

=x i

P (u=1)=P i+1 ⇔a[ i ]0+a[ i ]1 u+a[ i ] 2 u2+a[ i ]3 u3

=x i+1

P '(u0=0)=P 'i ⇔ a[ i ]1+2a[ i ]2 u+3 a[i ]3 u2

=xi'

P '(u=1)=P 'i+1⇔a[ i ]1+2 a[ i ] 2 u+3 a[ i ]3 u2

=xi +1'

{a[ i ]0=xi

a[ i ]1=x i'

a[ i ] 2=3 xi1−x i−2 xi'−x i1

'

a[ i ]3=2xi−x i1xi'x i1

'

Page 66: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

73

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 ...

Page 67: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

74

Computer Aided Design

Splines

By finite differences with three points :

At the boundaries, we use finite differences (asymmetric)

The result depends on the parametrization ! Cardinal spline

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

x i'=

xi1−xi

2 ui1−ui

xi−xi−1

2 ui−ui−1

x0'=

x1−x0

u1−u0

xn−1'

=xn−1−xn−2

un−1−un−2

x i'=1−c

x i1−xi−1

2 , 0≤c≤1

x0'=(1−c)(x1− x0)

xn−1'

=(1−c)(xn−1−xn−2)

Page 68: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

75

Computer Aided Design

Splines

5 points, finite differences by varying the parametrization [0..1] , [0..2] , [0..5] , [0..10]

Continuity of the curve/parameter but loss of regularity (and of geometric continuityin many cases)

Page 69: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

76

Computer Aided Design

Splines

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

Page 70: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

77

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

Page 71: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

78

Computer Aided Design

Splines

5 points, Cardinal Spline c=0.25

Page 72: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

79

Computer Aided Design

Splines

5 points, Cardinal Spline c=0.5

Page 73: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

80

Computer Aided Design

Splines

5 points, Cardinal Spline c=0.75

Page 74: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

81

Computer Aided Design

Splines

5 points, Cardinal Spline c=1.0

Page 75: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

82

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.

Page 76: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

83

Computer Aided Design

Splines

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

C. D

eBoor

Page 77: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

84

Computer Aided Design

Splines

Boeing

Page 78: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

85

Computer Aided Design

Splines

We impose the continuity of the second derivatives

We substitute in the “internal” equations

Finally we obtain :

x[ i−1]

''1=x [i ]

''0⇔ 2a[ i−1] 26a[ i−1]3=2a[i ]2

2 [3 x i−x i−1−2 x i−1'

−x i']6 [2 x i−1−x ix i−1

'x i

']

=2 [3 x i1−x i−2 x i'−x i1

']

x i−1'

4 x i'x i1

'=3xi1−x i−1

Page 79: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

86

Computer Aided Design

Splines

At the boundaries we want

We have then a linear system with n unknowns :

x [0]

''0=0⇔ 2a[0] 2=0

x [n−2]

''1=0⇔ 2a[n−2] 26a[ n−2] 3=0

2 x0'x1

'=3x1−x0

xn−2'

2 xn−1'

=3xn−1−xn−2

2 11 4 1

1 4 1⋱

1 4 11 2

x0

'

x1'

x2'

xn−2'

xn−1'

=3x1−x0

3 x2−x0

3x3−x1

3xn−1−xn−3

3 xn−1−xn−2

Page 80: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

87

Computer Aided Design

Splines

By solving the system, we have :

, which is substituted in

,to get the polynomial in each portion :

From the global parameter u, we have to find in which portion we are ( the value of i ) , then compute right polynomial...

x0

'

x1'

x2'

xn−2'

xn−1'

{a[ i ]0=xi

a[ i ]1=x i'

a[ i ] 2=3 xi1−x i−2 xi'−x i1

'

a[ i ]3=2xi−x i1xi'x i1

'

x [i ]u =a[i ] 0a[ i ]1ua[ i ]2 u2a[ i ]3 u

3 , 0≤u1

Page 81: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

88

Computer Aided Design

Splines

5 control points, natural spline

Catmull-Rom spline

Page 82: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

89

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 C

2

Page 83: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

90

Computer Aided Design

Splines

3 points, order 3!

Page 84: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

91

Computer Aided Design

Splines

5 points

Page 85: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

92

Computer Aided Design

Splines

11 points

Page 86: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

93

Computer Aided Design

Splines

21 points

Page 87: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

94

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

Page 88: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

95

Computer Aided Design

Splines

3 points, random perturbation 1%

Page 89: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

96

Computer Aided Design

Splines

5 points, random perturbation 1%

Page 90: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

97

Computer Aided Design

Splines

11 points, random perturbation 1%

Page 91: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

98

Computer Aided Design

Splines

21 points, random perturbation 1%

Page 92: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

99

Computer Aided Design

Splines

Deterministic perturbation Each point is shifted radially depending on its

position by -5 or +5 % of the circle's radius

Page 93: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

100

Computer Aided Design

Splines

3 points, deterministic perturbation 5%

Page 94: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

101

Computer Aided Design

Splines

5 points, deterministic perturbation 5%

Page 95: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

102

Computer Aided Design

Splines

11 points, deterministic perturbation 5%

Page 96: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

103

Computer Aided Design

Splines

21 points, deterministic perturbation 5%

Page 97: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

104

Computer Aided Design

Splines

11 points

non local control

Page 98: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

105

Computer Aided Design

Splines

Page 99: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

106

Computer Aided Design

Splines

Perturbation of a point We shift one point by a significant amount

Page 100: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

107

Computer Aided Design

Splines

21 points

Page 101: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

108

Computer Aided Design

99 points

Splines

Page 102: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

109

Computer Aided Design

Splines

999 points

Page 103: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

110

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.

Page 104: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

111

Computer Aided Design

Splines

Closed curve ? The curve can be closed, just impose everywhere

that the second derivative is continuous.

Page 105: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

112

Computer Aided Design

Splines

Instead of

... we have

(4 1 11 4 1

1 4 1⋱

1 4 11 1 4

)(x0

'

x1'

x2'

xn−3'

x n−2'

)=(3(x1−xn−2)

3(x2−x0)

3(x3−x1)

⋮3( xn−2− xn−4)

3(x0−x n−3))

x[n−2]

''(1)=x[0 ]

''(0)⇔ 2a[ n−2 ]2+6a[ n−2 ]3=2a [0] 2

x [0]

''0=0⇔ 2a[0] 2=0

x [n−2]

''1=0⇔ 2a[n−2] 26a[ n−2] 3=0

Circulantmatrix

xn−1=x0

xn−1'

=x0'and

Page 106: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

113

Computer Aided Design

Splines

General case : arbitrary parametrization

We again change the parametrization...

P (ui)=P i ≡ {x (ui)= xi

y (ui)= y i

x[ i ](u)= A[ i ] 0+ A[ i ]1 u+ A[ i ] 2 u2+ A[ i ]3 u3 , u∈[ui , ui+1]

u=u−ui

ui +1−ui

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

d udu

=1

ui+1−ui

=1hi

Page 107: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

114

Computer Aided Design

Splines

We pass through both points :

We impose both slopes :

Finally :

P u0=0=P i ⇔a[ i ]0a[ i ]1 u0a[i ] 2u02a[ i ]3 u0

3=xi

P u1=1=Pi1⇔a[ i ]0a[i ]1 u1a[i ] 2 u12a[i ]3 u1

3=x i1

P 'u0=0=

d Pd u

0=d Pd u

01hi

=P 'i ⇔ a[i ]12a [ i ] 2 u03a [ i] 3u02=x i

' hi

P 'u1=1=

d Pd u

1=d Pd u

11hi

=P 'i1⇔a[i ]12a[ i ]2 u13a[ i ]3 u12=x i1

' hi

{a[i ]0=x i

a[i ]1=x i' hi

a[i ]2=3 x i1− xi−2 x i' hi−x i1

' hi

a[i ]3=2 x i−x i1x i' hix i1

' hi

Page 108: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

115

Computer Aided Design

Splines

We impose the second derivative for a natural spline

We substitute in the internal equations

d 2 P [i ]

du2 u=d 2 P[i ]

d u2

d 2u

d u2 =d 2 P [ i]

d u2

1

hi2

2 [3 xi−x i−1−2 x i−1' hi−1−x i

' hi−1]6 [2 x i−1−x ix i−1' hi−1x i

' hi−1]

hi−12

=2 [3 x i1−x i−2 x i

' hi−x i1' hi ]

hi2

x[ i−1]

''1=x[i ]

''0⇔

2a[ i−1] 26a [ i−1] 3

hi−12

=2a [i] 2

hi2

Page 109: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

116

Computer Aided Design

Splines

We obtain finally :

x i−1'

2 x i'

hi−1

2 x i

'x i1

'

hi

=3 x i−x i−1

hi−12

3 x i1−x i

hi2

hi x i−1'

2 x i'hi−12 xi

' xi1

'=3

hi

hi−1

x i−x i−13hi−1

hi

x i1−x i

Page 110: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

117

Computer Aided Design

Splines

At the boundaries we want a vanishing second derivative …

We have then a linear system of n unknowns:

(next page)

x[0]

''(0)=0⇔

2a [0] 2

(h02)

=0

x[n−2]

''(1)=0⇔

2a[ n−2 ]2+6a[ n−2 ]3

(hn−22

)=0

h0(2 x0'+ x1

')=3(x1−x0)

hn−2(xn−2'

+2 xn−1'

)=3(xn−1−xn−2)

Page 111: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

118

Computer Aided Design

Splines

(2h0 h0

h1 2 h1+2h0 h0

hn−2 2 hn−2+2 hn−3 hn−3

hn−2 2hn−2

)(x0

'

x1'

xn−2'

xn−1'

)=

(3(x1−x0)

3h1

h0

(x1− x0)+3h0

h1

(x 2−x1)

3hn−2

hn−3

(xn−2−xn−3)+3hn−3

hn−2

(xn−1−xn−2)

3(xn−1−xn−2)

)

Page 112: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

119

Computer Aided Design

Splines

Natural Spline(uniform parametrization)

Natural Spline(non uniform parametrization)

u=0

u=1

u=2

u=4

u=5

u=3

u=4

Page 113: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

120

Computer Aided Design

Splines

Compact notation We would like a compact representation as for the

Lagrange interpolation.

This on each interval [i,i+1].

x[i ](u)=a[ i ]0+a[ i ]1 u+a[i ]2 u2+a[i ]3 u3

0≤u<1

{x[ i](u)=∑

0

n

xi hi 0p(u)+∑

0

n

x i' hi 1

p(u)

y[ i ](u)=∑0

n

yi hi 0p(u)+∑

0

n

y i' hi 1

p(u)

...

⇔ P[i ](u)=∑0

n

P i hi 0p(u)+∑

0

n

Pi' hi 1

p(u)

{a[ i ]0=xi

a[ i ]1=x i'

a[ i ] 2=3 xi1−x i−2 xi'−x i1

'

a[ i ]3=2xi−x i1xi'x i1

'

Page 114: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

121

Computer Aided Design

Splines

We have on each interval :

By rearranging equations

{a[i ]0=xi

a[i ]1=x i'

a[i ] 2=3 xi1−x i−2 xi'−x i1

'

a[i ]3=2xi−x i1xi'x i1

'

x [i ]u =xix i'u3x i1−x i−2 x i

'−xi1

' u

22 xi−x i1xi

'x i1

'u

3

x [i ]u=xi 1−3u22u

3x i

'u−2u

2u

3

x i13u2−2 u

3xi1

'−u

2u

3

Page 115: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

122

Computer Aided Design

Splines

Hermite polynomials (for two points)

{h00

p=1−3u

22u

3

h10p=3u

2−2u

3

h01p=u−2u

2u

3

h11p=−u

2u

3

Page 116: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

123

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.

hi0n(u)=[1−

l n ''(ui)

l n '(ui)

(u−ui)][ l in(u)]

2

hi1nu =u−ui[l i

nu]

2

l inu=

l nu

l n 'uiu−ui

= ∏j=0, i≠ j

n−1 u−ui

u j−ui

l nu =∏

j=0

n−1

u−u j

Page 117: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

124

Computer Aided Design

Splines

Properties of the Hermite basis

hi0n

u j= ij

hi0n

'u j=0

hi1n'u j=ij

hi1nu j=0

∑i

hi0nu=1

Interpolation of the positions

Interpolation of the slopes

Page 118: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

125

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 P

i

Let P*(u,Pi) the affine transformation of the points of the

curve P(u,Pi) defined from the original points P

i

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,P

i*)

for all u.

Page 119: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

126

Computer Aided Design

Splines

Affine transformations

Translation

Scaling

3 rotations

Shear

12 degrees of freedom

P ≡A⋅Pu

u=[abc ] ; A=[

1 0 00 1 00 0 1 ]

u=0 ; A=[d 0 00 e 00 0 f ]

u=0 ; A=[cos −sin 0sin cos 0

0 0 1]⋯u=0 ; A=[

1 g h0 1 i0 0 1]

Page 120: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

127

Computer Aided Design

Splines

Let P a parametric curve built this way :

Let's verify the invariance by a translation t:

P (u , Pi)=∑0

n−1

P i K in(u)

P (u , Pi*)=∑

0

n−1

(P i+t) K in(u)=∑

0

n−1

P i K in(u)+∑

0

n−1

t K in(u)

=P (u , P i)+∑0

n−1

t K in(u)

=P (u , P i)+t=P*(u , Pi) iff ∑

0

n−1

K in(u)=1

Partition of unity

Page 121: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

128

Computer Aided Design

Splines

For the other multiplicative transformations

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.

P (u , Pi*)=∑

0

n−1

(A⋅P i) K in(u)=A⋅∑

0

n−1

P i K in(u)

=A⋅P (u , P i)=P*(u , P i)

(no particular conditions except linearity with respect to the coordinates of the control points)

Page 122: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

129

Computer Aided Design

Splines

Do Hermite's basis form a partition of unity ?

∑0

n−1

h??n

u=1

{h00

p=1−3u

22u

3

h10p=3u

2−2u

3

h01p=u−2u

2u

3

h11p=−u

2u

3F u=1

F 0=1F 1=1 F '

0=0F '

1=0

Page 123: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

130

Computer Aided Design

Let's check the invariance If we apply a translation to the control points P

i, the

derivatives Pi' should not change ...

P (Pi*)=∑

0

1

(P i+t )hi0n(u)+∑

0

1

Pi' hi1

n(u)

=∑0

1

thi0n(u)+∑

0

1

P i hi0n(u)+∑

0

1

P i' hi1

n(u)

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

P i*=P i+t P i

' *=P i

'

Splines

Page 124: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

131

Computer Aided Design

Splines

We must also check the invariance for the other multiplicative transformations : those affect both the coordinates and the derivatives

P P i*=∑

0

1

A⋅P ihi0nu∑

0

1

A⋅Pi'hi1

nu

P i*= A⋅P i P i

' *=A⋅P i

'

=A⋅∑0

1

P i hi0nu∑

0

1

P i' hi1

nu

=A⋅P (P i)=P*(P i)

QED

Page 125: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

132

Computer Aided Design

Splines

Beware of the computation of the slopes x'i ...

Natural Splines :

2 11 4 1

1 4 1⋱

1 4 11 2

x0

'

x1'

x2'

xn−2'

xn−1'

=3x1−x0

3 x2−x0

3x3−x1

3xn−1−xn−3

3 xn−1−xn−2

P i'=L(P i−P j)⇒ P i

' *=L (P i

*−P j

*)=L((A⋅Pi+t)−( A⋅P j+t))

=A⋅L(P i−P j)=A⋅Pi'

Linear operator

It is OK in this case

Page 126: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

133

Computer Aided Design

Splines

Rotation of 45° Scaling x direction

(times 0.5) Followed by a

translation

Page 127: Interpolation and polynomial approximation Interpolation - … · 2019-07-15 · 1 Computer Aided Design Outline Interpolation and polynomial approximation Interpolation Lagrange

134

Computer Aided Design

Splines

3D Curves Minimal order so that a curve can have a torsion

(non planar curve) Let's consider a Lagrange interpolation 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

P u=∑i=0

n−1

P i l ipu