2005-10-24 Chapter 4 Representations of Curves and Surfaces.

Post on 03-Jan-2016

218 views 2 download

Tags:

Transcript of 2005-10-24 Chapter 4 Representations of Curves and Surfaces.

2005-10-24

Chapter 4

Representations

of Curves and Surfaces

2005-10-24

4.1 Parametric Representation and Continuity Conditions of Curves and Surfaces

4.1.1 Parametric Representation of Curves and Surfaces

a spline is a flexible strip used to produce a smooth curve through a designated set of points.

2005-10-24

spline curve :

piecewise cubic polynomial function whose first and second derivatives are continuous across the various curve sections

spline surface :

can be described with two sets of orthogonal spline curves

2005-10-24

Applications of splines

CG to design curve and surface shapes to digitize drawings for computer storage to specify animation paths for the objects

or the camera in a sceneCAD to design automobile bodies, aircraft and

spacecraft surfaces, and ship hulls

2005-10-24

a spline description in 2D space x = x(u), y = y(u) u [0, 1]∈A point function on the spline in 2D space c

an be expressed as P(u) = [x(u), y(u)]

a spline description in 3D space x = x(u), y = y(u), z = z(u) u [0, 1]∈A point function on the spline in 3D space c

an be expressed as P(u)= [x(u) , y(u), z(u)]

2005-10-24

As for a surface, the parametric equation of the 2D surface is represented by the form x = x(u, w) , y = y(u, w) u, w [0, 1]∈A point function on the surface can be expressed as P(u, w) = [x(u, w) , y(u, w)]

The parametric equation of the 3D surface is x = x(u, w) , y = y(u, w) , z = z(u, w) u, w [0, 1]∈A point function on the 3D surface is P(u, w) = [x(u, w) , y(u, w), z(u, w)]

2005-10-24

4.1.2 Interpolation and Approximation Splines

Interpolation curves are commonly used to digitize drawings or to specify animation paths.

Approximation curves are primarily used as design tools to structure object surfaces

2005-10-24

Figure 4-1A set of six control points interpolated with piecewise continuous polynomial sections.

Figure 4-2A set of six control points approximated with piecewise continuous polynomial sections.

2005-10-24

A spline curve and control points

Relations ? The convex polygon boundary that encloses

a set of control points is called the convex hull.

2005-10-24

4.1.3 Continuity Conditions

To ensure a smooth transition from one section of a piecewise parametric curve to the next, we can impose various continuity conditions at the connection points.

Parametric continuity conditions: If each section of a spline is described with a set

of parametric coordinate functions of the form x = x(u), y = y(u), z = z(u), u1 u u2

2005-10-24

Zero-order parametric continuity, described as C0 continuity, means simply that the curves meet. [That is, the values of x, y, and z evaluated at u, for the first curve section are equal, respectively, to the values of x, y, and z evaluated at u, for the next curve section. ]

First-order parametric continuity: C1 Second-order parametric continuity: C2

Higher-order parametric continuity: Cn

2005-10-24

Figure 4-6Piecewise construction of a curve by joining two curve segments using different orders of continuity:

(a) zero-order continuity only, (b) first-order continuity, and (c) second-order continuity.

2005-10-24

Geometric Continuity Conditions Zero-order geometric continuity, described as G0 continuity, is the same as z

ero-order parametric continuity. That is, the two curves sections must have the same coordinate position at the boundary point.

First-order geometric continuity, or G1 continuity, means that the parametric first derivatives are proportional at the intersection of two successive sections. If we denote* the parametric position on the curve as P(u) , the direction of the tangent vector P'(u), but not necessarily its magnitude, will be the same for two successive curve sections at their joining point under G1 continuity.

Second-order geometric continuity, or G2 continuity, means that both the first and second parametric derivatives of the two curve sections are proportional at their boundary. Under G2 continuity, curvatures of two curve sections will match at the joining position.

2005-10-24

4.2 Hermite Curves 4.2.1 Spline Specifications There are three equivalent methods for specifying a par

ticular spline representation: (1)We can state the set of boundary conditions that are

imposed on the spline; (2) we can state the matrix that characterizes the spline; (3) we can state the set of blending functions (or basis fu

nctions) that determine how specified geometric constraints on the curve are combined to calculate positions along the curve path.

2005-10-24

Suppose we have the following parametric cubic polynomial representation for the x coordinate along the path of a spline section:

x(u) = axu3 + bxu2 + cxu + dx, 0 u 1 (4-10)

From the boundary conditions, we can obtain the matrix that characterizes this spline curve by first rewriting Eq. 4-10 as the matrix product

2005-10-24

x(u)=[ u3 u2 u 1 ] =U ∙ C (4-11)

U is the row matrix of powers of parameter u,and C is the coefficient* column matrix.Using Eq4-11 we can obtain Eq4-12. C=Mspline ∙ Mgeom (4-12)

CU

d

c

b

a

uuuux

x

x

x

x

1)( 23 CU

d

c

b

a

uuuux

x

x

x

x

1)( 23 CU

d

c

b

a

uuuux

x

x

x

x

1)( 23 CU

d

c

b

a

uuuux

x

x

x

x

1)( 23

2005-10-24

Thus,we can substitute the matrix represen

tation for C into Eq4-11 to obtain x(u)=U∙ Mspline ∙ Mgeom (4-13)

Finally, we can expand Eq. 4-13 to obtain a polynomial representation for coordinate x in terms of the geometric constraint parameters

x(u)= (4-14)

2005-10-24

4.2.2 Cubic Spline Interpolation Methods

Characteristics of cubic polynomials: Compared to higher-order polynomials, c

ubic splines require less calculations and memory and they are more stable.

Compared to lower-order polynomials, cubic splines are more flexible for modeling arbitrary curve shapes.

2005-10-24

Given (n+1) control points:p0 , p1 , …… , pn

pk=(xk,yk,zk) k=0,1,2,……,n

Figure 4-8A piecewise continuous cubic-spline interpolation of n + 1 control points.

2005-10-24

Between each pair of control points,we have

x(u)=ax∙u3+bx ∙ u2+cx ∙ u+dx

y(u)=ay ∙ u3+by ∙ u2+cy ∙ u+dy ( 0<u<1)(4-15)

z(u)=az ∙ u3+bz ∙ u2+cz ∙ u+dz

Or p(u)= a ∙ u3+b ∙ u2+c ∙ u+d

Problem??

how to obtain the values of four coefficients a,b,c,and d?

2005-10-24

4.2.3 Hermite Interpolation

A Hemite spline (named after the French mathematician Charles Hermite) is an interpolating piecewise cubic polynomial with a specified tangent at each control point.

2005-10-24

Figure 4-9Parametric point function P(u) for a Hermite curve section between control point pk and pk+

1.

2005-10-24

Given control point(pk,pk+1),and parametric derivatives Dpk

,Dpk+1.

we can have

P(0) = pk

P(1) = pk+1

P′(0) = Dpk (4-16)

P′(1) = Dpk+1

2005-10-24

We can write the vector equivalent of Eqs. 4-15 for this Hermite-curve section as

P(u) = au3 + bu2 +cu + d, 0 u 1 (4-17)

where the x component of P is x(u) = axu3 + bxu2 + cxu + dx, and similarly for the y and z components. The matrix equivalent of Eq. 4-17 is

(4-18)

2005-10-24

And the derivative of the point function can be expressed as

(4-19)

2005-10-24

Substituting endpoint values 0 and 1 for parameter u into the previous two equations, we can express the Hermite boundary conditions 4-16 in the matrix form:

(4-20)

2005-10-24

Solving this equation for the polynomial coefficients, we have

(4-21)

2005-10-24

Thus ,we can write in terms of the boundary conditions as

(4-22)

Finally, we can obtain the polynomial form: P(u) = pk(2u3 – 3u2 + 1) + pk+1(-2u3 + 3u2) + Dpk

(u3 –

2u2+ u) + Dpk+1(u3 – u2)

=pkH0(u) + pk+1H1(u) + DpkH2(u)

+ Dpk+1H3(u) (4-23)

2005-10-24

The polynomials Hk(u) for k = 0, 1, 2, 3 are refe

rred to as blending functions .

Figure 4-10 The Hermite blending functions.

2005-10-24

An example

Given the coordinates of three points P0(4,4), p1(24,4),

p2(36,3) respectively, and their slopes D0(8.832,5.547),

D1(8.832,-5.547),D2(8.832,5.547),generate a cubic

Hermit spline , compute the coordinates of points the

spline when u=0 , 0.25 , 05 , 0.75 and 1 , and plot the

curve.

2005-10-24

Sloution:

A Hermite spline can be described as:

P(u) =pkH0(u) + pk+1H1(u) + DpkH2(u) + Dpk+1

H3(u)

Where H0(u)=2u3-3u2+1 H1(u)=-2u3+3u2

H2(u)=u3-2u2+u H3(u)=u3-u2

For the line p0p1:

p0=[4 4] D0=[8.832 5.547]

p1=[24 4] D1=[8.832 -5.547]At u=0 and u=1,we have

p(0)=p0=[4 4] p(1)=p1=[24 4]

2005-10-24

At u=0.5 , we have

H0(0.5)=2*0.53-3*0.52+1=0.5

H1(0.5)=-2*0.53+3*0.52=0.5

H2(0.5)=0.53-2*0.52+0.5=0.125

H3(0.5)=0.53-0.52=-0.125

Therefore , we obtain

p(0.5)=0.5[4 4] + 0.5[24 4] + 0.125[8.832 5.547]

- 0.125[8.832 -5.547]

=[14 5.386]

2005-10-24

Similarly:

At u=0.25 , p(0.25)=[7.953 5.04]

At u=0.75 , p(0.75)=[20.04 5.04]

2005-10-24

Problem:

How to input the value of slopes?

So , we have a modified method.

2005-10-24

4.2.4 Cardinal Splines

As with Hermite splines, cardinal splines are interpolating piecewise cubics with specified endpoint tangents at the boundary of each curve section.

The difference is that we do not have to give the values for the endpoint tangents. For a cardinal spline, the value for the slope at a control point is calculated from the coordinates of the two adjacent control points.

2005-10-24

Figure 4-11Parametric point function P(u) for a cardinal-spline section between control points pk and pk+1.

Figure 4-12Tangent vectors at the endpoints of a cardinal-spline section are proportional to the chords formed with neighboring control points (dashed lines).

2005-10-24

the four control points from pk-1, to pk+1, are used to set the boundary conditions for the cardinal spline section as

P(0) = pk

P(1) = pk+1

P′(0) =1/2(1 – t)(pk+1 – pk-1) (4-24)

P′(1) = 1/2(1 – t)(pk+2 – pk)

Figure 4-13Effect of the tension parameter on the shape of a cardinal spline section.

2005-10-24

Let s=1/2(1-t)

where the cardinal matrix is

2005-10-24

Figure 4-14The cardinal blending functions for t = 0 and s = 0.5

2005-10-24

Expanding matrix equation 4-25 into polynomial form, we have

P(u) = pk-1(– su3 + 2su2 – su) + pk[(2 – s)u3 + (s –3)u2

+ 1]+ pk+1[(s – 2)u3 + (3 – 2s)u2 + su)] +

pk+2(su3 – su2)

= pk-1CAR0(u) + pkCAR1(u) + pk+1CAR2(u)

+pk+2CAR3(u)

Pass through all control points.

2005-10-24

4.3 Bezier Curves and Surfaces

Approximation methodDesign Renault automobile bodies

Advantage:

highly useful and convenient for curve

and surface design

easy to implement

2005-10-24

4.3.1 Bezier Curves

Suppose we are given n + 1 control-point positions:

pk = (xk, yk, zk), k = 0 ,1,2,……,n.

Bezier polynomial function :

0≤u ≤1

n

knkk uBEZpuP

0, ),()(

2005-10-24

Bernstein polynomials:

the C(n, k) are the binomial coefficients:

3 points : a parabola

4 points : a cubic Bezier Curve

2005-10-24

Figure 4-15Examples of two-dimensional Bezier curves generated from three, four, and five control points. Dashed lines connect the control-point positions.

2005-10-24

4.3.4 Cubic Bezier Curves

4 control points (p0,p1,p2,p3):

0≤u ≤1

Where

2005-10-24

Bezier blending function:

2005-10-24

At u=0 , B1,3=B2,3=B3,3=0 , B0,3=1

At u=1 , B0,3=B1,3=B2,3=0 , B3,3=1

2005-10-24

We know B1,3(u)=3u-6u2+3u3

→ B′1,3(u)=3-12u+9u2

Let B′1,3(u)=0 , so we have 3-12u+9u2=0 So , when u=1/3, B1,3(u) have the maximum. Similarly, when u=2/3, B2,3(u) have the maximum.

2005-10-24

Figure 4-19 The four Bezier blending functions for cubic curves (n = 3).

2005-10-24

The algorithm:

Begin

x=x0,y=y0

move to (x ,y)// 移动到 (x0,y0)

for u=0 to 1 step ∆u

x=B0,3(u)*x0+ B1,3(u)*x1+ B2,3(u)*x2+ B3,3(u)*x3

y=B0,3(u)*y0+ B1,3(u)*y1+ B2,3(u)*y2+ B3,3(u)*y3

line to (x ,y)

end for

end

2005-10-24

For an example:Construct a cubic Bezier Curve with

four points p1(0,0,0) , p2(1,1,1) , p3(2,-1,-1) , P4(3,0,0) , and compute the values of coordinates at u=0 , 1/3 , 2/3 , 1

Solution:

2005-10-24

Where

At u=0 , p(0)=p1=[0 0 0]

At u=1 , p(0)=p4=[3 0 0]

2005-10-24

At u=1/3

B0,3(1/3)=(1-1/3)3=8/27 B1,3(1/3)=3×1/3(1-1/3)3=4/9 B2,3(1/3)=3×(1/3)2(1-1/3)=2/9 B3,3(1/3)=1/27Thus: P(1/3)=8/27[0 0 0]+2/9[1 1 1]+4/9[2 -1 -1]+1/27[3 0 0] =[1 2/9 2/9] At u=2/3 B0,3(2/3)=1/27 ,B1,3(2/3)=2/9 ,B2,3(2/3)=4/9,B3,3(2/3)=8/27Thus: P(2/3)=1/27[0 0 0]+2/9[1 1 1]+4/9[2 -1 -1]+8/27[3 0 0] =[2 -2/9 -2/9]

2005-10-24

4.3.2 Properties of Bezier Curves

(1) a Bezier curve is that it always passes through the first and last control points.

(2) the slope at the beginning of the curve is along the line joining the first two control points, and the slope at the end of the curve is along the line joining the last two endpoints.

2005-10-24

B′0,3(u)=-3+6u-3u2

B′1,3(u)=3-12u+9u2

B′2,3(u)=6u-9u2

B′3,3(u)=3u2

At u=0 , B′0,3(0)=3 ,B′1,3 (0)=3 ,

B′2,3(0)=0 ,B′3,3(0)=0

p′(0)=-3p0+3p1=3(p1-p0)

2005-10-24

At u=1 , B′0,3(1)=0 , B′1,3 (1)=0 ,

B′2,3(1)=-3 , B′3,3(1)=3

p′(1)=-3p2+3p3=3(p3-p2)

(3) Similarly, the parametric second derivatives of a Bezier curve at the endpoints are determined by the three

adjacent control point.

(4) any Bezier curve is that it lies within the convex hull (convex polygon boundary) of the control points.

2005-10-24

Problem ?

How to link smoothly 2 cubic Bezier curves?

2005-10-24

4.3.3 Smooth Transition of Cubic Bezier Curves

Figure 4-18Piecewise approximation curve formed with two Bezier sections. Zero-order and first-order continuity are attained between curve sections by setting p'0 = p2 and by making points p1, p2, and p'1collinear.

2005-10-24

Two curves: the first section : p0 , p1 , p2 , p3

the second section : Q0 , Q1 , Q2 , Q3

p3 and Q0 are the same points.(1) To obtain C' continuity between

curve section. for the first section , at u=1 p'(1)=3(p3-p2) for the first section , at u=0 p'(0)=3(Q1-Q0)

2005-10-24

Let p'(1) = p'(0)If C‘ continuity , then 3(p3-p2)=3(Q1-Q0)Result: p2 , p3 , Q0 , Q1 collinear. p3 , Q0 middle point.

(1) To obtain C″ continuity between curve section. for the first section , at u=1 p ″(1)=6(p3-2p2+p1) for the first section , at u=0 p″ (0)=6(Q2+Q0-2Q1)

2005-10-24

If C″ continuity , then Q2-p1)=2(Q1-p2)

Result: Q 2p1 and Q 1p2 平行.    Q 2p1 长度是 Q 1p2 长度的2倍.

2005-10-24

4.3.5 Bezier Surfaces

Two sets of orthogonal* Bezier curves can be used to design an object surface by specifying an input mesh of control points.

with pj,k specifying the location of the (m + 1) by (n + 1) control points.

2005-10-24

Figure 4-21A composite Bezier surface constructed with two Bezier sections, joined at the indicated boundary line. The dashed lines connect specified control points. First-order continuity is established by making the ratio of length L1 to length L2 contrast for each collinear line of control points across the boundary between the surface sections.

2005-10-24

4.4 B-Spline Curves and Surfaces

the most widely used class of approximating splines.

two advantages :(1) the degree of a B-spline polynomial can be set

independently of the number of control points

(2) B-splines allow local control over the shape of a spline curve or surface The trade-off is that B-splines are more complex than Bezier splines

2005-10-24

Figure 4-22A closed, periodic, piecewise, cubic B-spline constructed with cyclic specification of the six control points.

2005-10-24

4.4.1 B-Splines Curves

Suppose we have n+1 points

pk(xk,yk,zk) k=0,1,2,……,n

u [0,1]∈Where

1

1

2

2

2121210 0

,,, )()(),(n

k

n

knknkkk vBuBpvuP

2005-10-24

4.4.2 Cubic B-Splines

n=3 , we have 4 control points:p0,p1,p2,p3

when n=3,k=0

2005-10-24

when n=3,k=1

when n=3,k=2

when n=3,k=3

2005-10-24

So , we have

where

2005-10-24

For an exampleConstruct cubic B-Splines curves with 5 points

p0(1,0) , p1(0,2) , p2(2,3) , p3(5,2.5) , p4(6,1) and

compute the values of coordinates at u=0 , 1/2 ,

1 , draw the curve.

solution:

2005-10-24

2005-10-24

At u=0

F0,3(0)=1/6 , F1,3(0)=4/6

F2,3(0)=1/6 , F3,3(0)=1/6

At u=1

F0,3(1)=0 , F1,3(1)=1/6

F2,3(1)=4/6 , F3,3(1)=1/6

At u=0.5

F0,3(0.5)=0 .021 , F1,3(0.5)=0.479

F2,3(0.5)=0.479 , F3,3(0.5)=0.021

2005-10-24

For p0p1p2p3

2005-10-24

Similarly, for p1p2p3p4

p(0)=[2.17 2.75] p(1)=[4.67 2.33] p(0)=[3.479 2.698]

The drawing is omitted.

2005-10-24

The algorithm:Begin x=F0,3(0)*x0+ F1,3(0)*x1+ F2,3(0)*x2+ F3,3(0)*x3

y=F0,3(0)*y0+ F1,3(0)*y1+ F2,3(0)*y2+ F3,3(0)*y3

move to (x,y) for k=0 to n-3 for u=0 to 1 step ∆u x=F0,3(u)*xk+ F1,3(u)*xk+1+ F2,3(u)*xk+2+ F3,3(u)*xk+3

y=F0,3(u)*yk+ F1,3(u)*yk+1+ F2,3(u)*yk+2+ F3,3(u)*yk+3

line to (x ,y) end for end forend

2005-10-24

4.4.3 Properties of B-Spline Curves

(1)often , a B-Spline curve doesn’t pass through the start or end point.

p(0)=1/6p0+4/6p1+1/6p2

p(1)=1/6p1+4/6p2+1/6p3

(2)Sections of B-Spline curve are smoothly and consecultively connected.

2005-10-24

4.4.4 B-Spline Surfaces

B-spline surfaces exhibit the same properties as those of their component B-spline curves.

2005-10-24

Figure 4-23A prototype helicopter, designed and modeled by Daniel Langlois of SOFTUIAGE, Inc., Montreal, using 180,000 B-spline surface patches. The scene was then rendered using ray tracing, bump mapping, and reflection mapping. (Coudesy silicon Graphics, Inc.)