Smoothing of cubic parametric splines

Smoothing of cubic parametric splines

Smoothing of cubic parametric splines Johan A P Kjellander The governing equilibrium equation for a plane linear elastic beam is the Euler-Bernoulli ...

346KB Sizes 0 Downloads 119 Views

Smoothing of cubic parametric splines Johan A P Kjellander

The governing equilibrium equation for a plane linear elastic beam is the Euler-Bernoulli differential equation:

The most common curve representation in CADCAM systems o f today is the cubic parametric spline. Unfortunately this curve will sometimes oscillate and cause unwanted inflexions which are difficult to deal with. This paper has developed from the need to eliminate oscillations and remove inflexions from such splines, a need which may occur for example when interpolating data measured from a model. A method for interactive smoothing is outlined and a smoothing algorithm is described which is mathematically comparable to manual smoothing with a physical spline.

y(IV)_

The literature of the field describes many more or less complex interpolation schemes leading to splines with different geometrical properties. A spline under tension for example, introduced by Schweikert I and investigated by Cline 2, Nielsson 3 and others, is a spline where the shape is altered using a tension parameter. Mehlum's spline4 is a spline in which every segment is a piece of a Cornu spiral where curvature varies linearly. Many others could be mentioned s-7. The ordinary cubic parametric spline is used very often in practical applications however. The reason is probably its simple mathematics and ease of computation. The cubic parametric curve representation in IGES (Initial Graphics Exchange Specification) is one good example of its commercial importance. In this paper the spline introduced by Ferguson 8 and thoroughly treated by Peters 9 and Faux and Pratt 1° will be used to introduce some new approaches to the problem of increasing the smoothness of the cubic parametric spline by adjusting the position of data points. The Ferguson spline is defined as a cubic parametric polynomial spline with continuity in position, first and second derivatives and where the parameter t varies in the range 0 ~< t ~< 1. A point on a segment of such a spline is: O
(1)

where ai if expressed in terms of end conditions in r and ~ is:

= r(0) a, =~(0) a2 3(r(1)-r(0))-2i(0) -f(1) a3 = 2(r(O) -r(1)) + f(0) + f(1) ao

=

(2) (3) (4) (5)

Department of Mechanical Engineering, University of Link6ping, S-581 83 Link6ping, Sweden

volume 15 number 3 may 1983

W = K f (y"): dx

(7)

This is a good approximation for most beam problems i f y ' is not too large and the physical dimensions of the beam are such that energy associated with shear is small compared to W. A beam of this kind is the draftsman's traditional wooden spline used for curve fitting and a cubic polynomial spline is thus its approximate mathematical model.

THIRD

DEGREE

CONTINUITY

In a physical spline, energy is decreased by decreasing the shear forces applied to it. Mathematically this can be seen as decreasing the difference in third derivatives on both sides of a datapoint. Making this difference zero (removing a force applied to the spline) for a given datapoint r i joining two segments A and B of a Ferguson spline gives:

"vA (1) =

(8)

which is satisfied if: 1

3

Z a/t / i=1

(6)

The deflection y(x), caused by the distributed load q(x) and the end loads, minimize the potential energy. If the load q(x) is nonzero only for discrete values o f x a piecewise cubic polynomial function is a solution to this equation. With q(x) = 0 the potential energy will only be due to internal strain energy, which i f y ' < < 1 may be written as:

cubic splines, oscillations, interactive smoothing

r(t)=(x(t),y(t),z(t))=

q(x) El(x)

1

rig = ~ ( r i - l + r i + l ) + -~ ( r i - 1 - ri+l)

(9)

index g denoting a smoothed point. How is energy, equivalent to internal strain energy in a beam, effected in the Ferguson spline if a point r / is moved to a new position rig according to equation (9) and all other points and their tangents are kept unchanged? In equation (7) y is an explicit function o f x . For a parametric curve like the Ferguson spline equation (7) corresponds to: W~ = K f (~)2 dt

0010-4485/83/030175--05 $03.00 © 1983 Butterworth & Co (Publishers) Ltd

(10)

175

Hence energy associated with a given segment of a Ferguson spline is: 1

W* = K f (2a 2 + 6a3t)2dt = o =

2

K(4I;

a2i

+ 121~

]=x~ y, z

o3i+ 122~

a2i /=X, y, z

a~i

)

i=X, y, z

= K(Wx* + W~,+ W~)

(11)

It is sufficient to study only the x-component, while the treatment of W~, and Wz* is analogous. From equation (11) it is found that: (12)

W* = 4a~x + 12O2xO3x + 12a~x

where

according to equation (9) gives a curve with a lower value of W*. If a point in a Ferguson spline is moved without recalculating the tangents, however, the curvature continuity is destroyed and the spline is no longer a Ferguson. Since a Ferguson spline is a curve that minimizes W* for a given set of points, it is hereby proven that if a point is moved according to equation (9) and the tangents are recalculated a spline with a lower value of W* is acquired. For a given point xi this process can be repeated to infinity and in the end xig = xi and equation (8) will be valid in the point even after recalculation of the tangents. An interesting method of achieving third-degree continuity in one step for a given point is to incorporate equation (9) in the system of linear equations used to calculate the tangents. Normally such a system for n points looks like: 21

a2x = 3(xi+

1 - xi)

- 2Y~i - xi+

1

a 3 x = 2 ( x i - Xi+ l ) + "~i + "~i+ I

(13)

141

(14)

0141

The total energy for two consecutive segments A and B of the.spline would with equations (13) and (14) substituted in equation (12), then be: WxA B = WxA + WxB = 2 4 x

-24xixi_

I -12xixi_l .2

00

0 0

0

0

0141

0

0

0141

0

01

2

+

+ 12x7_1 + 1 2 X i - l X i - I + 1 2 X i - l X i + 4xi-1 + .2

(15)

- 12xi+12i+I + 12xi~i+l + 4~iY~/+1 + 4 x i + l

-21

0

(16)

xig = -~(xi-1 + xi+l)+ ~(~i-1 -~i+1)

tOI

=

3(rl-ro)

h I

(r2

e21

(r3 - rl )

- ro)

]

_6,

(rn - rn_ 7)_

0

141

Where x I is the point in common for the two segments. The x-component of equation (9) is: 1

--[: J

(19)

If constraint (8) is added we get one more unknown ri and one more equation (9) which will result in:

2

+ 4 X i - l X i + 8,~i2 + 12xi+1 - 2 4 X i + l X / - 1 2 x / + l x i

1

0

Substitution of equation (I 6) for xi in equation (15) results in 2

0 1 4 1 0

0

O

to-

0

tz

0

ri- I ti 6+ z

0-3

0 1 4 1 0

0

0 1 4 1 0 0

3

0

014

1

WxABg = 6xi-1 - 1 2 X i - l X i + l + 6 X l - l X i - I + 6 X i - l X i + l

0

+ 6xi2+ 1 - 6 X i + l X i - I - 6xi+ZXi+l + ~5 x i•-21

0

5 .2 + 3~i_l~i+ 1 + -~xi+ 1 + 1 2 x i _ 1 ~ i + 4 ~ i _ 1 ~ i

0

1

0 - ~1 o ~ 01 - 3(rl

- ro)

3(r2

- ro)

0

2

rn

1

ri

(20)

-

(17)

+ 8Y~7- 12xi+lY~i + 4 x i x i + l

With xi=O (the origin of the coordinate system may be moved without changing W*) equations (15) and (17) give:

-3r/_2 3(ri+l

-

ri_l)

3ri+2 ~

2

=

[12xi_1 + 12xi-12i-1 + 427-1

WxA B - W~.ABg 2

.2

+ 12xi+ 1 - 12XI+lY(i+ l + 4xi+z]

2

- [6xi_ l - 12xi_lxi+

1

3 (rn - rn- 1 )

2

+ 6Xi_lY(i_ 1 + 6xi_I/(i+ 1 + 6xi+ 1 - 6xi+1~i_ 1 -6Xi+l~i+

1



1



2

Which is always greater than zero, hence WABg <- W~B. This proves that a point in a Ferguson spline moved

176

l (ri-1 + ri+1)

5 .2 5 .2 I + ~ X i _ 1 + 3,~i_1,~i+ 1 + - ~ X i + I ]

= (Xi_ I + X i + I + ~ X i _ I - ~ X i + l )

3(rn - rn-2)

(18)

which when solved will give us a Ferguson spline with equation (8) valid in ri. In this way it is possible to achieve third-degree continuity in many points simultaneously by just adding the appropriate equations to equation (20).

computer-aided design

CURVATURE

DERIVATIVE

CONTINUITY

Equation (8) is a sufficient constraint for gaining continuity of ~ = d g / d t in a given data point. It is, however, possible to gain this continuity in other ways. With: g=

t fxP t ~

(21)

and specializing to a plane curve we get: g - (j2 +.~,2)3/2 =

j3

(22)

and:

s

- 3s .~4

:

(23)

Ifk is to be continuous in a datapoint r i joining two segments A and B, in a Ferguson spline, the following is required: kA (1) = kB(0 )

(34)

which will move the point in a specific direction. If we move a point in this way the situation is much the same as when we moved according to equation (9). The spline tangents have to be recalculated in order to get a true Ferguson spline. If we do this however equation (24) will not be valid any more and the point has to be moved again and so on. For a wellbehaved spline an infinite number of iterations will make equation (24) valid in the point even after recalculation of the tangents. Since h 1 and h 2 in equation (33) contain terms like x.y, it is not possible to incorporate this constraint into the linear system of equations (19), and therefore it is not possible to make equation (24) valid in one step for a Ferguson spline as it was for equation (8). Nevertheless each iteration gives a better curve and using this method it is possible to specify the direction in which the point is to move, an option which is not available using equation (9). INTERACTIVE

rA (1) = fB(O)

(25)

rA (1) = PB(0)

(26)

=

Y i - Yig _ constant xi - xi o

(24)

Since we deal with a Ferguson spline we also know that:

Equations

an additional constraint is needed. This could for example be:

(27)

The Ferguson segment may be written as: r(t) = r(0) (1 - 3t 2 + 2t 3) + r(1) (3t 2 - 2t 3) + f(0) x (t - 2t = + t 3) + f(1) (-t = + t 3)

When a spline is being smoothed interactively by adjusting positions of datapoints, there are two things that a system ought to be able to help the operator with: • measuring the smoothness of the spline in question • adjusting the positions of datapoints so that the spline really gets s m o o t h e r

(23), (25) and (26) in (24) then give:

(I) (1) A (i) (0)78 (0) - 28 (0)

SMOOTHING

(28)

and

The first problem is efficiently solved 6y generating x-curves, see examples. This is a curve which shows the variation of g along the spline to be smoothed, and any oscillations or inflexions are easily detected with the help of this curve. The second problem can be handled with using one of the methods described earlier in equations (9), (20) or (33). What a designer who is smoothing a spline, now has to do is:

~(t) = r(O) ( - 6 t + 6t 2) + r(1) (6t - 6t 2) + f(O) x (1 - 4t + 3t 2) + f(1) (-2t + 3t 2)

(29)

"f(t) = r(0) (-6 + 12t) + r(1) (6 - 12t) + f(0) x (4 + 6t) + f(1) (-2 + 6t)

(30)

~:(t) = 12(r(0) - r(1)) + 6(f(0) + f(1 ))

(31)

• •

let the system generate a K-curve study the x-curve and decide which points should be moved and according to what criteria (see equations (9), (20) or (33)) • let the system generate new points and interpolate with a new spline • let the system generate a new x-curve • if not satisfied go back to the second step

Equation (27) together with (29) and (31) then gives: Y(i(12Yi- 1 - 24Yl + 6 ~ i - I + 12Yi+ I - 6,~i+ I ) - Y i x (12)(i_ I - 2 4 x i + 6 f ( i _

1 +12xi+ I -62i+i)=0

(32)

or Yi = k 1 + h2Xi

A point r i can now be moved to any position along this straight line and equation (24) will still be valid. Since there is an infinite number of solutions to equation (33)

volume 15 number 3 may 1983

(33)

Example 1 Figure 1 (a) shows a number of collinear points. Point number 4 however exhibits an error and is not collinear with the other points. The Ferguson spline that interpolates the points oscillates and the (dotted) K-curve shows where inflexions appear. In Figure 1 (b) point number 4 has been moved once according to equation (9) and the Ferguson-spline is now smoother. If moved again an infinite number of times point number 4 will end up as in Figure 1 (c).

177

but if one could specify how much and in what direction each point in a spline may be moved, an automatic smoothing program iterating on equations (9), (20) or (33) could probably be written.

In Figure 1 (c) point number 4 has been moved once according to equation (20) and the spline is now perfectly smooth.

Example 2 Figure 2(a) shows a number of points forming a sharp corner. The Ferguson-spline generated oscillates. Moving the corner point once according to equation (9) gives us the curve in Figure 2(b) which is much better. In Figure 2(c) the corner point has been moved according to equation (20) and curvature slope is continuous in the.point. Finally in Figure 2(0') the corner point has been removed completely. Again the spline oscillates. This shows that moving a point according to equation (20) is not the same as removing the point completely even if that would be the physical significance. When a point is removed in a parametric spline, tangent vector magnitudes and thus curvature change.

ACKNOWLEDGEMENTS I am pleased to acknowledge the helpful discussions with Dr U Bj6rkenstam at the University of Link6ping,

Example 3 The curve in Figure 3(a) appears quite smooth at first glance. The K-curve indicates several inflexions, however, where there should be none. In Figure 3(b) points 2, 4, 5, 7 and 8 have been moved once according to equation (20). Point number 10 has been moved once according to equation (9). The curve is now fully acceptable.

a

Figure 2(a). Sharp corner

Example 4 Figure 4 shows the use of equation (24). The point to be smoothed, P is moved in several different directions all resulting in points on the same straight line representing equation (33). It is interesting to note that this also is a line ofK = constant.

CONCLUSIONS Moving datapoints in a cubic parametric spline according to equations (9), (20) or (33) reminds one of manual smoothing. The 'load' on the spline decreases and thus internal energy. The Ferguson spline has been used here to show this, but equations (9), (20) and (33) could easily be adopted to other cubic parametric splines. It is quite satisfactory to smooth splines in this way interactively

j\

\

b /

Figure 2(b). Sharp corner smoothed using equation (9)

\

?

js

I •

!

u



u

u

C

Figure I. Ferguson spl/ne (a) oscillating (b) smoothed using equation (9) (c) smoothed using equation (20)

178

Figure 2(c). Sharp corner smoothed using equation (20)

computer-aided design

J I

t

i/

Figure 4. The use of equation (24)

/"

(1974) pp 218-220 3

Figure 2(d). Point removed completely 4

5 x 3

El

6

6

i 7 J

.

.

.

.

.

.

JL..~---

a

Figure 3. Curve (o) with several inflexions (b) with several inflexions after interoctive smoothing

8

Nielson, G M 'Some piecewise polynomial alternatives to splines in tension' in Barnhill, R E and Riesenfeld, R F (eds) Computer-eidedgeometric design Academic Press (1974) Mehlum, E Curve end surface fitting based on o voriotional criterion for smoothness Central Institute of Industrial Research, Oslo, Norway (1969) Forrest, A R 'Computational geometry. Achievements and problems' Computer aided geometric design Academic Press (1974) p 17 Gordon, W l and Riesenfetd, R 'B-spline curves and surfaces' in Barnhill, R E and Riesenfeld, R F (eds) Computer oided geometric design Academic Press (1974) p 95 Wielinga, R F 'Constrained interpolation using B-curves as a new tool in computer aided geometric design' in Barnhill, R E and Riesenfeld, R F (eds) Computer oidedgeometric design Academic Press (1974) p 153 Ferguson, J C 'Multivariable curve interpolation' Report No D2-22504 Boeing, Seattle, WA, USA

(1963)

Link6ping, Sweden and also the interesting experiences from the work done by Msc G Liden at SAAB-SCANIA Aircraft Division, Link6ping, Sweden.

REFERENCES 1 2

Schweikert, D G 'An interpolation curve using a spline in tension']. Moth. & Phys. No 45 (1966) pp 312-317 Cline, A K 'Scalar and planar valued curve fitting using splines under tension' Commun. ACM Vol 17 No 4

volume 1.5 number 3 may 1983

9

Peters,G J 'Parametric bi-cubic surfaces' in Barnhill, R E and Riesenfeld, R F (eds) Computer aided geometric design Academic Press (1974) 10 Faux, I D and Pratt, M J 'Computational geometry for design and manufacture' Department of Mathematics, Cranfield Institute of Technology, Bucks, UK (1979) 11 Timoshenko, S P and Goodier, J N Theory of elasticity McGraw-Hill

179