Computer Graphics for Engineering Numerical simulation in technical sciences

Curve Representations

Luiz Fernando Martha André Pereira

Graz, Austria June 2014 and Surfaces Representations

Three types of representations for curves and surfaces are common in computer graphics and geometric design: explicit, implicit, and parametric. Here we shall look briefly at each of these alternatives and then settle on one particular form to use throughout this course.

Source: Explicit Representations When you first studied analytic geometry, you used rectangular coordinates and considered equations of the form y = f(x) . The graphs (x, f(x)) of these functions are curves in the plane. For example, y = 3x + 1 represents a straight , and y = x 2 represents a parabola (see Figure). Similarly, you could generate surfaces by considering equations of the form z = f(x,y): the equation z = 2x + 5y- 7 represents a plane in 3-space, and z = x 2 -y2 represents a hyperbolic paraboloid. Expressions of the form y = f(x) or z = f( x,y ) are called explicit representations because they express one variable explicitly in terms of the other variables. Implicit Representations

Not all curves and surfaces can be captured readily by a single explicit expression. For example, the unit centered at the origin is represented implicitly by all solutions to the equation x2 + y 2 - 1 = 0 . If we try to solve explicitly for y in terms of x, we obtain which represents only the upper half circle. We must use two explicit formulas to capture the entire circle.

Often it is easier just to stick with the original implicit equation rather than to solve explicitly for one of the variables. Thus x2 + y 2 - 1 = 0 represents a circle, and x2 + y 2 + z 2 - 1 = 0 represents a . Equations of the form f(x, y) = 0 or f(x, y, z) = 0 are called implicit representations because they represent the or surface implicitly without explicitly solving for one of the variables. Implicit Representations

Implicit representations are more general than explicit representations. The explicit curve y = f(x) is the same as the implicit curve y - f(x) = 0 , but as we have seen it is not always a simple matter to convert an implicit curve into a single explicit formula. Moreover, implicit equations can be used to define closed curves and surfaces or curves and surfaces that self-intersect, shapes that are impossible to represent with explicit functions (Figure).

For closed curves and surfaces, the implicit equation can also be used to distinguish the inside from the outside by looking at the sign of the implicit expression. For example, for points inside the unit circle x2 + y 2 - 1 < 0 , and for points outside the unit circle x2 + y 2 - 1 > 0 . This ability to distinguish easily between the inside and the outside of a closed curve or surface is often important in solid modeling applications. Implicit Representations

The lemniscate of Bernoulli: (x 2+y 2)2 - (x 2-y2)2 = 0 . Notice that unlike explicit functions, the graphs of implicity equations can self-intersect. Implicit Representations

Nevertheless, implicit representations also have their drawbacks. Given an explicit representation y = f(x) , we can easily find lots of points on the curve (x,f(x)) by selecting values for x and computing f(x) .

If our functions f(x) are restricted to elementary functions like polynomials, then for each x there is a unique, easily computable y. Thus it is a simple matter to graph the curve y = f(x) .

On the other hand, it may not be so easy to find points on the curve f(x,y) = 0 . For many values of x there may be no y at all, or there may be several values of y, even if we restrict our functions f(x,y) to polynomials in x and y.

Finding points on implicit surfaces f(x,y,z) = 0 can be even more formidable. Thus it can be difficult to render implicitly defined curves and surfaces. Parametric Representations

There is another standard way to represent curves and surfaces that is more general than the explicit form and yet is still easy to render. We can express curves and surfaces parametrically by representing each coordinate with an explicit equation in a new set of parameters. For planar curves we set x = x(t) and y = y(t) ; for surfaces in 3-space we set x = x(s,t), y = y(s,t), and z = z(s,t). For example, the parametric equations

represent the unit circle centered at the origin because by simple substitution we can readily verify that x2(t) + y 2(t) - 1 = 0 . Similarly, the parametric equations

represent a unit sphere, since x2(s,t) + y 2(s,t) + z 2(s,t) - 1 = 0 . Often we shall restrict the parameter domain. Thus a parametric curve is typically the image of a line segment; a parametric surface, the image of a region--usually rectangular or triangular - of the plane. Parametric Representations The parametric representation has several advantages. Like the explicit representation, the parametric representation is easy to render: simply evaluate the coordinate functions at various values of the parameters. Like implicit equations, parametric equations can also be used to represent closed curves and surfaces as well as curves and surfaces that self-intersect. In addition, the parametric representation has another advantage: it is easy to extend to higher dimensions. To illustrate: if we want to represent a curve in 3-space, all we need do is introduce an additional equation z = z(t) . Thus the parametric equations represent a line in 3-space. Figure illustrates a more complicated parametric curve in 3-space.

The helix: x = cos(t) , y = sin(t) , z = t/5 . Parametric Representations The parametric representation has its own idiosyncrasies. The explicit representation of a curve is unique: the graph of y = g(x) is the same curve as the graph of y- f(x) if and only if g(x) = f(x) . Similarly, if we restrict to polynomial functions, then the implicit representation f(x,y) = 0 is essentially unique. Indeed if f(x,y) and g(x,y) are polynomials, then g(x,y) = 0 represents the same curve as fix,y) - 0 over the complex numbers if and only if g(x,y) is a constant times a power of f(x,y). However, the parametric representation of a curve is not unique. For example, the equations

are two very different parametric representations for the unit circle x2 + y 2 = 1 . Moreover, if we restrict our attention, as we shall in most of this text, to polynomial or rational parametrizations, then it is known that every such parametric curve or surface lies on an implicit polynomial curve or surface. The converse, however, is not true. There exist implicit polynomial curves and surfaces that have no polynomial or rational parametrization. Thus, the implicit polynomial form is more general than the rational parametric form. Parametric Representations

Nevertheless, because of their power, simplicity, and ease of use, we shall choose to represent all the curves and surfaces in this course using parametric representations. Moreover, our curves and surfaces will lie in an unspecified number of dimensions, since the parametric representation works equally well in an arbitrary number of dimensions. Note that in the one-dimensional case the parametric representation is the same as the explicit representation, so we cover explicit representations automatically as a special case.

Sometimes it will be helpful to think about the special case of explicit representations, but more often than not this can confuse the issue because parametric curves exhibit geometric properties such as self-intersection that can never occur in explicit representations. Planar parametric curves (x(t), y(t)) are much more flexible than the planar graphs (t,x(t)) of explicit functions. Parametric Representations

It remains to say what kinds of functions we shall allow in our parametric representations. Most of the remainder of this course is about how to choose the parametric functions in order to generate suitable curves and surfaces. Generally our functions shall be variants of polynomials: either simple polynomials or rational functions (ratios of polynomials) or piecewise polynomials (splines) or piecewise rational functions.

Polynomials have many advantages, especially when used in conjunction with a computer. Polynomials are easy to evaluate. Furthermore, more complicated functions are generally evaluated by computing some polynomial approximation, so nothing is really lost by restricting to polynomials in the first place. In addition, there is a well-developed theory of polynomials in numerical analysis and approximation theory; computer graphics and geometric modeling borrow extensively from this theory. Curves

Perhaps the easiest way to describe a form is to select a few points on this form. Given enough points, the eye has a natural tendency to smoothly interpolate between data.

Here this problem will be studied mathematically . Given a finite set of points in affine space, we will investigate methods for generating polynomial curves and surfaces that interpolate the points. We begin with schemes for curves and then extends such techniques to surfaces. Curves

• Lines

• Beziers

• B-Splines

• NURBS

• Other types of special curves: Polylines, circle arcs and ellipse arcs Curves Requirement 1: Axis Independency

y

x Curves Requirement 2: Multiple Values

y

x Curves Requirement 3: Local Control

y

x Curves Requirement 4: Little Oscillation

High degree polynomial Curves Requirement 5: Versatility Curves Requirement 6: Uniform Sampling

∆sn ∆s3

∆s2

∆s4 ∆s1

∆si ≈ ∆sj

Finally: Curves – Requirement 7: Feasible Mathematical Formulation Solution

Curve represented by a low-degree (generally 3) piecewise polynomial

3 2 t=1 x(t) = axt + bxt + cxt + d x 3 2 y(t) = ayt + byt + cyt + d y 3 2 3 2 z(t) = azt + bzt + czt + d z x(t) = axt + bxt + cxt + d x 3 2 t=0 y(t) = ayt + byt + cyt + d y 3 2 z(t) = azt + bzt + czt + d z continuity at the common points of the parts

Parameterization t∈[0,1 ] local t=0 t=1 t=0 t=1 t=0 t=1 or

u∈[] u0 , un global u0 u1 u2 un Differential Geometry

Generic Parameter: u Length Parameter: s = s(u)

s or u d  Tˆ(s) = P(s) P(u) ds  d  or P(s) R(u) = P(u) du

 ds ds  R = Tˆ = R du du Parameterization Requirements

   P 1 P(u) = 1( − u)P0 + u P1 P(u)

P0 (1-u) u

(1-f(u)) f(u)   

P(u) = 1( − f (u)) P0 + f (u) P1

1 ua ub ua

d  0 ub P(u) = 0 du Ifu21> u⇒ su ( 2 )> su ( 1 ) Geometric and Parametric Continuity

 

R1 )0( = R2 )1(

Discontinuous Continuous: C 0 and G 0 Continuous: C 1 and G 1

Geometric Parametric     R )0( ≠ R )1( 1 2 R1(0)= R 2 (1)

   

T1 )0( = T2 )1( T1 )0( ≠ T2 )1(

C0 and G 1 C1 and G 0 Bézier Curves

P. of Casteljau, 1959 (Citroën) P. of Bézier, 1962 (Renault) - UNISURF Forest 1970: Bernstein Polynomials

z  n  P(t) = ∑ Bi,n (t) Vi V 2 Vn-1 i=0 t=1 V1

Vn where: t=0 P(t) V3 V n 0   n−i i Bi,n (t) =   1( − t) t  i  y pol. Bernstein n n! x   =  i  i (! n − i)! coef. binomial Cubic Bézier

 3  3   3−0 0 3 P t)( = B t)( V B 3,0 (t) =   1( − t) t = 1( − t) ∑ i 3, i 0 i=0   3   3−1 1 2 z B 3,1 (t) =   1( − t) t = 1(3 − t) t V1 1 3 V3   3−2 2 2 B 3,2 (t) =   1( − t) t = 1(3 − )tt P(t) 2 V 0 V 3 2   3−3 3 3 B 3,3 (t) =   1( − t) t = t y 3

3 x ∑ Bi 3, (t) = [1( − t) + t] =1 i

     3 2 2 3 P t)( = 1( −t) V0 + 1(3 −t) t V1 + 1(3 − )tt V2 +t V3 Bernstein Cubic Polynomials

B0,3 B1,3 1 (1-t) 3 3(1-t) 2t

3 0 1 t 0 1 t

B2,3 B3,3 1 2 3(1 -t) t t3 -3 0 1 t 0 1 t

B0,3 + B1,3 + B2,3 + B3,3 1

0 1 t Properties of a Cubic Bézier

     3 2 2 3 P t)( = 1( −t) V0 + 1(3 −t) t V1 + 1(3 − )tt V2 +t V3 d      P t)( = − 1(3 −t)2 V + [− 1(6 − )tt + 1(3 −t)2 ]V + [−3t 2 + 1(6 − )tt ]V + t 3 V dt 0 1 2 3 R(0)   P )0( = V z 0

V1   P )1( = V3 V3 P(t) d    V0 V P )0( = −3V + 3V 2 dt 0 1 y d    P )1( = −3V + 3V x dt 2 3 R(1) Control of a Cubic Bézier Convex Hull

n  n P() t= α∑α i V i with ∑ i = 1 i=0 i = 0 Demonstration

Induction n=1    P(t) = α0 V0 +α1 V1 α0 +α1 =1  ok

n=2     P(t) = α0 V0 +α1 V1 +α 2 V2 α0 +α1 +α2 =1       α0 α1 P(t) = (α0 +α1) V0 + V1  +α2 V2 (α0 +α1) +α2 =1 (α0 +α1) (α0 +α1) 

 P t)( is interior  ok

n=3 ... Foley Equation 

 V2 V1  P t)(  V3  V0      3 2 2 3 P t)( = 1( −t) V0 + 1(3 −t) t V1 + 1(3 − )tt V2 +t V3

−1 3 − 3 1V0x V0 y V0z      3 − 6 3 0 V V V P(t) = t 3 t 2 t 1   1x 1y 1z    − 3 − 3 0 0 V x V y V z   2 2 2   1 0 0 0V3x V3y V3z  Reduction from n=3 to n=2

     3 2 2 3 P t)( = 1( −t) V0 + 1(3 −t) t V1 + 1(3 − )tt V2 +t V3     V 1 t)( = 1( −t) V + t V 1 0 0 1  V2 t)(    1 1 V1 t)( V1 t)( = 1( −t) V1 + t V2     V 1 (t) = (1−t) V + t V 1 2 2 3 V0 (t)      P t)( = 1( −t)2 [1( −t)V + Vt ]+ 1(2 − )tt [1( −t)V + Vt ]  0  1 1 2 2 +t []1( −t)V2 +t V3

    2 1 1 2 1 P t)( = 1( −t) V0 + 1(2 − )tt V1 +t V2 Bezier n=2 Reduction from n=2 to n=1

    2 1 1 2 1 P t)( = 1( −t) V0 + 1(2 − )tt V1 +t V2     V 1 2 1 1 1  1 V0 t)( = 1( −t)V0 +t V1  V2    V 2 2 1 1  1 V1 t)( = 1( −t)V1 +t V2   2 1 V0 P(t) V0

     1 1 1 1 P t)( = 1( −t) [1( −t)V0 + Vt 1 ]+t[1( −t)V1 + Vt 2 ]

   2 1 P t)( = 1( −t)V0 +t V1 Bezier n=1 Calculation of a Point   1  V1 V2  1 V1  V2 2  V1    2 P t)( 1 V V V0 0  3 (1-t)  V  0 V 1 t V0 0  V  V 2  1 1 0 P(t) V1  V  V 2 2 1 1 V2 V3

Show that: Bi,n (t) = 1( − t) Bi,n−1(t) + t Bi− ,1 n−1(t) Subdivision of Cubic Bézier

  V H  1 V   2  1  1  V L V R V L = V + V 2   1 1 0 1  L R  2 2 L R V V3 = V0 1 V2 . . .     L R V0 = V0 V3 = V3

    V L  8 0 0 0V   R  1 3 3 1  0 0 V0 V0  L           4 4 0 0 R   V1  1  V1  V 1 0 2 4 2 V  =   1  =   1   L      R    V2 8 2 4 2 0 V2 V 8 0 0 4 4 V         2    2  V L  1 3 3 1V  R  3   3  V3  0 0 0 8V3  Construction of a Bezier

u=1/2

P(1/2) Curve fitting

     3 2 2 3 P t)( = 1( −t) V0 + 1(3 −t) t V1 + 1(3 − )tt V2 +t V3      d 2 2 2 2 P t)( = − 1(3 −t) V0 +[ 1(3 −t) − 1(6 − )tt ]V1 +[ 1(6 − )tt −3t ]V2 +3t V3 dt     2 2 2 2 = − 1(3 −t) V0 + 3(3 t −4t + )1 V1 + (3 −3t + 2t)V2 +3t V3

d      P(0) = −32 V +3V = 3(V −V ) dt 0 1 1 0 d      P )1( = −32 V +3V = 3(V −V ) dt 2 3 3 2 d 2      P t)( = 1(6 −t)V + 6(3 t − )4 V + (3 −6t + )2 V +3t 2 V dt 2 0 1 2 3 d 2        P )0( = 6V −12 V +6V = 6 ()V −2V +V dt 2 0 1 2 0 1 2 d 2        P )1( = 6V −12 V +6V = 6()V −2V +V dt 2 1 2 3 1 2 3 New notation

Vn−2 Vn−3 Vn−1 Vn−4 Vn

V4 V2 V V 3 V 1 V 7 V5 6

rnc −2 V0 lnc −1 lnc −2 pnc −2 r 1 pnc −1 l1

p1 r r 2 0 p2 l2

p0 Derivatives in the new notation

 3 2 2 3 Pi t)( = 1( −t) pi + 1(3 −t) t ri + 1(3 − )tt li+1 +t pi+1

z d  r Pi )0( = 3()ri − pi i dt pi+1 d  P(1) = 3(p − l )  dt i i+1 i+1 P t l pi i ( ) i+1 d 2  P )0( = 6 ()p −2 r + l y dt 2 i i i i+1

d 2  x P )1( = 6()r −2 l + p dt 2 i i+1 i+1 Construction of a curve that passes at 2 points

n=2 P )1('' = 0 p1

6(p0 −2 r0 + l1)= 0

l1 6(r0 −2 l1 +p1)= 0

r 1 0 r = ()p −p 0 3 1 0 p0  2 l = ()p −p P )0('' = 0 1 3 1 0 Construction of a curve that passes at 3 points

  P )1('' = P )0(''  p0 −2 r0 + l1 = 0 0 1 P )1('' = 0 r 1 1 l2 1( − ρ)l1 + ρ r1 = p1  p2 l1 p1 1 r0 − 2 l1 + p1 = p1 − 2 r1 + l2   ρ = 0 0  +  r1 −2 l2 +p2 = 0 r0 0 1

p0  2 −1 0 0 r  p   0   0  P0 )0('' = 0   0 1( − ρ) ρ 0  l1   p1    =   1 − 2 2 −1 r 0  1         0 0 −1 2 l2  p2  Constructive Method: given n points add one more

rn ln+1 ln pn r 1 pn+1 l1

p1 r  r n−1 ρ = 0 0 l pn−1   n−1 0 + 1

1( − ρ)ln + ρ rn = pn p0 rn−1 − 2 ln + pn = pn − 2 rn + ln+1

rn −2 ln+1 +pn+1 = 0

 1( − ρ) ρ 0  ln   pn        − 2 2 −1 rn  = − rn−1        0 −1 2 ln+1   pn+1  Interpolation: given p 0…pn , find l’s and r’s

rn ln+1 ln pn r 1 pn+1 l1

p1 r r n−1 0 pn−1 ln−1

p0 Bezier interpolation

Given: np points rnp −2 lnp −1  lnp −2 p0,p1, ,pnp −1 pnp −2 dnp −2 r d 1 2 pnp −1 l1 Find: 2(np-1) points

p1 d1  r2 l1,l2, ,lnp −1 r0 p d l 2 0 2  r0,r1, ,rnp −2 Criteria: p0

p '' 0 = 0 ⇒ 6(p −2r +l )=0 ⇒ 0 0 1 2r0 −l1 =p0

p'' np −1 =0 ⇒6(rnp −2 −2lnp −1 +pnp −1)=0 ⇒ −rnp −2 +2lnp −1 =pnp −1 d p ' =d p ' ⇒ ⇒ i i left i−1 i right 3di(pi −li )=3di−1(ri −pi ) ld ii +di−1ri =(di−1 +di)pi p '' =p '' ⇒ 6(r −2l +p )=6(p −2r +l ) ⇒ −r +2l −2r +l =0 i left i right i−1 i i i i−1 i i−1 i i−1 i Bezier interpolation

rnp −2 Criteria:

lnp −1 l 2r0 −l1 =p0 np −2 p np −2dnp −2 r 1 d2 pnp −1 ld ii +di−1ri =(di−1 +di)pi l1

p1 d1 r −ri−1 +2li −2ri−1 +li =0 r 2 0 l p2 d0 2 −rnp −2 +2lnp −1 =pnp −1 resulting linear system: p0 2 −1 0 0 0 0 0 0 r0   p0       d d l (d d)p 0 1 0 0 0 0 0 0 1   0 + 1 1      1 −2 2 −1 0 0 0 0 r 0   1      0 0 0 d2 d1 0 0 0 l2  (d1 +d2)p2  =  0 0 1 −2 2 −1 0 0 r 0   2        0 0 0 0 0 dn−2 dn−1 0 lnc −2 (dn−3 +dn−2)pn−2      0 0 0 0 1 −2 2 −1rnc −2  0       0 0 0 0 0 0 −1 2lnc −1   pn−1  solve for l and r B-Splines

 V  4   n  V3 • V + + n  • • P(u) = N (u) V + ∑ i, p i V1 i=0 •+ +  V2  • p = polynomial degree N (u) P(u)  i,p + p-1 V0 control the continuity ( C ) •

(u −ui ) (ui+ p+1 −u) Ni, p (u) = Ni,p−1(u) + Ni+1,p−1(u) • vertexes (ui+ p −ui ) (ui+ p+1 −ui+1) + nodes 0 obs .:= 1 by definition. 0 U={u , u , ..., u } 0 1 m ui = nodes (knots) [ui,u i+1 ] = segments (spans)

1 ifu∈ [ ui u i +1 ) Ni,0 ( u ) =  m=n+p+1 0 otherwise Ni,0 (u) ...... u0 u1 u2 ui ui+1 um u

u0 ≤ u1 ≤ u2 ≤ … ≤ um Properties of Ni,p (u)

• Não negativa: Ni,p (u)≥0 para qualquer u, i, e p.

• Partição da unidade: ∑ Ni,p (u)=1 para todo u∈[ u0,um].

• Suporte local: Ni,p (u)=0 se u∉[ ui, ui+p+ 1]. Mais ainda, in qualquer intervalo dos nós no máximo p+ 1 das Ni,p (u) são não zero.

• Diferenciabilidade: todas as derivadas de Ni,p (u) existem no interior de um intervalo de nós (onde é polinômial) . Nos nós Ni,p (u) é p-k diferenciável, onde k é a multiplicidade do nó.

• Extremo: exceto para o caso p=0, Ni,p (u) tem apenas um ponto de máximo. Uniform Spline

(u −ui ) (ui+ p+1 −u) Ni, p (u) = Ni, p−1(u) + Ni+ ,1 p−1(u) (ui+ p −ui ) (ui+ p+1 −ui+1)

uj+1 - uj =d

(u −u ) (u + (p + )1 d −u) N (u) = i N (u) + i N (u) i, p pd i, p−1 pd i+ ,1 p−1 Uniform Splines p=0 and p=1 p=0 Ni,0 (u)

1 ifu∈ [ ui u i +1 ) Ni,0 ( u ) =  0 ifu∉ [ u u ) i i +1 0... ui-d ui ui+d... n p=1 (u −u ) (u + 2d −u) N (u) = i N (u) + i N (u) i 1, d i, p−1 d i+ ,1 p−1

0 ifu∈ [0 u i )  ()u− u  i ifu∈ [ u u )  d i i +1 N( u ) =  i,1 (u+ 2 d − u )  i ifu∈ [ u u )  d i+1 i + 2  0 ifu∈ [ ui+2 u m ]

Ni,2 (u)

ui-d ui ui+d ui+2d Uniform Splines p=2

Ni-1,1 (u) Ni,1 (u) Ni+1,1 (u)

ui-d ui ui+d ui+2d ui+3d (u −u ) (u +3d −u) p=2 N (u) = i N (u) + i N (u) i,2 2d i,1 2d i+1,1  0 ifu∈ [0, u i )  2 (u− u i )  2 ifu∈ [, ui u i +1 )  2d (uuu− )( +−++− 2 du ) ( u 3 duuud )( −+ ( )) N u ii i i 1,2 ( ) =  ifu∈ [ ui+1 , u i + 2 )  2d 2  2 (ui + 3 d − u ) − ifu∈ [ ui+2 , u i + 3 )  2d 2  0 ifu∈ [ u ,] u  i+3 m Polynomials of Uniform B-Spline

(u −u ) (u + (p + )1 d −u) N (u) = i N (u) + i N (u) i, p pd i, p−1 pd i+ ,1 p−1

u ui ui+d ui+2 d ui+3 d ui+4 d

Ni,0 (u) 0 1 0 0 0 0

Ni+1,0 (u) 0 0 1 0 0 0

Ni,1 (u) 0 (u-u i)(ui+2 d-u) 0 0 0

Ni+1,1 (u) 0 0 (u-( ui+d)) (ui+3 d-u) 0 0

2 2 2 (u-u i)( ui+2 d-u)/2 d + 2 2 Ni,2 (u) 0 (u-u i) /2 d 2 (ui+3 d-u) /2 d 0 0 (ui+3 d-u)( u-( ui+d))/2 d

2 2 2 (u- (ui+d))( ui+3 d-u)/2 d + 2 2 Ni+1,2 (u) 0 0 (u- (ui+d)) /2 d 2 (ui+4 d-u) /2 d 0 (ui+4 d-u)( u-( ui+2 d))/2 d [( u-u )2(u +2 d-u) + i i [( u-u ) ( u +3 d-u)2 + (u-u )( u +3 d-u)( u-( u +d)) i i N (u) 0 (u-u )3/6 d3 i i i (u +4 d-u)( u- (u +d))( u +3 d-u) (u +4 d-u)3/6 d3 0 i,3 i +( u +4 d-u)( u- (u +d)) 2 ] i i i i i i + ( u +4 d-u)2(u-( u +2 d))]/6 d2 /6 d3 i i

t t=( u-ui)/ d t = ( u- (ui+d))/ d t = ( u- (ui+2 d))/ d t=( u- (ui+3 d))/ d

6 3 2 3 2 3 Ni,3 (t) 0 t /6 (-3 t +3 t +3 t+1)/6 (3 t -63 t +4)/6 (1- t) /6 0 Segments of the Cubic B-spline

p(t) (3t 3-6t 2+4)/6 (-3t 3+3t 2+3t+1)/6 0,7

0,6

0,5

0,4

0,3

0,2 (1-t) 3/6 t3/6 0,1 0,0 t 0,0 0,2 0,4 0,6 0,8 1,0 Basis Functions

N-1,3 (u)N0,3 (u) N1,3 (u) N2,3 (u) ... Nn-1,3 (u) Nn,3 (u) Nn+1,3 (u) 0,7 0,6 0,5 0,4 0,3 0,2 0,1 0

u0 u1 u2 i=0 u3 ... um-4 um-3 um-2 um-1 um u i=1 t i=n t t

For i = 0, ..., n For t = 0, ..., 1  1( −t)3  3t3 −6t 2 + 4  −3t3 +3t 2 +3t +1  t3  P t)( = V + V + V + V i 6 i−1 6 i 6 i+1 6 i+2 Periodic B-Spline - Foley -

For each pair Vi, Vi+1 , i=0,...,n For each t=0,...,1

−1 3 − 3 1Vi− ,1 x Vi− ,1 y Vi− ,1 z      3 − 6 3 0 V V V P(t) = t 3 t 2 t 1   i,x i, y i,z  − 3 0 3 0V V V    i+ ,1 x i+ ,2 y i+ ,2 z   1 4 1 0Vi+3,x Vi+3, y Vi+3,z 

V = V Periodic: n+1 0 Vn+2 =V 1 i=0, ... , n

V-1 = Vn Vn+1 = V0 V3 Vn+2 = V1

V-1= V n

V4 V2 Non Periodic B-Spline - Foley -

• vertexes  V  + nodes  n−1 V i=3 • Vn  3 + +• • i=n-1 Vn−1  + • V1 i=1 • + i=2 + V i=0 2 i=0  • +• P(0) = ( V + 4 V + V )/6 V0 -1 0 1  P’’ (0) = V-1 -2V0+ V1 = 0 V1 • ⇒ V-1 = 2 V0 - V1 i=0; P(0) = V0

i=n-1

P(1) = ( Vn-1+ 4 Vn+ Vn+1 )/6

P’’ (1) = Vn-1-2Vn+ Vn+1

⇒ Vn+1 = 2 Vn - Vn-1

i=n-1; P(1) = Vn Periodic Basis

V2 V3

V9= V1 i=4 i=3 i=5 V i=2 4

i=1 i=6 V8= V0 i=7 i=0 V-3=V5

V-1= V7 V = V u u -2 6 (u− u i ) (i+ p + 1 − ) Nuip,()= Nu ip ,− 1 () + Nu ip + 1, − 1 () ()uuipi+− ( uu ip +++1 − i 1 ) Periodic Uniform Cubic B-Spline U = {0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0} 0,7 0,6 0,5 N(u,0,3) N(u,1,3) 0,4 N(u,2,3) N(u,3,3)

N(u,i,p) 0,3 N(u,4,3) N(u,6,3) 0,2 N(u,7,3) 0,1 0,0 0,0 0,2 0,4 0,6 0,8 1,0 u Non Periodic Basis

Nonperiodic Uniform Cubic B-Spline U= {0, 0, 0, 0, 1/4, 2/4, 3/4, 1, 1, 1, 1} 1,0

0,8

N(u,0,3) N(u,1,3) 0,6 N(u,2,3) N(u,3,3)

N(u,i,p)N(u,i,p) N(u,4,3) 0,4 N(u,6,3) N(u,7,3)

0,2

0,0 0,0 0,2 0,4 0,6 0,8 1,0

u u u (u− u i ) (i+ p + 1 − ) Nuip,()= Nu ip ,− 1 () + Nu ip + 1, − 1 () ()uuipi+− ( uu ip +++1 − i 1 ) Bézier and B-Spline

Bézier by means of a Cubic B-Spline U={0,0,0,0,1,1,1,1}

1,0

0,8

0,6 N(u,0,3) N(u,1,3) N(u,2,3) N(u,i,p) 0,4 N(u,3,3)

0,2

0,0 0,0 0,2 0,4 0,6 0,8 1,0 u

u u (u− u i ) (i+ p + 1 − ) Nuip,()= Nu ip ,− 1 () + Nu ip + 1, − 1 () ()uuipi+− ( uu ip +++1 − i 1 ) Periodic B-Spline - Interpolation - V = V n+1 0 Vn+1 =V 1

Consider the nodes P0(0) P (0) 1 as given points V3 P (0) For i=0,..., n n P 2(0) P V V V V = V i(0) = ( i-1+ 4 i+ i+ 1)/6; -1 n P3(0)

P4(0) V4 V2 • vertexes   4 1 0 0 0 1V  P  + nodes   0   0  1 4 1 0 0 0 V P   1   1  1 0 1 4 1 0 0V  P    2  =  2  6 0 0 1 4 1 0 V P   3   3  0 0 0 1 4 1V  P    4   4     1 0 0 0 1 4Vn  Pn  Non Periodic B-Spline - Foley - • vertexes  V  + nodes  n−1 V i=3 • Vn  3 + i=n-1+• V Consider the nodes  • • n−1 + as given points V1 i=1 • + i=2 + V i=0 2 P = V ; P = V ;  • 0 0 n n +• For i=1,..., n -1 V0 P (0) = ( V + 4 V + V )/6;  i i-1 i i+ 1 V1 •   1 0 0 0 0 0V  P    0   0  1 4 1 0 0 0 V P   1   1  1 0 1 4 1 0 0V  P    2  =  2  6 0 0 1 4 1 0 V P   3   3  0 0 0 1 4 1V  P    4   4     0 0 0 0 0 1Vn  Pn  Rational Functions

From trigonometry: u = tan( α / 2) 2u sin( α) = 1+ u 2 1− u 2 cos( α) = 1+ u 2

1.0

0.8   2  1− u 2u  P(u) =  2 , 2  0.6 1+ u 1+ u  u ∈ ]1,0[ 0.4

0.2

0 0.2 0.4 0.6 0.8 1.0 Conics y

a conic written in the axis system whose origin is a conic point

x ax 2 + bxy + cy 2 + dx + ey = 0 x = ty at 2 y 2 + bty 2 + cy 2 + dty + ey = 0 dt + e dt 2 + et y = − x = − at 2 + bt + c at 2 + bt + c

Any conic can be represented parametrically as a fraction of quadratic polynomials NURBS Non Uniform Rational B-Splines

w(u)x(u) wi xi      w(u)y(u) n w y   = N (u)  i i    ∑ i, p   w(u)z(u) i=0 wi zi w      w(u)   wi 

y x(u) x  n i   wi Ni, p (u)   y(u) = ∑ n yi    i=0 w N (u)   z(u) ∑ k k, p zi  x k=0 w=1 yh

x( u )  x n i xh   wi N i, p ( u ) yu( )=∑ Ruyip, ( )  i where Ru ip , ( ) = n i=0  w N( u ) z( u )  z i ∑ k k, p k=0 Conics as NURBS     B() uwV+ B () uwV + B () uwV P( u ) = 0,2 00 1,2 11 2,2 22 B0,2() uw 0+ B 1,2 () uw 1 + B 2,2 () uw 2 where :

BuNui,2( )= i ,2 ( ) with U = {0,0,0,1,1,1}  V Faux et al. 1 w1=s/(1-s) w0w2 /w 1 – determines the conic 3 Hyperbole (w >1)  1 S 1 ParábolaParabola (w 1=1) s 0.2 Ellipse (w 1<1) w =1 w0=1 w1=0 2      V0 M V2 P(1 )= S and  2   -0.2 S=(1 − sM ) + sV 1 Circle defined by NURBS

8 x( u )  xi  wi N i ,2 ( u ) =∑Rui,2( )  where Ru i ,2 ( ) = 8 y( u )  i=0 yi  ∑wk N k ,2 ( u ) k=0 2 2 2 2 {}w = ,1{ ,1, ,1, ,1, }1, U={0, 0, 0, 1/4, 1/4, 1/2, 1/2, 3/4, 3/4, 1, 1, 1} 2 2 2 2

1(x 2 , y 2) (x 3 , y 3) (x 1 , y 1) 0.8

0.6 0.4

0.2 n=8 (x , y ) (x 4 , y 4) 0 0 p=2 -1 -0.8 -0.6-0.4 -0.20 0.2 0.4 0.6 0.8 1 (x 8 , y 8) m=12 -0.2 -0.4

-0.6

-0.8

-1 (x 5 , y 5) (x , y ) (x 6 , y 6) 7 7