<<

Parametric Curves & Surfaces Parametric / Implicit Parametric Curves (Splines) Parametric Surfaces Subdivision

Marc Neveu – LE2I – Université de Bourgogne

1 2 ways to define a circle

Parametric Implicit

F>0

F=0 u

F<0

xu=r.cosu F x ,y= x2 y2−r 2 {yu=r.sinu

2 ­ Representations of a curve (2D)

Explicit : y = y(x) y=mx+b y=x2 must be a function (x­>y) : important limitation

Parametric : (x,y)=x(u),y(u)) (x,y) = (cos u, sin u) + easy to specify ­ hidden additional variable u : the parameter

Implicit : f(x,y) = 0 x2+y2­r2=0 + y can be a multivalued function of x ­ difficult to specify, modify, control

3 ­ Representations of curves and surfaces (3D)

x2+y2+z2­1=0 • Implicit Representation x­y=0

• Curves : f(x,y,z) = 0 and g(x,y,z) =0 • Surfaces : f(x,y,z) =0

• Parametric Representation • Curves : x = f(t), y = g(t), z = h(t) • Surfaces : x = f(u,v), y = g(u,v), z = h(u,v) • Cubic Curve : 3 2 • x= axt + bxt + cxt + dx 3 2 • y = ayt + byt + cyt + dy 3 2 • z = azt + bzt + czt + dz 4 xt =x R.cos2.t  0 Helicoid : yt =y R.sin2 .t 0 u∈ℝ ,v∈ℝ  =  {z t z0 p.t x=v.cosu y=v.sinu Helix passing by (x ,y ,z ), radius R, 0 0 0 {z=u pitch p

5 Representation of Surfaces

Parametric Surface – (x(u,v),y(u,v),z(u,v)) Ex : plane, sphere, cylinder, torus, bicubic surface, sweeping surface parametric functions allow moving onto the surface modifying u and v (eg in nested loops) Easy for polygonal meshes, etc Terrific for intersections (ray/surface), testing points inside/border, etc Implicit Surface F(x,y,z)=0 Ex : plane, sphere, cylinder, torus, blobs Terrific for visualization Easy for intersections, morphing Subdivision Surface Defined by a control mesh and a recursive subdivision Easy for interactive conception 6 Visualization of Parametric Curves

View of functions x(t), y(t), z(t) Parametric 3D curve, without t Parameterization of a curve: infinite number of solutions (with (un­)constant speed, (dis­)continuous, by arc length,...)

7 Parametric Curves : summary

Why piecewise , why cubics ? Principal Curves : Hermite splines, Bezier splines, Catmull­Rom splines, natural cubic splines, B­Splines, NURBS Surfaces

8 Building Curves

Representing is not building Goals for building curves : Smooth, “thin plate” curve Use control points Like ship builders : Weights or joints to handle a flexible latte () The latte passes by the joints and has a “smooth” shape Mathematically ?

9 2 types of curves

Interpolation Approximation

The curve passes by the control pointsThe curve is attracted by control points

10 Before we start...

A few mathematical bases....

11 Let E3 be an Euclidian space

Parametric curve :

2 n Qt =[ xt , y t, zt ]= X 0X1 t X2 t ... Xn t eg :

Qt =X 0 X1 t barycentric combination BC of E3 : point of E3 /

n

BC=∑  i Pi i=0 n

∑  i=1 {i=0

convex combination BC /  ≥ ∀ i 0 i 12 Barycentric Coordinates

area p, b, c areaa , p ,c areaa, b, p u= v= w= p=u av bw c areaa ,b ,c areaa ,b ,c areaa ,b ,c b uvw=1 a b c 1 x x c areaa , b, c= a b c 2 y y y ∣1 1 1 ∣ b p c u : v : w

pa

pc a p c u + v : w u : w

a 13 Convex Hull

The set of all the convex combinations of a set  of points of E3 is the convex hull of 

A particular case of a convex combination : the linear of 2 distinct points a and b : Q(t) = (1­ t) a + t b

14 Parameterization

Segment [a, b] is defined by the affine application [0,1] → E3 ∀ t ∈ ℝ x ∈ E3 We can change the parametric space without altering [a, b] in E3 u−u ℝ t= a ub−ua u u u a b ℝ E3 0 t 1 a b u −u u−u15 x t=1 ­ t at b xu= b a a b ub−ua ub ­ ua Interpolation

Let P0, ..., Pn and t0, ..., tn the corresponding parameter values. – Interpolation consists in finding a curve P(t) passing by all the points – Compute a polynomial satisfying the interpolation constraints : P(ti) = Pi (i=0..n) • Theorem : – There exists a unique polynomial P of degree

≤ n such that P(ti) = Pi (i=0..n) with fixed Pi and ti

16 Polynomial Interpolation

A polynomial of degree n interpolates a curve in (n+1) points Ex : 2nd degree curve to interpolate 3 points 2 x(t) = at +bt+c in (t1,x1), (t2,x2), (t3,x3) 3 linear equations with 3 unknowns to find out a,b,c Lagrange interpolation curve « sinuous », global, unstable => low degree polynomials and smooth curve simulate an elastic thread (thin plate) 17 Lagrange Interpolation

Data : n + 1 points (with x distinct by 2). i  x0 , y0 ,x1 ,y1 .... xn ,yn 

Lagrange polynomials

n x− x j x−x0 x−x j 1 x− xn L j x= ∏ = ... x−x j −1 iver x j −x j −1 ... i= 0, i≠ j x j −xi x j− x0 x j −x j 1 x j −x n

Two properties : ∀ j degreeL j  = n

L j xi  =  j ,i ie L j x j =1 ∧ L j xi =0 if j≠i

n th 18 L x = ∑ y j L j x Is the unique n degree polynomial verifying L  xi = yi ∀ i j=0 Aitken's Algorithm

P1 P3 2 P0

1 P 1 P0 1 1 P2 3 P0 P0 2 19 P1 P2 Aitken's Algorithm

1 ti 1−t t−ti Recursive Proof : r=1 Pi t = Pi  Pi1 i=0,..., n−1 t i1−t i t i1−ti ­1 r­1 Suppose proposition true for r­1 : P0r interpolates Pi, i=0,...,r­1 and P1 interpolates Pi, i=1,...,r

r tr −t r−1 t−t 0 r −1 P0 t = P0  t P1 t  t r −t 0 t r −t 0 n = ∗ n−1  ∗ n−1 = It interpolates all data points : for t=t0 P0 t 0 1 P0 t 0 0 P1 t 0 P0

Same for t=tn

r−1 r −1 Under assumption P0 t i =P1 ti =Pi i=1,...,r−1

r Since weights sum to 1 P0 t i =Pi ∀ i Generalization

r ti r −t r −1 t−t i r −1 Pi t = Pi  t  Pi1 t  i=0,... ,n−1 ∧ r=1,20... ,n t ir −ti t ir −ti Splines : piecewise polynomial curves

An elastic thread under constraints minimizes its flexion energy ~ integral of the squared curvature ~ second derivative => distribute curvature «in the best way as possible» Spline = piecewise polynomial (several low degree polynomials) The more frequent : cubics Minimize the second derivative

21 Piecewise Polynomials Spline : several combined pieces « correct » combination

Position, tangency and curvature continuity Position continuityPosition and tangency continuity

22 ­ 9 Piecewise linear polynomials

Linear Interpolation p0

p1

pt=1 −t p0 t p1 2 basis functions

1 1 −1 1 t   = 1 p0 =   p t  t  ∑ Bi t pi 0 1 0 1  i =O  p1  23 Bézier Curve

1 −2 1 P 0 0 0 P1 Pt= t 2 t 1 0   −2 2 0 P1 1 0 0  0 P 2 

0 2 0 2 −2 1 P B t P t t 0 0 0 P0 P t = −2 2 2 0 = 2   0 0 t t P1 B1 t P1 P0 2 2 t  P 0 B2 t P0  2   2  2 

n n 0 Bernstein polynomials Pt = ∑ Bi t Pi i =O 24 Degree n=2 Bézier Curve

1 0 0 P0 t  = 1−t P0t P1 1 0 0 P1 t  = 1−t P1 tP2 0 P1 2 1 1 P0 t  = 1−t  P 0t P1 2 P t 1 1 0   P1 t  2 0 0 P0 t  P0 t  = 1−t  1−tP 0 tP1   −  0 0 t 1 t P 1 tP2 P0 0 0 P2 2 2 0 0 2 0 P0 t  = 1−t  P0 2t 1−t P1t P2 n 2 0 2 0 2 0 n 0 = B0 P0B1 P1 B 2 P 2 = ∑ Bi Pi = i 0 degree n = 2 25 Bézier Blending functions

Degree 1 Degree 2

1,2 (1­t)2 t2 1

0,8

1 1 0,6 B1 B 0 2t(1­t) 0,4 t 0,2 0 1 0 1 2 3 4 5 6 7 8 9 10 11

26 Bézier Curve

P0 0 1 P1

2 1 2 1 1 P  t  P  t  P  t  P t P  t  0 1 1 0 1  0 P0 t 

0 0 P0 P P0 0 0 2 P2

27 Subdivision of Bézier curves

Each half is a Bézier curve General de Casteljau algorithm

28 ­ 26 Bézier Curve

29 Cubic Bézier Curve

0 −1 3 −3 1 P0 0 3 2 3 −6 3 0 P Pt =  t t t 1 1 −3 3 0 0 0 P2  1 0 0 0  0 P3

3 0 3 0 1−t P 0 B0 t  P0  − 2 P 0 B 3t P0 Pt = 3t 1 t 1 = 1 1 2  −  0 3 0 3t 1 t P 2 B2 t  P2 3  t  P 0 B 3t P0  3   3  3  30 Bézier Blending Functions

3 B0  t 3 B3 (t)

B3 t 1   3 B2  t

31 Bézier Curve

32 Bezier

General form n n Bn t =∑ B i tPi i=0 with B nt= n 1−t n−i t i i  i 

1 1 1 B. 11−t 1t 2 2 1 1 2 B. 11−t 21−t t 1t 3 3 2 1 1 2 3 B. 11−t 31−t  t 31−t  t 1t ⋮ ⋮ ⋮ ⋮ ⋮ Bi ⋯ n 1−t n−i t i ⋯ ⋯ . i  33 De Casteljau

r r−1 r −1 Pi t =1 −t Pi ttPi1 t r=1, ... ,n i=0, ..., n−r t∈ℝ 0  = {Pi t Pi 0 P1

2 P t 1 1 0   P1 t  P0 t 

P0 0 0 P2

34 Properties of Bernstein Polynomials

n n−1 n−1 Bi t=1−t Bi −1 t t Bi−1 t  0 n {B0t=1 ∧ B j t =0 if j ∉ {0,...,n}

End Points and Convex Hull n n n ∑ Bi t =1 ∧ Bi t≥0 ∀ t ∈ [0,1] i =0

{Bn 0=P0 ∧ Bn 1=Pn

Affine Invariance let f x=A . xb be an affine transformation n n f  B nt=∑ Bi t  f Pi  i =0

35 Properties of Bernstein Polynomials Symmetry

n 0 n n n n Bi t =Bn −i 1−t   ∑ Bi t Pi =∑ Bn−i 1−t  Pi ∀ t ∈ [0,1] i =0 i =n

Affine Invariance for parameters

u−a let t= t ∈[0,1] ∧ u∈[a , b] B t is the same curve as B u b−a n n

36 Properties of Bernstein Polynomials Derivatives First derivative n−1 dBnt  n−1 =n ∑ Pi Bi t with  Pi =Pi 1−Pi dt i =0 n dBi t  n n  =n  Bi −1 t −Bi t  dt Tangent vectors dB 0 dB 1 n =n  P ∧ n =n P dt 0 dt n−1

General form k   n−k k d B n t n! k n−1 k k−1 k−1 k k− j k = ∑  Pi Bi t  with  Pi = Pi 1− Pi=∑ −1 Pi j d t  n−k! i =0 j =0  j  37 Bézier : degree Elevation

Bernstein polynomials properties : n1−i  i1  Bn t = Bn 1 t  Bn 1 t  P i n1 i n1 i1 2

n n 1 C t = P B t P ∑ i i 3 i=0 n n n1−i  i1  =∑ P Bn 1t∑ P Bn 1t  i i  i i1 P 1 i=0 n 1 i =0 n 1 2

n1 n1 n1−i n1 i n1 C t =∑ Pi Bi t ∑ Pi−1 Bi t  i= 0 n1 i =0 n1 since the corresponding term is zero P 1 = P 0 0 P 1 P 1 1 1 P = P 1 i i 3 3 P = P  1− P i=0,... ,n1 i n1 i −1  n1 i P  P 38 Repeated Degree Elevation

r degree elevations P  P  2 P  r P r r has vertices P0 ,P nr r n i− j r n Pi = ∑ P j j= 0  j nr  i 

r lim  P = Curve 39 r ∞ Degree Reduction

Can we write a given curve of degree n+1 as one of degree n? Just approximate.

1 ∗ ∗ P P 1 ∗ ∗ 0 0 = ⋱ ⋮ ⋮ P 1 [ n ] P n 1 ∗ ∗ [ ] [ 1 ] M B = B1  degree elevation MT M B = MT B1 system of normal equations 40 Bézier Curve

41 Bézier Curve

42 Piecewise Bézier Curve

43 More cubics....

Hermite CatmullRom

44 Hermite

Why these ? The only cubics that verify :

p0= p0

p1= p1 dp0 ∣ = =∇ p dt t 0 0 dp0 ∣ = =∇ p dt t 1 1

Interpolate extremities and tangents at the extremities 45 ­ 14 Graphically

Cubic Hermite Spline

∇p0

∇p1

t=1 t=0 p1 p0

Hermite Specification

46 ­ 15 Cubic Curves

Cubic Polynomial p  t  = at 3 +bt 2 +ct+d = t .a T with t= [ t 3 t 2 t 1] and a = [ a b c d ]

a [ p  t  ]=[ t 3 t 2 t 1] b c [ d]

47 Hermite Splines Computation

4 constraints : positions and tangents at both ends of [0,1]

p  0  =p0

p  1  =p1

p'  0  =p' 0

p'  1  =p' 1

Hyp : cubic form : p  t  =at 3 +bt 2 +ct+d 4 unknowns : a,b,c,d

48 Hermite Splines Computation

• As pt=at 3bt 2ctd dpt p't= =3at2btc dt • The 4 constraints give 4 linear equations

p(0) = p0 = d

p(1) = p1 = a+b+c+d

p’(0) = p0 ’ = c

p’(1) = p1 ’ = 3a+2b+c • Solve in a, b, c, d: a=2 ­2 + ’+ ’, b= ­3 +3 ­2 ’­ ’, c= ’, d= p0 p1 p0 p1 p0 p1 p0 p1 p0 p0 • Matrix form...

49 ­ 18 Hermite Splines : matrix form

p0

p1 0 0 0 1 a dp 1 1 1 1 0 = b dt 0 0 1 0 c [3 2 1 0 ][d ] dp1 [dt ] ¿ Control Vector Basis spline coefficients

Solve in spline coefficients p0

a 2 −2 1 1 p1 −3 3 −2 −1 b = dp0 c 0 0 1 0 dt [d ] [1 0 0 0 ] dp 1 [ dt ] Spline coefficients basis control vector 50 ­ 19 Equation of Cubic Hermite Splines

p0 3 2 2 −2 1 1 p1 2t −3t 1 p0 − − − −2t 33t 2 p 3 2 3 3 2 1 dp0 pt= 1 [ p ]=[ t t t 1 ] 3 2 −  ∇ p 0 0 1 0 dt t 2t t 0 3 2  t −t  ∇ p1 1 0 0 0   [ ] dp 1 [dt ]

Basis Control Points Matrix

51 For Hermite cubics, 4 basis functions

3 2 2t −3t 1 p0 − 3 2 p pt= 2t 3t 1 3 2 t −2t t ∇ p0 3 2 ∇  t −t  p1

4 basis functions t

Every Hermite Spline is a linear combination (a blend) of these 4 functions

52 ­ 13 Back to Bézier Curves A kind of Hermite curve

4 control points : P0 and P3 at ending points,

P1 and P2 control the tangents at ending points p(0)= P0, p(1)=P3, p'(0)=3(P1­P0), p'(1)=3(P3­P2) Bézier Matrix ~ Hermite Matrix Convex Hull Property 53 From Hermite to Bézier

p(0)= P0 P 1 0 0 0 0 p(1)=P3 dp dp 1 2 0 0 0 1 P1 p1 p2 = p'(0)=3(P1­P0) [ dt dt ] −3 3 0 0 P 2 p'(1)=3(P ­P ) [0 0 −3 3 ] 3 2 P [ 3 ]

Hermite Control Vector Bézier to HermiteBézier Control Vector

54 Bézier : matrix form

2 −2 1 1 1 0 0 0 P0 −3 3 −2 −1 0 0 0 1 P [ P  t  ]=[ t 3 t 2 t 1] 1 0 0 1 0 −3 3 0 0 P2 [1 0 0 0 ][ 0 0 −3 3 ] P [ 3 ]

Hermite Basis Bézier to HermiteBézier Control Vector

−1 −3 3 1 P0 −3 −6 3 0 P [ P  t  ]=[ t 3 t 2 t 1] 1 3 −3 0 0 P2 [1 0 0 0 ] P [ 3 ] 55 Bézier Basis Functions

3 T  1−t  P0 2 P p  t  = 3t  1−t  1 2 3t  1−t  P2 3 P [ t ] [ 3 ]

Bernstein Polynomials of degree 3 non negative over [0,1], sum up to 1 Property : curve within the convex hull of control points

56 Bézier Blending Functions

57 ­ 25 Hermite Splines Composition

Hermite composed Spline Every piece is a Hermite cubic specify position and tangent a every joint Pieces interpolate positions and tangentes C1 continuity Starting from a list of positions and tangents, build a piecewise cubic that passes at every point These points are joints or nodal points

58 Catmull-Rom Splines With Hermite or Bézier splines, difficult to compose curves to ensure C1 or G1 continuity Catmull­Rom : interpolating cubic splines C1 continuous Data :

(n+1)control points P0,...,Pn

Tangents at every Pi : s (Pi+1 – Pi­1) i=2..n­1 « Phantoms » at ending points

“serial” Hermite splines. Each piece is determined by 4 points

59 Catmull-Rom Matrix

a −s 2−s s−2 s P0 2s s−3 3−2s −s P b = 1 c −s 0 s 0 P2 [d ] [ 0 1 0 0 ] P [ 3 ]

Spline Coefficients Catmull­Rom MatrixControl Points

Compute as for Hermite and Bezier

s is a tension parameter (often s=1/2) 60 Splines with C2?

Higher degree Increase computational cost Polynomials Unstable

Global Control Natural cubics

Cubic B­Splines Approximation

61 Cubic natural Splines

C2 continuity Compute coefficients to solve a cubic equation Global computation(solve tridiagonal linear system ) Natural Splines : second derivatives arbitrarily set to 0 at ending points

62 Cubic natural Splines Data : n+1 points P (t ,y ) i=0,..,n. i i i Find y=f(t) / y =f(t ) with derivatives f'(t) and f"(t) i i continuous over [t0,tn].

Points ti are called knots and hi=ti+1­ti is the step (not necessarily constant but positive: t0

yi=f(ti)

63

ti Cubic natural Splines

<=> find n fonctions Si(t) i=0,1,..,n­1 such that:

(ti,yi) verify the 2 consecutive functions they belong to, except points (t0,y0) and (tn,yn) which belong only to the first and last function.

S 0 t 0= f t 0=y0

Si t i = f t i = yi ∀ i∈{1,... ,n−1} 1  =  = {S n−1 t n f t n yn Continuity conditions for the spline, its derivative, and its second derivative:

Si t i =Si−1 ti 

S ' i t i =S 'i −1t i  ∀ i∈{1,...,n−1} 2  =   {S ' ' i ti S ' ' i−1 ti 64 Cubic natural Splines

n+1 conditions (1) S (t) are polynomials of degree <= i +3 (n­1) conditions (2) 3, find for each 4 coefficients => = 4n­2 linear conditions for the Si(t) total : 4n numbers to be coefficients. determined

S' (t )=f'(t ) and S' (t )=f'(t ) or 0 0 0 n­1 n n 2 conditions are missing : impose S' (t )=f'(t ) and S" (t )=f"(t ) or 0 0 0 0 0 0 2 conditions : S"0(t0)=S"n­1(tn)=0 (natural splines ) or ......

Let zi = S''(ti ) for 0 ≤ i ≤ n. S''(t ) = S''(t ) = 0 => z = z = 0 0 n 0 n the other zi are unknown. 65 Cubic natural Splines

z  −z S'' t=z  i 1 i t−t  Si(t) has degree <=3, S"i(t) is linear i i i hi

with (h =t ­t ) : zi 1 zi i i+1 i = t −t  t −t h i h i1 Two successive integrations give: i i

zi 1 3 zi 3 Si t =  t−t i   t i 1−t  C i t −t i Di ti 1−t  6hi 6 hi

y  h y h S t = y ∧ S t =y ⇒ C = i 1 − i z ∧ D = i − i z i i i i i1 i1 i i1 i i hi 6 hi 6

h h Compute z using S' (t ) = S' (t ) S ' t = i − 1 z  i − 1 z b i i−1 i i i i − 1 i 6 i − 1 3 i i − 1

−hi hi yi 1−yi S ' i ti = zi 1 zibi with bi = 6 3 hi And so : 66 hi − 1 zi −1 2hi − 1hi zi hi zi 1=6bi − bi − 1 Cubic natural Splines

2h h  h 0 1 1 z1 6b1−b0 h 2h h  h 1 1 2 2 z2 6b2 −b1 h 2h h  h  −  2 2 3 3 z3 = 6 b3 b2 ⋱ ⋱ ⋱ ⋮ ⋮

hn−3 2hn−3 hn −2  hn− 2 zn −2 6bn −2 −bn−3  h 2h h  z 6b −b  [ n −2 n−2 n−1 ][ n−1 ] [ n −1 n−2 ]

The system is tridiagonal, strictly diagonally dominant by column : easy to solve (Gauss Seidel, ...)

67 Let the ith piece of the spline be represented by

Cubic natural Splines

2 3 Y i  t=ai bi tci t di t t∈[0,1] ∧ i∈{0,n−1}  1 

Solving for ai, bi, ci, and di then gives

Y i 0= yi =ai

Y i 1= yi 1=ai bici di ' Y i 0=Di =bi ' {Y i 1=Di 1=bi2ci 3di

ai =yi

bi=Di

ci =3yi1−yi −2Di −Di1 68 {di =2yi− yi 1DiDi 1 Cubic natural Splines Now require that the second

Y i −11= yi derivatives also match at the points, so ' ' Y i−11=Yi 0

Y i 0= yi ' '  ' ' {Y i−11=Yi  0

Y 0= y for interior points and endpoints satisfy 0 0 {Y n−1 1=yn

­> 4(n­1)+2=4n­2 equations for 4n unknowns ' ' Y 0 0=0 => two more conditions : second ' ' {Y n−11=0 derivatives at the endpoints be zero 69 Cubic natural Splines

Rearranging all these equations leads to the following symmetric tridiagonal system

2 1 D0 3y1− y0 

1 4 1 D1 3y2−y0

1 4 1 D2 3 y3−y1 1 4 1 = D3 ⋮ ⋮ ⋱ ⋱ ⋱ ⋱ ⋱ ⋱ ⋮ 3yn−1− yn−3 4 1 Dn−1 3yn−yn−2 1 2 〚 〛 D 3y −y −  〚 n 〛 〚 n n 1 〛

70 Interpolation, Continuity, local Control

Hermite/Catmull­Rom/Bézier Interpolatory Local CTRL

Approximation (not interpolation) The curve passes « nearby » the control points Convexe hull property C2 continuity, local control

72 B-Spline Basis (uniform knot vector)

−1 3 −3 1 Pi−3 1 3 −6 3 0 P P  t =[ t 3 t 2 t 1] i−2 i 6 −3 0 3 0 Pi−1 [1 4 1 0 ] P [ i ]

73 Cubic splines Comparison

Type Control Points Continuity Interpolation

Hermite 2 + 2 tgtes C1 O Bézier 4 C1 O Catmull­Rom 4 shared C1 O Natural n shared C2 O B­Splines 4 shared C2 N

74 Non Uniform B-Splines

non uniforme sequence

joint Different basis functions on each knot interval (piece of curve) local control possible reduction of continuity

Nodal sequence or nodal vector

75 B-Spline curves : examples Order = degree+1

Knot vector

76 Basis functions B-Spline curves : examples

Control points and order unchanged. Knot vector changes 77 B-Spline curves : examples

Control points and Knot vector unchanged. Order changes 78 B-spline Curves

m C t = P B t Global Curve : t in [t ,t ] ∑ i i , k 0 m+k i=0

j= m

Union of m­k+2 curves C t  = ∐ C j t j =k −1

j= m i= 0 C t  = P B t  Each curve C is of order k ∐ ∑ i j i j , k j j =k −1 i =−k−1  Example : order k=4, 10 control points (from 0 to m=9), m+k=13 knots, m­ k+2=7 curve pieces 79 B-splines Curves

m

Curve Equation : C t =∑ Pi Bi , k t t ∈[t 0 ,t m k ] , i∈{0,m} i=0

Knot vector : T ={t i ;0imk ∧ t 0ti t m k }

Recurrence computation

1 if t ∈[t i ,t i 1 [ Bi ,1 t= { O otherwise

t−t i t ir −t Bi ,r t = Bi ,r −1t   Bi1,r −1t  for r ∈{2,k} t ir −1−ti ti r −t i 1 0 (convention  0) 0 80 B-splines Curves

1 if t ∈[ t i ,t i 1 [ Bi ,1 t= { O otherwise

t−t i Bi ,2= Bi ,1 ti 1−t i t −t  i 2 B i1,1 t ti 2 −t i1 i ti1 ti2 ti3 ti4

t−ti t−t i Bi ,3= Bi ,1 t i 2−ti ti 1−ti

t −t i t i2−t t i 3−t t−t i 1 Bi ,4 t    Bi1,1 {t i 2−t i t i2−t i1 t i 3−t i 2 t i2−t i1 }

ti 3−t t i 3−t  Bi2,1 ti 3−ti 2 t i 3−t i 2 81 B-splines Curves

Ordre k = 3 Ordre k = 4

Ordre k = 2

82 B-Splines : # pieces

B(u)

u

u0 uk­1 um+1 um+k

Example : k=3 N =[mk−k−1]−[Ok−1] m=8 =[m1]−[k−1] m­k+2=7 = m−k2 Continuity Parametric : Ck Geometric : Gk P(u) continuous till kth P continuous derivative independantly from u till value, slope, 2nd kth derivative derivative,... Position, tangent, Important for animations curvature,... (parameter =time) CAGD,...

A curve may be Ck and not Gk and conversely 84 B Splines Continuity

• Control points Duplication – No duplic. ­ C2 , G2 – 1 duplic. ­ C2 , G1 – 2 duplic. ­ C2 , G0;  segments – 3 duplic. ­ C2 , G0

• Knots Duplication – No duplic. ­ C2 , G2 – 1 duplic. ­ C1 , G1 – 2 duplic. ­ C0 , G0 – 3 duplic. ­C­1, G­1 → several curves

85 ­ 38 C2 Cubic B-    Data : A0,...,An and t0,...,tn and 0= n=3, i=1,i=2,...n­1

2 Find C Cubic B­Spline control points Q0,...,QL, L=n+2 and C(ti)=Ai, i=0,..,n

Q1

A2 Q3 A1

Q4 Q2 d0=A0 A3

Q6=A4

Q5 86 t t0 1 t4 C2 Cubic Spline Interpolation

#unknowns : L+1 = n+3 ∈ #data points = #equations = n+1 : C(ti)=Ai i {0,n} => 2 more conditions : Clamped End Conditions ˙ ˙ Clamped End Conditions : C t 0  and C t n  are given ˙ 3 ˙ 3 C t 0 = [Q1−Q0 ] ∧ C t n = [QL−Q L−1 ] t 1−t 0 t n−t n−1

Triple end knots : Q0=A0 and QL=An t −t t −t − Q =Q  1 0 C˙ t = ∧ Q =Q − n n 1 C˙ t  CEC => 1 0 3 0 L−1 L 3 n

87 C2 Cubic Spline Interpolation

And so 3 3 3 3 Q2 B2 t1 Q3 B 3t 1=r s ∧ Q L−3 B L−2 t n −1QL−2 BL−3 t n−1=r e 3 3 with r s =A1−Q1 B1 t 1 ∧ re= An −1−QL −1 BL−1 t n −1 Because of local support of B Splines : 3 3 3 Ai =Qi B i t i Qi1 Bi1ti Qi 2 Bi 2 t i  i=2,... ,n−2

3 3 B 2t 1 B3t 1 3 3 3 rs B1 t 2 B 2t 2 B 3t 2 Q 2 A ⋮ ⋮ 2 = ⋮ ⋮ ⋮ A 3   3   3   k− 2 B L−3 t K −2 BL− 2 t K− 2 B L−1 t K −2 [Q L−2 ] r 3 3 [ e ] B t  B t  [ L−3 K−1 L−2 K −1 ] 88 B-Splines Interpolation

n Let {Ai}i=0...n (n+1) points with associated knots {ti}0

Find {Qj}j=0..p (p+1) control points so that BS(t) k interpolates Ai with C continuity RESULT

­1 If n=p Q=Bk .A

t ­1 t If p

89 B-Splines Interpolation

n

Bt =∑ Bj , k t.Q j Proof j =1

Bt = A ∀ i Constraints i i Rewrite constraints

A1=B1, k t 1 .Q1 B2, k t 1 .Q2⋯B p ,k t 1.Q p

A2=B 1,k t 2 .Q1 B2, k t 2 .Q2 ⋯ Bp , k t 2 .Qp ⋮

A n=B 1,k t n .Q1 B2, k t n .Q2 ⋯Bp , k t n .Q p Matrix form t t A=B k .Q with A=[ A1 A2⋯ An ] Q=[Q1 Q2⋯Q p]

B1, k t 1 ⋯ ⋯ B p ,k t 1 ⋮ ⋱ ⋮ Bk = ⋮ ⋱ ⋮ 90   ⋯ ⋯   [B 1,k t n B p, k t n ] B-Splines Interpolation

−1 If n=p Q=Bk . A If p

Mettre ici image courbe approximation/interpolation

91 An algorithm

Input: n+1 data points A0, ..... An and a degree k Output: A B­spline curve of degree k that contains all data points in the given order Algorithm: Select a method for computing a set of n+1 parameters t0, ..., tn; => we get a knot vector U; for i := 0 to n do for j := 0 to n do Evaluate Bj,k(ti) into row i and column j of matrix B; /* matrix B is available */ for i := 0 to n do Place data point Ai on row i of matrix A; /* matrix A is constructed */ Use a linear system solver to solve for Q from A = B.Q Row i of Q is control point Qi; Control points Q0, ..., Qn, knot vector U, and degree k determine an interpolating B­ spline curve;

92 B-Splines Interpolation

Left : 9 data points in black; computed control points in blue. Pink dots on the interpolating curve correspond to the knots (chord length method). Here "knot points" are quite close to the data points and the control polygon also follows the data polygon closely. Right : the data polygon and the control polygon are very different. 93 Parameters, Knots & Degree

Uniform Chord length Centripetal Universal

Four curves obtained using four parameter selection methods and the degree of the interpolating B­spline curve is 3. The uniform method generates a cusp, the chord length method forces the curve wiggle through data points wildly, the centripetal method resemblances the chord length method but performs better, and the universal method follows the data polygon closely (better than the uniform method) but produces a small loop. 94 Parameters, Knots & Degree

Relation between parameters and knots : the parameters and knots obtained from the universal method are more evenly distributed than those of the chord length method and the centripetal method. Moreover, the parameters and knots obtained from the centripetal method stretch the shorter (resp, longer) chords longer (resp., shorter) and hence are more evenly distributed. Therefore, the longer curve segments obtained by the chord length method become shorter in the centripetal method and the curve does not wiggle wildly 95 through data points. Parameters, Knots & Degree

2 The uniformly spaced method and universal method usually follow long chords very well. On the other hand, these two methods have problems with short chords. Because the 3 parameters are equally or almost equally spaced, the interpolating curves have to stretch a little longer for shorter chords. As a result, we see 4 peaks and loops. This situation gets worse with higher degree curves because higher degree curves provide more freedom to 5 wiggle.

Uniform Chord Length Centripetal Universal 96 Why Is This Method Global?

B­spline curves satisfy the local modification property ≠ global interpolation => changing the position of a single data point changes the shape of the yellow dots are data points and one of them is moved to its new position, marked in light interpolating curve blue and indicated with a red arrow. These nine data points are fit with a B­spline curve of degree 4 using the centripetal method. The resulting curve (in blue) and the original curve have eight data points identical, and the eight 97 curve segments are all different ! Parameter Selection

There are infinite number of possibilities Input data points: A , ..., A => find n+1 0 n for selecting these parameters. For parameters t , ..., t so that A corresponds 0 n k example, we can evenly divide the to parameter t → A = C(t ) ∀ k ϵ[0, n]. k k k domain, or randomly pick n+1 values from Fig : 7 data points => find 7 parameters to the domain. Thus, the choice of setup the desired correspondence. parameters (parameterization of the curve) affects the shape of the curve 98 Uniform Parameterization

= t 0=0 t 0 a i b−a t = i∈{1,n−1 } t i=ai i∈ {1,n−1} i n n = t n=1 t n b

Simple,but generates some unpleasant results. For example, when data points are not uniformly spaced : bulges, sharp peaks and loops. (left) : loop at data point 3. (right) : the curve wiggles its way through data points 1, 2 and 3

99 Chord length Parameterization interpolating curve close to the data polygon => length of the curve segment between two adjacent data points close to the length of the chord of these two data points => length of the interpolating curve close to the total length of the data polygon ( ∼arc­length parameterization)

n

Total length of the data polygon L=∑∥Ai − Ai−1∥ k i=1 ∑∥Ai − Ai−1∥ i=1 Ratio of the chord length from data point A to data point A , denoted as L Lk= 0 k k L

t 0=0 t 0=a Parameterization : t k =Lk t k =aLk b−a

t n=1 t n=b

100 Centripetal Parameterization

Extension to the chord length method : the distance between two n a adjacent data points is measured by ||A ­ A || (a>0) rather than the a i i­1 L=∑∥Ai − Ai−1∥ conventional ||A ­ A ||. The length of the data polygon is i=1 i i­1 k t =0 ∥ − ∥a 0 Ratio: ∑ Ai Ai−1 Parameterization : t =L i=1 k k Lk= t =1 L n

a=1/2

101 Universal Parameterization

Hyp : we need n+1 parameters; interpolating B­spline degree is p.

=> number of knots = m+1, where m = n + p + 1. u0=u1=⋯=u p=0 Knots uniformly spaced with clamped end conditions => i u = i ∈{1, n− p} first p+1 knots= 0 pi n− p1 last p+1 knots = 1 u =u =⋯=u =1 remaining n ­ p knots evenly subdivide the domain [0,1]: m− p m− p1 m

=> n+1 B­spline basis functions. Parameters = values where corresponding basis functions reach a maximum.

102 Knot Vector Generation

Given : a set of n+1 parameters t0, t1, ..., tn and degree p; generate a knot vector. For a B­ spline curve of degree p, we need m+1 knots, where m=n+p+1.

u0=u1=⋯=u p=0 If the curve is clamped use the universal i u = i ∈{1, n− p} method for instance pi n− p1

um− p=um− p1=⋯=um=1 uniformly spaced knot vector : no knowledge of the parameters, simple to generate. Not recommended ( if used with the chord length method for global interpolation → system of linear equations singular).

u0=u1=⋯=u p=0 1 i  p−1 u pi= ∑ t j i ∈{1, n− p} de Boor knot vector : "average" the parameters p j =i u =u =⋯=u =1 m− p m− p1 m 103 Bicubic Surfaces

Surfaces defined with bicubic functions x(u,v),y(u,v),z(u,v) bicubic polynomials 16 terms to combine the powers of u and v

Matrix form u=[ u3 u2 u 1 ] v= [ v3 v2 v 1] s  u,v  =uAvT or s  u,v =uMGMT vT with M matrix of bases functions and G matrix of control points (tensor product ) 104 From Curves to Surfaces Bicubic spline surfaces behave as spline curves Control points and bases matrices 16 control parameters (points and/or derivatives) Tensor product of rank­4 → 4x4x4x4 array !!!! Symmetry in u and v and orthogonal bases reduce the tensor to 2 copies of a matrix

S u ,v=U t M P M t V with M basis matrix and P matrix of control points

Surfaces Visualization 4 u­bases and 4 v­bases 16 basis surfaces : surface = weighed sum of basis surfaces 105 Surface = combination of patches­ 43 Tensor product

P11 Bilinear Interpolation

v P01

P00

v u u P10

P0, 0 P0, 1 1 −v Pu ,v=[ 1 −u u ] P0, 1 =1 −vP v P P P [ v ] 0, 0 0, 0 0, 1 [ 1, 0 1, 1 ] 1, 1 =1 −   P1, 0 v P1, 0 V P1, 1 106 1, 1 0, 1 1, 1 Pu ,v=P0, 0 u ,v=1 −uP0, 0u P1, 0 Tensor Product

P P 1 1  = − 0,0 0,1 1−v 1 1 P u ,v [ 1 u u ] Pu ,v=∑ ∑ Pi , j Bi u Bj v P P [ v ] [ 1,0 1,1] i= 0 j =0

107 Tensor Product m m m P u=∑ Pi Bi u i= 0 n n Pi =Pi v=∑ Pi , j B j v j =0

m n m n Pu ,v=∑ ∑ Pi , j Bi u B j v i= 0 j =0 108 Exemple: Bézier Surface Tensor Product

Example : B Spline Example : Bezier

m n m n  = m   n   S u ,v=∑ ∑ Bi ,k uB j , l vPi , j S u ,v ∑ ∑ Bi u B j v Pi , j i =0 j=0 i =0 j=0 where k and l are B­Spline orders where k and l are Bezier degrees

110 B-Splines Surfaces

v

v

n+l

v

n+1

v

l­1

v

0

u

u0 uk­1 um+1 um+k

number of patches=m−k2 xn−l2 B-Splines patchwork ex : bicubics De Casteljau

r −1, r −1 r−1, r−1 r , r Pi , j Pi , j 1 1 −v P Pi , j =[ 1 −u u ] 03 Pr −1, r −1 P r−1, r−1 [ v ] [ i1, j i 1, j1 ] r=1, ... ,n i , j=0, ...,n−r

v

P00

P33

33 P00 u

v

11 P20

u 113 P30 Curves on surfaces

Isoparametric curves v

q=(qu,qv)

u(t)=(1­t)p+tq

p=(p ,p ) u v u

114 Normal & Twist Vectors

Normal Vectors

∂ ∂ su ,v∧ su ,v ∂ u ∂ v nu ,v= ∂ su ,v∧ ∂ su ,v ∥∂ u ∂ v ∥

Twist Vectors ∂ 2 su ,v ∂ u∂ v t u ,v= ∂ 2 su ,v 115 ∥∂ u∂ v ∥ Coons Patches

Idea : fill in between curves

C2(u)

D1(v)

C1(u) D2(v)

any degree u ∈ [u ,u ], v ∈ [v ,v ] min max min max 116 Ruled Surfaces

Find surface that interpolates c1(u) and c2(u) ∈ u [umin,umax], say [0,1]. Find x(u,v) / x(u,0) = c1(u) ∧ x(u,1) = c2(u). Simplest solution : linear interpolation

xu ,v=1−vc1uvc2 u xu ,v=1−v xu,0v xu,1

117 Coons Patches

2 ruled surfaces

r cu, v=1−vc1uvc2 u=1−vxu,0v xu,1

r d u ,v=1−ud1 vud 2 v=1−u x0,vu x1,v rc interpolates c1(u) and c2(u) but does not reproduce d1(v) and d2(v) (same for rd) => take off bilinear interpolation x 0,0 x0,1 1−v r  u,v =[ 1−u u ] cd [ x 1,0  x1,1][ v ] Coons patch : x = rc + rd – rcd

118 Coons Patches

Bilinear Coons General Coons

  f u x0, v  = 1−u x 0,v xu ,v= 1 x u ,v [ x1,v] [u ][ x1,v] [ f 2u] 1−v g v  xu,0  xu,0 1 [ xu,1][v ] [ xu,1] g v [ 2 ] 1−u x0,0 x0,1 1−v   x0,0 x0,1 g v − − f 1 u 1 [u ][ x1,0 x1,1][v ]   [ x1,0 x1,1] g v [ f 2 u ] [ 2 ]

119 Coons Patches

Drawback

u [0,2], v [0,1] Boundary curves x(u,0) and x(u,1) differentiable but cross­boundary derivatives discontinuous along x(1,v) 120 Partially Bicubically Blended Coons Patches

0 3 Use Hermite functions : set f1=g1=H3 and f2=g2=H3 Cross derivative along u=0 : 3 H 0 v xu0, v=[ xu 0, 0  xu0, 1 ] 3 [ H 3v] all other terms vanish since 3 3 dH 3 0  dH 3 1  i = i =0 i=0, 1 du du Cross­boundary derivative on a boundary depends only on that boundary

Drawback : flat spots at corners xuv i , j=0 i , j∈{0, 1 } 121 Bicubically Blended Coons Patches Data : xu,0 , xu,1 , x 0, v, x1, v

xv u ,0  , xv u ,0 , xu 0, v , xu 0, v

x ”tangent ribbons” u (1,v)

(0,v) x u v

u 122 Bicubically Blended Coons Patches Generalize ruled surfaces

3 3 3 3 hc u ,v=H 0 ux0, vH 1 u xu0, vH 2 uxu1, vH 3ux1, v 3 3 3 3 hd u ,v=H 0 v xu,0 H 1 v xv u,0 H 2 v xv u,1 H 3v xu,1 

3 x 0, 0  xv 0, 0  xv 0, 1  x0, 1  H 0 v 3 3 3 3 3 xu 0, 0  xuv 0, 0  xuv 0, 1  xu 0, 1  H 1 v hcd u ,v=[ H 0 u H 1 u H 2 u H 3u] 1 0  1 0  1 1  1 1  3 xu , xuv , xuv , xu , H 2 v 3 x1, 0  xv 1, 0  xv 1, 1  x1, 1    [ ][ H 3 v ]

Coons patch : x = hc + hd – hcd

123 Gordon Surfaces

Interpolation of a network of curves ∈ Surface g / isoparametric curves g(ui,v) i {0,m} and ∈ g(u,vj) j {0,n}

­> same idea as Coons : find g1 (resp g2) that interpolates g(ui,v) (resp g(u,vj)). Find g12.

Result = g1 + g2 ­ g12

124 Gordon Surfaces

m m g1u ,v=∑ gui , v Li u i=0 n n g2 u ,v=∑ gu ,v j  L j v j =0 v m n m n g12 u ,v=∑ ∑ gui ,v j  Li uL j  v i=0 j =0 u

g(u,v1) g=g1g2−g12

g(u2,v)

125