Fairing of parametric cubic splines

Fairing of parametric cubic splines

COMPUTER MODELLING PERGAMON Mathematical and Computer Modelling 30 (1999) 121-131 www.elsevier.nl/locate/mcm Fairing of Parametric Cubic Splines J. ...

617KB Sizes 0 Downloads 72 Views

COMPUTER MODELLING PERGAMON

Mathematical and Computer Modelling 30 (1999) 121-131 www.elsevier.nl/locate/mcm

Fairing of Parametric Cubic Splines J. YE Department of Computational Science National University of Singapore Singapore 119260 yejpkz3.nus.edu.sg R. Qu Department of Mathematics National University of Singapore Singapore 119260 [email protected] (Received and accepted January 1999) Abstract-The generation of smooth curves from a given set of data points is a very important problem in the field of Computer Aided Geometric Design. Cubic splines are widely used in practical applications, because of its simple mathematics and computation. However, these curves could sometimes oscillate and introduce unwanted inflexions. This paper develops an iterative method similar to Kjellander’s to eliminate these oscillations and inflexions. @ 1999 Elsevier Science Ltd. All rights reserved. Keywords-Minimal

energy curve, Ferguson spline, Curvature,

Approximation.

1. INTRODUCTION 1.1.

Fair

Curves

One of the goals of computer-aided geometric design is to obtain smooth and fair curves. Very frequently, however, interpolation algorithms produce curves that interpolate a given set of data points, but have unwanted oscillations. The fairness of a curve is measured by several criteria. F’rom a general viewpoint the problem of constructing a fair curve may be approached by optimizing a functional that measures curve fairness. The fairness functional based on the square of the second-order derivative of the curve is often considered an adequate measure of fairness (cf. [l-3]). There are also several different fairness functionals ever considered, e.g., the functional based on the curvature of the curve (cf. [4]), and the functional based on higher order derivatives (cf. [5]). In practice, the commonly used and recognized criterion for curve modelling is the least bending energy. The total energy of an elastica of length 1 is proportional to the integral of the square of the curvature taken along the elastica (cf. [6,7]), i.e., E=

J

1

K(S)’ ds,

0

0895-7177/99/S - see front matter. PII:sos95-7177(99)Oo152-1

@ 1999 Elsevier Science Ltd. All rights reserved.

Typeset

by 4&W

J. YE

122

AND

R. Qu

where n is the curvature and s is the arc length. However, the functional expressing the exact energy is complicated, and as a consequence, this method is computationally very demanding and takes a lot of time. In practice, approximating energy functionals are often used. In this paper, the curve C is required to minimize a fairness functional which is based on the integral of the second derivative squared of the curve:

=J (P”(t))2 b

J1

(1.1.1)

dt.

a

The composite curve C is used to approximate the given data points {ri}, with associated pi rameter values ti E [a, b]. In order to control the distance between points pi on the curve C and ri, an error functional with parameters ci 10 is introduced:

(1.1.2)

J2 = 2 oi(pi- T.~)~. i=o

As a result, the curve C is required to minimize the following composite functional J=

Jr + J2.

(1.1.3)

The methodology used in our approach is derived from the existing fairing method due to Kjellander [l]. Kjellander’s method is limited to the uniform parametrization case and may sometimes render undesirable fluctuation (cf. [8]) when the parametrization is not consistent with the geometric spans. This makes the generated curve ‘unpleasant’. The following example demonstrates this phenomenon (cf. [8,9]). The data is shown in Table 1 The resulting curves are shown in Figure la while Figure lb shows the corresponding curvature plots. The curve with uniform parametrization is plotted with a dashed line, and the curve with chord length parametrization is plotted with a solid line. Table I x

0

12

II

0

0

0

3

4

5

6

7

8

9

0

0

4

4

4

4

4

(a) The curvea fitted with uniform (dash) and nonuniform (solid) parametrizations.

(b) The corresponding curvature plots of both curves. Figure 1.

123

Parametric Cubic Splines

From the above graphs, the drawback of the uniform parametrization we extend Kjellander’s method in two respects:

is clear. In this paper,

1. chord length parametrization is used instead of the uniform parametrization; 2. the fairing functional J is used instead of the fairing functional based on the square of the second derivative. We conclude this section with a brief discussion on cubic splines which is pertinent fairing method.

to our

1.2. Ferguson Spline

1.1. Given a set of n + 1 data points ri = (zi, yi), i = 0 : n, in R2, with associated parameter values ti E [a, b] satisfying a = to < - - - < t, = b, a function P(t) is cubic interpolatory spfine function (or Ferguson spline) if the following conditions are satisfied: DEFINITION

P

E

C2[a,b],

P is a cubic polynomial Pi defined on the subinterval [ti, &+I], i = 0 : n - 1, P(ti) = ri for i = 0 : n, i.e., P interpolates the data points {ri}, one set of the following boundary conditions: (a) P”(to) = P”( tn) = 0, (b) P’(to) = T;, P’(t,) = T;, (c) P(to) = P(&),

P’(to) = P’(&),

Here the chord length parametrization

P”(to)

= P”(t,).

is used so that

k

c

IQ-

Q-11

to =a,

(k=1,2

,...,

n).

(1.2.1)

A point on a segment [&_I, ti] of such a spline is given by: r(t)

=

(z(t),

y(t))

= a0 + al(t

-

t&l)

+ az(t

-

+ as(t

ti-1)2

-

ti-1)3,

(1.2.2)

where ai can be expressed as: a0 =

(1.2.3)

T-j-1,

(1.2.4)

a1 = +i_1, a2 =

j$

(Ti -

T&-l)

(w-l

-

2

-

-

hi fi,

(1.2.5)

$

+

$

(1.2.6)

*

* a3 =

$

Ti) +

1

h_ ii-1

z

ii-1

fi,

z

where ii denotes the first-order derivative of the cubic spline r(t) at ti, and hi = ti - ti-1 (i=l:n). We conclude this section by stating the Minimum Curvature Property of cubic splines (cf. [lo]). 1.1. MINIMUM CURVATURE PROPERTY. Let f(t) E C2 be any function defined on [a, b], and moreover, let it satisfy the same interpolating and endpoint conditions as the cubic spline S(t) . Then THEOREM

b

sa

[S”(t)]2

di! 5 s

ab

with equality holding if and only if f G S over [a, b].

V”W12 4

J.

124

2. FAIRING 2.1. Kjellander’s

Smoothing

YE AND ft.

Qu

OF CUBIC

SPLINE

Method

Let T be a parameterized curve in R2:

t E [a,b] c R.

r(t) = (x(t), y(t))TI The curvature of the plane curve is then given by

(2.1.1) The energy integral can be derived (with respect to parameter t) as (2.1.2)

For the case where r = (5, Y(z)), the exact strain energy of r can be written as

E=

5/2

dx*

(2.1.3)

So with the assumption Iy’( < 1, (2.1.3) reduces approximately to the energy functional

E = s

(Y”)~ dx.

Kjellander found that this approximate energy functional is decreased if any point ri is moved to a new position rig according to the following equation, provided that all other points and their tangents are kept unchanged (cf. [5]): rig = $ (ri-1 + ri+r) + i (+i-1 - +i+r) * However, functional (2.1.4) cannot guarantee that the point rig does not deviate much from the original point r-t_ Moreover the uniform parametrization assumed in [5] may sometimes render undesirable fluctuation as illustrated in section one. In the next part, the fairness functional defined in (1.1.3) and the chord length parametrization are used and the criterion to move a point is given. 2.2. Modified

Kjellander’s

Smoothing

Method

In this section, we show that the energy, according to the fairness functional (1.1.3) can be decreased by moving point ri to a new position rig according to the following equation

where I.=12 3 h;’

IIj =

The following notations are used in our formulations: Pr P’S -

P3 Ji(Pj)

-

J(Pj) -

the Ferguson spline interpolating the points the cubic spline interpolating the points (TO,. . . , ri-1, T+T~+I,. . . ,r,) with the same tangent at every point as the Ferguson spline Pr, the Ferguson spline interpolating the points {TO,. . . , r+1, r~,ri+l, . . . , T,}, the energy of the cubic spline Pj according to fairing functional J+, the energy of the cubic spline Pj according to fairing functional J.

Of course, the three cubic splines 4,

Ps, P3 have the same boundary conditions.

Parametric

Cubic Splines

125

LEMMA 2.1. h(S)

-

Jl(P2)

where Jr(Pr) = Cy=, Jty_, (P~(t)“)~dt PROOF.

According to (1.2.1)-(1.2.6),

= (4 + Ii+1 + %)(7-i

and Jr(&)

- Qg)2,

= li(P2ft)“)2dt.

a point on a segment of a cubic spline between ri-1 and ri

can be computed by

5 aj(t - &_l)j

r(t) =

(2.2.3)

j=O = NiG&‘y

where

G=

1

0

0

0‘

0

0

1

0

-- 3 hi

3 pz

-hi

2

-- 1 hi

Ni = (l,t - ti-1, (t - ti-~)~, (t - ti-I)“)

e

Hence, the energy value according to the energy functional (1.1.1) associated with the given section [&_I, ti] is:

hi L1 =

> MT MGyT

s

dt, (2.2.4)

= rsoQ&T, = LIZ + Lly, where M = (O,O, 2,6t), 1% -Ii Iii Iii

(2.2.5)

-Ii Ia -Iii -I&

I& -rri III. I&

I& -I& IK II&

L1, = YiQiYT,

Ll, = XiQiXzT,

Xi = (Zi-1,2i,kiml,ki), 4 III,=%’

K = (Yd-l,Yi,!h-l,tii),

2 Ivj = hj’

(2.2.6)

(2.2.7) (2.2.8) (2.2.9)

and Ij and IIj are defined in (2.2.2) and (2.2.3), respectively. It is sufficient to study only the x-component, since the treatment to the y-component is analogous. By (2.2.3), the total energy for two consecutive segments A and B of the spline is: ‘&TAB

= &A =

+ J&B

XiQiXT

+ Xi+lQi+lXL,,

where xi is the common point for the two segments.

(2.2.10)

126

J.YE

The z-component

Substitution

R.Qu

AND

of equation (2.2.1) is:

of equation (2.2.11) for xi in equation (2.2.10) results in L lzA& =

Xi,QiX;+ X(i+qgQi+lX;+llg,

(2.2.12)

where xi, =

(Q-1,

zig, Xi-l,

ki),

X(i+l)g

=

(XigJi+lr~i,%+l)

*

(2.2.13)

From (2.2.10) and (2.2.12), we have LlzAB

-

LlsABg

=

(&

+ &+l

+

(2.2.14)

2oi)(zi - zig)‘.

It follows that Jl(Pi)

- Jr(P2) = (1i +

&+1

+ 24(ri

-

(2.2.15)

7-ig>2.

Thus, Lemma 2.1 is proved. From Lemma 2.1, it is clear that the cubic C1 spline PZ has smaller energy than the Ferguson spline PI according to the fairing functional (1.1.1). In the following lemma, we show that the Ferguson spline PI has a smaller energy than the cubic C1 spline Ps according to the faking functional (1.1.1). The proof is similar to that of Theorem 1.1. LEMMA 2.2.

whereJl(P3) = Ji (Ps(~)“)~ dt and J1 (Ps) is defined in Lemma 2.1. PROOF. Consider the integral

2 lti is1

- P3(t)“)2 dt

(4’(t)

Jh-1

(2.2.16) = J~(P~>- Jo

-22

1”’

Integrating

(P:(t)

- Ps(t)“) P{(t) dt.

h-1

i=l

by parts twice and using the interpolatory

conditions, we have

CJti n

(P;(t) - P3(t)“) P;(t) dt

i=l

k-1

=

n

(G(t)

-

GwPiwl:i_l

(2.2.17)

i=l c(

-(Pz(t) = (4(t)

Since ‘&

- Pa(t))P~(t)l:i_,

- 4(t))

+ s” (h(t) ti- 1

- Pdt))Pj(t)

P/I! = 0.

l:_, (PC(t) - P3(t)“)2dt 2 0, Lemma 2.2 is proven.

From these two lemmas, we have our main theorem.

dt

Parametric Cubic Splines THEOREM 2.1.

The energy J(q)

of a Ferguson spline 9,

127 according to the fairness func-

tional (1.1.3) is decreased by moving ri to a new position rig according to equation (2.2.1). PROOF. From Lemma 2.1, Jl(P1)

-

Jl(P2)

= (Ii + Ii+1 +24(7-i

- r&,

and Lemma 2.2, Jl(P2)

-

Jl(P3)

L 0,

we have Jl(Pl)

Incorporating

-

Jl(P3)

2 (4 + A+1 + 24(7-i

- QJ2.

(2.2.18)

(2.2.18) with the obvious fact that J,(pl)

- J2(p3)

= -%(ri,

- Ti)2,

we have J(q)

-

4s)

= Jl(pl)

- 4(s)

+ J2(pl)

2 (Ii + Ii+1 + Oi)(Ti

-

JZ(p3)

- r&J2 > 0.

(2.2.19)

So far, we have proven that if a point is moved according to equation (2.2.1) and the tangents are recalculated, a spline with a low value of energy according to the fairing functional (1.1.3) is acquired. For a given point ri this process can be repeated until rig = ri. From (2.2.1), we have

It is obvious from the above expression that if the process is repeated infinitely, the constant oi cannot control the distance between ri and rig, So during the iterative faking process, we should be careful. In order to control the distance, the number of iterations should be limited. If the distance is not limited and (2.2.20) is used to move the point ri, this process can be realized in one step (cf. [l]).

3. PRACTICAL

CONSIDERATIONS

We now discuss some practical issues arising in the implementation of the above methods. 3.1. Which

Point

Should

Be Moved

First?

As Kjellander and Farin have pointed out, curvature is an important tool in judging the aesthetic quality of a curve. A curvature plot is the graph of curvature vs. arc length or the parameter that defines the curve. The curvature plot is a highly sensitive indicator of the shape of a curve. If a curve has a pleasant curvature plot, a designer can be sure that a precision plot of the curve will be flawless. Thus, curvature plot is used to assess the quality of our fairing method. 3.2. Tolerances It may happen that the fairing method generates a curve that differs too much from the original one. For the cubic case, from (2.2.1) we have

The distance can be adjusted by properly choosing ui. However, special care should be taken when the process is repeated.

J. YE AND R. Qu

128

(a) Variation in ~5: 0 (solid), 300 (dotted), 1000 (dashed) and the original curve (dash-dotted).

(b) The corresponding the four curves.

curvature

plots of

(c) The curves generated by Kjellander’s (solid) and modified Kjellander’s (dashed) fairing method.

(d) The corresponding both curves.

curvature

plots of

Figure 2.

4. EXAMPLES To show the effectiveness of the fairing technique, three examples are provided in this section. The influence of the coefficient cri, the iterative process on the quality of the resulting curves are shown by these examples. Examples are also shown to compare our modified method with Kjellander’s. EXAMPLE 1. The first example (Figure 2a and Figure 2b) shows the influence of the coefficients {pi} on the shape of the curve. The nine points form a corner in the fifth point. In this example, the process iterates ten times and the natural boundary conditions are given. The Figure 2c and Figure 2d compare the Kjellander’s and our modified Kjellander’s fairing method. Here we set ~75= 0 and the criterion (2.2.20) is used instead of (2.2.1). Although the curve plots from Figure 2c are almost the same, from the curvature plots we can see our modified method makes the curvature plot much smoother. EXAMPLE 2. The second example (Figure 3a) shows the effect of the iterative process. It consists five unequally spaced points. Here the natural boundary condition and 41 = 1000 are used. From the Figure 3a and Figure 3b, we can see that the effect of the coefficient err on the shape of the curve is diminished as the iterative process is taken to a large number of times. In this example, after 20 times, both the curve and the curvature plots are almost the same.

Parametric Cubic Splines

(a) Variation in iterations: 20 (solid), 10 (dotted), 5 (dashed) and 1 (dash-dotted).

(b) The corresponding curvature plots of these curves.

(c) The curves generated by Kjellander’s (solid) and modified Kjellander’s (dashed) fairing method.

(d) The corresponding curvature plots of both curves.

129

Figure 3.

The following Figure 3c and Figure 3d compare the Kjellander’s and our modified Kjellander’s fairing method. Other conditions are the same as in the first example. In this example, our modified method also makes the curvature plot much smoother. EXAMPLE 3. The third examples to compare our modified method with the Kjellander’s method with respect to the coefficient ui and the iterative process.

Figure 4a and Figure 4b show the Kjellander’s and our modified Kjellander’s fairing method. The criterion (2.2.20) with as = 0 and the natural boundary conditions are used. Figure 4c and Figure 4d show the Kjellander’s and our modified Kjellander’s fairing method. The criterion (2.2.1) with C7s= 100 and the natural boundary conditions are used. The process (2.2.1) is applied only once.

5.

CONCLUSION

Kjellander’s method has been modified to smooth Ferguson splines. It is shown that the energy according to functional (1.1.3) can be reduced if we move a point according to equation (2.2.1). The fairness criterion is quite simple. It improves Kjellander’s method in two respects, the chord length parametrization and the fairing functional J. It is thus more suitable for practical applications.

130

J. YE AND ft. Qu

(a) Kjellander’s (solid) and modified Kjellander’s (dashed) fairing method.

(b) The corresponding both curves.

curvature plots of

(c) Kjellander’s (solid) and modified Kjellander’s (dashed) fairing method.

(d) The corresponding both curves.

curvature plots of

Figure 4.

Numerical examples are provided to show the effects of CT~and the iterative process on the shape of the curve. It is clear that the modified method works better, which is shown by the plots of the curve and its curvature. In practice, we must pay attention to the iterative process, because the tolerance is not guaranteed if the process is repeated.

REFERENCES 1. J.A.P. Kjellander, Smoothing of cubic parametric splines, Comput. Aided Des. 16, 175-179, (1983). 2. G. Farin, G. Rein, N. Sapidis and A.J. Worsey, Faking cubic B-spline curves, Comput. Aided Gwm. 91-103, (1987).

Des. 4,

3. C.H. Reinsch, Smoothing by spline functions II, Num. Math. 16, 451-454, (1967). 4. E. Mehlum, Nonlinear spline, In Computer Aided Geometric Design, pp. 173-208, (Edited by R.E. Barnhill and RF. Riesenfeld), Academic Press, (1974). 5. H. Meier and H. Nowacki, Interpolating curves with gradual changes in curvature, Comput. Aided Gwm.

Des. 4, 297-305, (1987). 6. E. Jou and W. Han, Elastic and Minimal-Energy

Splines in Curves and Surfaces, (chamonix-Mont-Blanc, lQQO), Academic Press, Boston, MA, (1991). 7. R. Qu and J. Ye, Efficient approximation of minimal energy curves with interpolatory constraints, Applied Mathematics and Computation (to appear). 8. T.A. Foley, Weighted bicubic spline interpolation to rapidly varying data, ACM trans. Graphics 6, 1-18,

(1987). 9. K. Salkauskss, C’ splines for interpolation of rapidly varying data, Rocky Mountain J. Math. 14, 239-250, (1974).

Parametric 10. A.F. Thomas,

Interpolation

Cubic Splines

with interval and point tensior controls using cubic weighted v-Splines,

131

ACM

Zhns. Math. Softw. 13, 66-96, (1987). 11. Z.D. Guan, J. Ling, N. Tao, P. Xi and R.X. Tang, Study and application of physics-based deformable curves and surfaces, Computer Graphics 21, 305-313, (1997). 12. D.G. Schweikert, An interpolation curve using a spline in tension, J. Math. Phys. 45, 312317, (1966).