computer aided design - cadxfem · 2017-10-10 · computer aided design bézier curves (following)...

97
1 Computer Aided Design Polynomial approximation

Upload: others

Post on 28-May-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

1

Computer Aided Design

Polynomial approximation

Page 2: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

2

Computer Aided Design

Outline

Approximation Bézier curves B-Splines We still focus on curves for the moment.

Page 3: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

3

Computer Aided Design

Bézier curves

Page 4: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

4

Computer Aided Design

Bézier curves

Bézier curves Pierre Bézier (1910-1999) Develops UNISURF –

first surface modelling software at Renault's (1971)

Publicizes the theory under his name in 1962... however, the principle was discovered in 1959 by Paul de Casteljau (at Citroën's) ! Because of the “culture of secret” at Citroën, De Casteljau will have his works recognized only in 1975.

Page 5: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

5

Computer Aided Design

Bézier curves

Use of Bézier curves : Postscript fonts (cubic Bézier) & TrueType

(quadratic Bézier)

Computer graphics In geometrical modeling and CAD, they tend to be

replaced by more general techniques (NURBS)

AaBbCc

Page 6: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

6

Computer Aided Design

Bézier curves

Modelling by interpolation is not very practical We seldom have interpolation points at our hand

Instead, we hope to define these points as the result of a modeling process instead of as an input data

Approximation gives more freedom in the design of the curve

Page 7: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

7

Computer Aided Design

Bézier curves

Elements of a Bézier curve :

n=d+1 control points

Bézier curve

Control Polygon with d=n-1 sides

(also called characteristic

polygon)

For Bézier curves, the notion of knot is trivial :

u0=0 u1=1

Page 8: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

8

Computer Aided Design

Bézier curves

Characteristics of Bézier curves More freedom than interpolation

Any degree Precise control of the curve's shape Numerical stability even with high degree (not as Lagrange !)

The are Bernstein polynomials (Sergei N. Bernstein, 1880-1968 - don't mistake for Leonard Bernstein...:) :

They form a complete polynomial basis They are a partition of the unity Sometimes called ‘blending functions’ The curve is described as one polynomial (unlike splines)

P (u)=∑i=0

d

P i Bid(u)

Bidu

Page 9: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

9

Computer Aided Design

Bézier curves

Bernstein polynomials

Bidu=di u

i1−ud−i

Binomial coefficients

Page 10: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

10

Computer Aided Design

Bézier curves

Binomial coefficients : computed with Pascal's triangle

1

1 1

1 2 1

1 3 3 1

1 4 6 4 1

1 5 10 10 5 11 2 3 4 5

d=0

1

2

3

4

5

di di =d !

d−i ! i !

(di )=(d−1

i )+(d−1i−1 )

i=0

Page 11: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

11

Computer Aided Design

Bézier curves

Bernstein polynomials

By design, they form a partition of unity...

Bid(u)=(di )u

i(1−u)d−i

1

Binomial coefficients

=∑i=0

d

Bid(u)

=∑i=0

d

(di )Ai Bd−i

=[(1−u)+u ]d=[A+B ]d =∑

i=0

d

(di )ui(1−u)d−i

Page 12: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

12

Computer Aided Design

Bézier curves

Some characteristics of the B. polynomials. has a root of multiplicity i for u=0 has a root of multiplicity d-i for u=1 (symmetry of the basis) If i≠0, has a unique maximum at u=i/d

Bid(u)=0 if i< 0 or i> d

Bid(0)=δi 0 and Bi

d(1)=δi d

Bidu

Bid(u)≥0 for u∈[0,1]

Bidu

Bid(1−u)=Bd−i

d(u)

Bi' d=d Bi−1

d−1u −Bi

d−1u

Bidu

Bid(i /d )=i i d−d

(d−i)(d−i )(di )

Page 13: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

13

Computer Aided Design

Bézier curves

Demonstration of Bi' d(u)=d (Bi−1

d−1(u)−Bi

d−1(u))

Bi' d(u)=(di )i u(i−1)

(1−u)d−i−(di )(d−i)ui

(1−u)d−i−1

(di )=d !

(d−i)! i !=(d−1

i−1 )di

Bi' d(u)=d (d−1

i−1 )u(i−1)(1−u)d−i

−d (d−1i )ui

(1−u)(d−1)−i

(di )=d !

(d−i)! i !=(d−1

i ) dd−i

d Bi−1d−1(u) d Bi

d−1(u)

QED

Page 14: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

14

Computer Aided Design

Bézier curves

Recurrence relations of Bernstein's basis

... but no practical interest other than demonstrating algebraic relations (cf. following)

These polynomials are usually not computed explicitly

Bidu=1−uBi

d−1uu Bi−1

d−1u

Bddu=u Bd−1

d−1u B0

du=1−uB0

d−1u

Page 15: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

15

Computer Aided Design

Bézier curves

Demonstration of the recurrence relations

Bidu=di u

i1−ud−i (di )=(

d−1i )+ (d−1

i−1 )

=(d−1i )⋅ui

(1−u)d−i+ (d−1

i−1 )⋅ui(1−u)d−i

=(1−u)⋅(d−1i )⋅ui

(1−u)(d−1)−i+ u⋅(d−1

i−1 )⋅u(i−1)(1−u)(d−1)−(i−1)

(1−u)⋅Bid−1(u) u⋅Bi−1

d−1(u)

QED

Page 16: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

16

Computer Aided Design

Bézier curves

Degree 4 No negative values

Therefore, no value above 1!

Page 17: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

17

Computer Aided Design

Bézier curves

Degree 20 No extreme values

Existence of a limit envelope

e (u)=1

√2 d πu(1−u)

e (u)

Page 18: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

18

Computer Aided Design

Bézier curves

The characteristics of Bernstein polynomials involve that the Bézier curve

: interpolates P

0 and P

d ,

is invariant by affine transformations , is contained in the convex

hull of its control points(because P(u) is a combination with positive coefficients of control points – also called convex combination) ,

P u=∑i=0

d

Pi Bidu

Page 19: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

19

Computer Aided Design

Bézier curves

(following) is variation diminishing : the curve has less inflexion

points (wiggles) than there are undulations of the characteristic polynomial (proof by the fact that a Bézier curve is obtained by recursive subdivision, see further) ,

delimits a closed convex domain if the control polygon itself is convex and closed... ,

Its length is smaller than that of the control polygon.

Page 20: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

20

Computer Aided Design

Bézier curves

Same examples as shown earlier on Lagrange interpolation Circle with an increasing number of points Perturbation of the control points

Page 21: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

21

Computer Aided Design

Bézier curves

Degree 2

Page 22: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

22

Computer Aided Design

Bézier curves

Degree 4

Page 23: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

23

Computer Aided Design

Bézier curves

Degree 10

Page 24: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

24

Computer Aided Design

Bézier curves

Degree 20

Page 25: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

25

Computer Aided Design

Bézier curves

When the number of control points increases, the curve tends to the control polygon (under the assumption that the control polygon itself converges to a smooth curve ... )

The approximation involves a substantial error between the curve and the control points However, an interpolation is not the objective here...

Page 26: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

26

Computer Aided Design

Bézier curves

Perturbation of a point We shift the indicated point

Page 27: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

27

Computer Aided Design

Bézier curves

Degree 4

Page 28: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

28

Computer Aided Design

Bézier curves

Degree 10

Page 29: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

29

Computer Aided Design

Bézier curves

Degree 20

Page 30: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

30

Computer Aided Design

Bézier curves

Editing Bézier curves Degree elevation Computation of points on the curve (De Casteljau's

algorithm and others ) Changing the range of a curve

Cutting, extension Curves defined by pieces and recursive subdivision

Page 31: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

31

Computer Aided Design

Degree elevation A curve of degree d+1 is able to represent any

curve of degree d If there aren't enough control points to design a

given shape, the degree may be increased... New control points must be determined (one more !) Forrest's equations [1972]

Q0=P0

Q i=i

d+1P i−1+(1−

id+1

)Pi for i=1,⋯ , d

Qd1=P d

Bézier curves

Page 32: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

32

Computer Aided Design

Bézier curves

Demonstration of Forrest's equations :

Let's express in function of

P (u)=∑i=0

d

P i Bid(u) Q (u)=∑

i=0

d+1

Q i Bid+1(u)

Q (u)=P (u) ∀ u∈[0,1]

Bid(u)=(di )u

i(1−u)d−i

Bid +1(u)Bi

d(u)

Bid +1(u)=(d+1

i )ui(1−u)d−i+1

=(1−u)(d+1

i )

(di )Bi

d(u)

Q i= f (P0 ... P d)

Page 33: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

33

Computer Aided Design

Bézier curves

We replace the terms of the binomial

(d+1i )=

(d+1)!(d+1−i) ! i !

=(di )d+1

d+1−i

Bi+1d +1(u)=(d+1

i+1 )ui+1(1−u)d−i

=u(d+1

i+1 )

(di )Bi

d(u)

(d+1i+1 )=

(d+1)!(d−i)!(i+1)!

=(di )d+1i+1

(di )=d !

(d−i)! i !

Bid +1(u)=(1−u)

d+1d+1−i

Bid(u) Bi+1

d +1(u)=u

d+1i+1

Bid(u)

(1− id+1 )Bi

d +1(u)=(1−u)Bi

d(u)

i+1d+1

Bi+1d +1(u)=u Bi

d(u)

Page 34: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

34

Computer Aided Design

Bézier curves

Bid(u)=(1− i

d+1 )Bid +1(u)+

i+1d+1

Bi+1d +1(u)

Q (u)=P (u)⇒∑i=0

d +1

Qi Bid+1(u)=∑

i=0

d

P i((1− id+1 )Bi

d+1(u)+

i+1d+1

Bi+1d +1(u))

=∑i=0

d

P i(1− id+1 )Bi

d+1(u)+∑

i=1

d+1

P i−1i

d+1Bi

d+1(u)

=∑i=1

d

(P i(1− id+1 )+P i−1

id+1 )Bi

d+1(u)+P0 B0

d+1(u)+Pd Bd +1

d +1(u)

Qi

Qd +1

Q0

Bid(u)=(1−u)Bi

d(u)+u Bi

d(u) We split up

Bi

d(u)

QED

Bid(u)and replace :

We renumber :

Page 35: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

35

Computer Aided Design

Bézier curves

Degree elevation in practice ...

Degree 4

Page 36: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

36

Computer Aided Design

Bézier curves

Degree 5

Page 37: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

37

Computer Aided Design

Bézier curves

Degree 6

Page 38: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

38

Computer Aided Design

Bézier curves

Degree 7

Page 39: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

39

Computer Aided Design

Bézier curves

Degree 8

Page 40: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

40

Computer Aided Design

Bézier curves

Degree 9

Page 41: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

41

Computer Aided Design

Bézier curves

Degree 21

Page 42: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

42

Computer Aided Design

Bézier curves

De Casteljau's algorithm Allows the robust construction of points on the

curve Very simple geometrical interpretation

Page 43: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

43

Computer Aided Design

Bézier curves

Principle of De Casteljau's algorithm Construction of the centroids of the control

points : We continue with ....

As far as possible, until only one control point remains,That control point is P(u).

P i0

P i1

P i1=(1−u)P i

0+u P i+1

0

P i2

P0d

Page 44: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

44

Computer Aided Design

Bézier curves

Kig

Page 45: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

45

Computer Aided Design

Bézier curves

The algorithm is :

What is its complexity ? Consists of 3d(d+1) multiplications

and 3d(d+1)/2 additions , so quadratic with respect of the the degree d.

Initialization of For j from 1 to d For i from 0 to d-j

EndForEndFor is the point we want.

P ij=1−uPi

j−1u Pi1

j−1

P0d

P i0

Page 46: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

46

Computer Aided Design

Bézier curves

Demonstration with the help of recurrence relations

By gathering the terms :

by setting

P (u)=∑i=1

d−1

Pi ((1−u)Bid−1(u)+u Bi−1

d−1(u))

+P0(1−u)B0d−1(u)+Pd uBd−1

d−1(u)

Bid(u)=(1−u)Bi

d−1(u)+u Bi−1

d−1(u)

Bdd(u)=u Bd−1

d−1(u) B0

d(u)=(1−u)B0

d−1(u)P u=∑

i=0

d

Pi Bidu

P (u)=∑i=0

d−1

[(1−u)P i+u P i+1 ] Bid−1(u)

P i1=1−u Pi

0u Pi1

0

Bid−1u

P u=∑i=0

d−1

P i1 Bi

d−1u

Page 47: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

47

Computer Aided Design

Bézier curves

We do it again with P u=∑i=0

d−1

P i1 Bi

d−1u

P(u)=∑i=1

d−2

Pi1((1−u)Bi

d−2(u)+ u Bi−1

d−2(u))

+ P01(1−u)B0

d−2(u)+ Pd−1

1 u Bd−2d−2(u)

P u=∑i=0

d−2

Pi2 Bi

d−2u

P u=P0d B0

0u , B0

0u≡1 QED

P u=∑i=0

d−2

[1−uP i1u P i1

1 ]Bid−2u

......

P (u)=(1−u)P0d−1 B0

1(u)+u P1

d−1 B11(u)

Page 48: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

48

Computer Aided Design

Bézier curves

Evaluation with Horner's method We rewrite the polynomials to a monomial form

a i=M hP i M h=(1 0 0 ⋯ 0−d d 0 ⋯ 0

d (d−1)2

−d (d−1)d (d−1)

2⋯ 0

⋮ ⋮

−1d−1 d d (d−1) ⋯ ⋯ 0

−1d−1d−1 d −1d−2 d (d−1)

2⋯ 1

)ai=di ∑j=0

i

−1i− j ij P j

P u=∑i=0

d

Pi Bidu=∑

i=0

d

ai ui

Page 49: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

49

Computer Aided Design

Bézier curves

Complexity of Horner's method : 3d multiplications + 3d additions ... without taking

into account the change of polynomial basis (to be done only once)

But : change of the internal representation Some authors have shown that numerical errors

introduced during the change of internal representation are substantial.

a i=M hP i

Page 50: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

50

Computer Aided Design

Bézier curves

Method based on Bernstein polynomials We factor the terms in

This is a monomial form that can be evaluated with Horner's method – without any change of the internal representation (points P

i )

But beware when u → 1 !!!! We'd rather factor rather the terms , That gives :

P u=∑i=0

d

Pi Bidu=1−ud∑

i=0

d

Pi di u

1−u i

1−u d−i Bidu=di u

i1−ud−i

ui

P u=∑i=0

d

Pi Bidu=ud∑

i=0

d

Pi di 1−u

u d−i

Page 51: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

51

Computer Aided Design

Bézier curves

To summarize :

P u={1−ud∑

i=0

d

P i di u

1−u i

, 0u≤12

ud∑i=0

d

P i di 1−u

u d−i

, 12u≤1

P(u)=(1−u)d (P0 P1 ⋯ P d)((d0 )

(d1)u

1−u

(d2)(u

1−u )2

(dd )(u

1−u )d )

Page 52: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

52

Computer Aided Design

Bézier curves

Algorithmic complexity of the vectorial method Requires 6d multiplications and 3d additions. No change in the internal representation

Page 53: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

53

Computer Aided Design

Bézier curves

Choice of algorithm ? Robustness

1 De Casteljau 2 Vectorial 3 Horner

Speed 1 Horner 2 Vectorial 3 De Casteljau *

De Casteljau

Vectorial

Horner

d

Tot

al f

lops

Page 54: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

54

Computer Aided Design

Bézier curves

In practice The vectorial algorithm is often used to quickly

compute points for display purposes De Casteljau's algorithm is used for increased

robustness and ... It allows to obtain derivatives of curve (see later...) It allows interesting geometrical operations (see later …) If many points are to be computed, it may actually

perform well (see later !)

Page 55: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

55

Computer Aided Design

Bézier curves

Restriction of a curve (cutting) Let us compute the intersection of two curves

We need a independent representation of each segment One wants 0<u<1 on each segment

Page 56: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

56

Computer Aided Design

Bézier curves

Let us start from De Casteljau's geometrical construction

Page 57: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

57

Computer Aided Design

Bézier curves

Let us start from De Casteljau's geometrical construction

The control polygon of the both parts is obtained from points coming from De Casteljau's algorithm !

Page 58: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

58

Computer Aided Design

Bézier curves

Curve to trim

u=0

I0

P0

0

u=1

I1

P3

0

P10

P2

0

Page 59: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

59

Computer Aided Design

Bézier curves

For a curve that we want to trim :1 – Compute the intersection point I

1 – at u=u

1 with help of De

Casteljau's algorithm – this gives the points Pij

Page 60: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

60

Computer Aided Design

Bézier curves

1 – Compute the intersection point I1 – at u=u

1 with help of De

Casteljau's algorithm – this gives the points Pij

u=0

I0

P0

0

u=1

I1

P3

0

P10

P2

0

P0

1

P1

1

P2

1

P0

2

P1

2

P0

3

Page 61: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

61

Computer Aided Design

Bézier curves

For a curve that we want to limit :1 – Compute the intersection point I

1 – at u=u

1 with help of De

Casteljau's algorithm – this gives the points Pij

2 – Among these points, consider the points P0

j : they are vertices of the characteristic polygon of the curve's restriction at the interval P

0-I

1 , and the new parametrization

is u*=u/u1

Page 62: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

62

Computer Aided Design

Bézier curves

2 – Among these points, consider the points P0

j : they are vertices of the characteristic polygon of the curve's restriction at the interval P

0-I

1 , and the new parametrization

is u*=u/u1

u=0

I0

P0

0

u=1

I1

P0

1

P0

2

P0

3

u*=0

u*=1

Page 63: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

63

Computer Aided Design

Bézier curves

For a curve that we want to limit :1 – Compute the intersection point I

1 – at u=u

1 with help of De

Casteljau's algorithm – this gives the points Pij

2 – Among these points, consider the points P0

j : they are vertices of the characteristic polygon of the curve's restriction at the interval P

0-I

1 , and the new parametrization

is u*=u/u1

3 – Calculate the intersection I0 on the new curve – at u*=u*

0 -

gives the points P*ij

Page 64: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

64

Computer Aided Design

Bézier curves

3 – Calculate the intersection I0 on the new curve – at u*=u*

0 -

gives the points P*ij

P*2

1

P*1

1

P*01 P*

03

P*0

2

P*1

2

u=0

I0

u=1

I1

P*2

0

P*3

0

u*=0

u*=1

u0*

P*1

0

P*0

0

Page 65: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

65

Computer Aided Design

Bézier curves

For a curve that we want to limit :1 – Compute the intersection point I

1 – at u=u

1 with help of De

Casteljau's algorithm – this gives the points Pij

2 – Among these points, consider the points P0j : they are

vertices of the characteristic polygon of the curve's restriction at the interval P

0-I

1 , and the new parametrization

is u*=u/u1

3 – Calculate the intersection I0 on the new curve – at u*=u*

0 -

gives the points P*ij

4 – Consider the points P*id : vertices of the characteristic

polygon of the curve's restriction to the interval I0-I

1 : new

parametrization is u'=(u*-u*0)/(1-u*

0)

Page 66: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

66

Computer Aided Design

Bézier curves

4 – Consider the points P*id-i : vertices of the characteristic

polygon of the curve's restriction to the interval I0-I

1 : new

parametrization is u'=(u*-u*0)/(1-u*

0)

P*2

1

P*0

3

P*1

2

u=0

I0

u=1

I1

P*3

0

u*=1

u*=0

u'=1u'=0

Page 67: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

67

Computer Aided Design

Bézier curves

P'2

P'0

P'1

I0

I1

P'3

u'=1

u'=0

Page 68: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

68

Computer Aided Design

Bézier curves

With the same algorithm, we can increase the parametric domain of a curve Intersection with objects close but not touching the

curve's extremities Beware : Bézier curves are variation diminishing

and convex combinations only when 0≤u≤1...

Page 69: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

69

Computer Aided Design

Bézier curves

u=0.8u=0.1

Desired cutting points

Page 70: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

70

Computer Aided Design

Bézier curves

Cutting for u=0.8

Page 71: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

71

Computer Aided Design

Bézier curves

Cutting for u=0.8...and for u=0.1 (at u*=0.1/0.8)

Page 72: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

72

Computer Aided Design

Bézier curves

Extension for u=1.1

Page 73: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

73

Computer Aided Design

Bézier curves

Extension for u=1.1 and cutting for u=0.1 - at (new parameter) u*=0.1/1.1 ...

Page 74: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

74

Computer Aided Design

Bézier curves

Curves defined by pieces Bézier curves do have a global control If we need local control, we have to assemble

several of them We have to impose some continuity at the interface

points between curves

Page 75: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

75

Computer Aided Design

=d P0B−1d−1−B0

d−1

P1B0d−1−B1

d−1

P2B1d−1−B2

d−1

Pd Bd−1d−1−Bd

d−1

Bézier curves

Expression of the derivatives of a Bézier curve with

By factoring :

dPdu(u)=d∑

i=0

d−1

(P i+1−P i)Bid−1(u)

dPduu=∑

i=0

d

Pi Bi' du Bi

' d=d Bi−1

d−1u −Bi

d−1u

dPduu=d∑

i=0

d

Pi Bi−1d−1u−Bi

d−1u

Bid−1u

=0

=0

P i'=P i+1−P i

Page 76: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

76

Computer Aided Design

Bézier curves

First derivative

The control points P'0 and P'

d-1

are interpolated so the first derivativeat the extremities only depends

on the two first (resp. last) control points

dPduu=d∑

i=0

d−1

P i1−P iBid−1u

dPduu=d∑

i=0

d−1

Pi' Bi

d−1u

O P(u)

P2

P0

P1

P3

P'0

P'1

P'2

1d

dPduu

O

First hodograph

Page 77: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

77

Computer Aided Design

Bézier curves

Second derivative = derivative of the derivative

The control points P''0 and P''

d-2...

are interpolated, so the second derivative atthe extremities only depends on the three first (resp. last)control points

d 2 Pdu2 u=d−1d∑

i=0

d−2

Pi1'−P i

'Bi

d−2u

d 2 Pdu2 u=d−1d∑

i=0

d−2

Pi'' Bi

d−2u

P'0

P'1

P'2

1d

d Pd uu

O1

d d−1d 2 Pdu2 u

P''1

P''2

Second hodograph

Page 78: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

78

Computer Aided Design

Bézier curves

Derivative of order k

The derivative of order k at the extremities only depends on the k+1 first (resp. last) control points.

Of course, there must be enough control points ... ( k < d+1 )

d k Pduk u=d−k1⋯d−1d∑

i=0

d−k

Pi1(k-1)−Pi

(k-1)Bi

d−ku

d k P

duku =∏

l=1

k

d−l1∑i=0

d−k

P i(k) Bi

d−ku , Pi

(k)=P i1

(k-1)−Pi

(k-1)

=(Pi+ 2(k-2)−2 Pi+ 1

(k-2)+ Pi

(k-2))

=∑j=0

k

(−1) j

(dj )P j+ i(0)

Page 79: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

79

Computer Aided Design

Bézier curves

Page 80: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

80

Computer Aided Design

Bézier curves

Relation between De Casteljau's algorithm and the derivatives From control points, it is possible to build a curve

that gives directly the value of the derivative.

We can also get derivatives while computing the position by De Casteljau's algorithm.

Let us consider the penultimate iteration of De Casteljau's algorithm :

dPduu=d∑

i=0

d−1

P i1−P iBid−1u

P i1=1−uPi

0u Pi1

0

P id−1=1−uP i

d−2u P i1

d−2

Page 81: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

81

Computer Aided Design

Bézier curves

Relation that links the points at the step d -1 to control points :

P id−1=∑

j=0

d−1

Pi j0 B j

d−1u

dPduu=d∑

i=0

d−1

P i10−Pi

0Bi

d−1u

=d ∑i=0

d−1

P i10 Bi

d−1u−∑

i=0

d−1

P i0 Bi

d−1u

=d P1d−1−P0

d−1

Page 82: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

82

Computer Aided Design

Bézier curves

So d times the difference between the two penultimate points of the De Casteljau algorithm yields the derivative !

dPduu

d=3

Page 83: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

83

Computer Aided Design

Bézier curves

Derivatives of higher order, same treatment

P id−k=∑

j=0

d−k

P i j0 B j

d−ku

=∏l=1

k

d−l1∑i=0

d−k

Pi2(k-2)−2 P i1

(k-2)P i

(k-2)Bi

d−ku

=∏l=1

k

(d−l+ 1)∑i=0

d−k

(∑j=0

k

(−1) j

(kj)P j+ i(0) )Bi

d−k(u)

=∏l=1

k

(d−l+ 1)∑j=0

k

(−1) j

(kj )P jd−k

d k P

duku=∏

l=1

k

d−l1∑i=0

d−k

Pi(k) Bi

d−ku

Page 84: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

84

Computer Aided Design

Bézier curves

Example for k=2 and d=3

By using De Casteljau’s algorithm to compute P(u), one also obtains derivatives up to order d, the latter one being constant. All higher order derivatives vanish.

dk P

duk(u)=∏

i=1

k

(d−i+ 1)∑j=0

k

(−1) j

(kj)P jd−k

d 2 P

du2u =3⋅2⋅P0

1−2 P1

1P 2

1

Page 85: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

85

Computer Aided Design

Bézier curves

Connecting two curves is the same as imposing constraints on the control points on both sides of the « sticking » point We assume regular curves

G0 continuity (positions) (same as C

0 continuity)

P0

P1

P3=P*

0

P*1

P*2

P*3

P2

Page 86: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

86

Computer Aided Design

Bézier curves

G1 continuity ( C

1 continuity is more strict)

Minimum degree : 2

P0

P1

P3=P*

0

P*1 P*

2

P*3

P2

P d−1 Pd= P0* P1

* , > 0 (=1 for a C1 continuity )

Page 87: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

87

Computer Aided Design

Bézier curves

G2 continuity ( C

2 continuity is more strict)

Continuity of the orientation of the osculatory plane

Continuity of the curvature radius

Pd−Pd−1×Pd−1−Pd−2=P2*−P1

*×P1

*−P0

*

d∥Pd−1−Pd−2∥3

(d−1)∥(Pd−Pd−1)×(P d−1−P d−2)∥=

d *∥P1*−P0

*∥3

(d *−1)∥(P2

*−P1

*)×(P1

*−P0

*)∥

R=∥dP

du∥3

∥d 2 P

du2 ×dPdu∥

Page 88: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

88

Computer Aided Design

Bézier curves

G2 continuity ( C

2 continuity is more strict)

Continuity of the osculatory plane's orientation

Continuity of the curvature radiusPd−Pd−1×Pd−1−Pd−2=P2

*−P1

*×P1

*−P0

*

P0

P1

P3=P*

0

P*1

P*2

P*3

P2

d‖P d−P d−1‖3

(d−1)‖(P d−P d−1)×(Pd−1−Pd−2)‖=

d *‖P1*−P0

*‖3

(d *−1)‖(P2

*−P1

*)×(P1

*−P0

*)‖

Page 89: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

89

Computer Aided Design

Bézier curves

The Gk continuity with k > 2 in the general case is

complex to impose The C

k continuity is easier to impose (simple

expression of higher order derivatives) Curve should be regular ! Same as imposing the continuity of functions x(u), y(u)

and z(u) , independently of each other.

d k P

duku=∏

l=1

k

d−l1∑i=0

d−k

Pi(k) Bi

d−ku

Page 90: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

90

Computer Aided Design

Bézier curves

C0 continuity

P0

P1

P3=P*

0

P*1

P*2

P*3

P2

Pd=P0*

Page 91: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

91

Computer Aided Design

Bézier curves

C1 continuity

P0

P1

P3=P*

0

P*1

P*2

P*3

P2

P1*=PdPd−Pd−1

Page 92: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

92

Computer Aided Design

Bézier curves

C2 continuity

P0

P1

P3=P*

0

P*1

P*2

P*3

P2

P2*=Pd−24P d−Pd−1

Page 93: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

93

Computer Aided Design

Bézier curves

C3 continuity

P0

P1

P3=P*

0

P*1

P*2

P*3

P2

P3*=8 Pd−12 Pd−16 Pd−2−Pd−3

Page 94: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

94

Computer Aided Design

Bézier curves

The curve has now a unique representation of degree 3.

P0

P*3

Page 95: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

95

Computer Aided Design

Bézier curves

Recursive subdivision Allows to draw the curve quickly with the help of De

Casteljau's algorithm Idea : splitting up the curve in two parts at u=0.5, then

these sub-curves in four parts ( still for u*=0.5) and so on. The control points of the sub-curves are obtained like a

residual of the De Casteljau algorithm at each step The control points quickly converge toward the curve When the gap between the starting and ending points of

each sub-curves is lower than a factor (depends on the resolution), we join simply the points of the characteristic polygon by straight line segments.

It's a « divide and conquer » approach – a famous paradigm in software engineering.

Page 96: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

96

Computer Aided Design

Bézier curves

0 subdivision

2 subdivisions

4 subdivisions

8 subdivisions

16 subdivisions

32 subdivisions

Page 97: Computer Aided Design - Cadxfem · 2017-10-10 · Computer Aided Design Bézier curves (following) is variation diminishing: the curve has less inflexion points (wiggles) than there

97

Computer Aided Design

Bézier curves

Cost of the recursive subdivision algorithm In for m levels of subdivision Number of generated points: For each point that is generated, the algorithm

becomes linear... Competitive in comparison with Horner It is not very accurate, nevertheless very robust.

O d 2⋅2m

d⋅2m