Interchanging spline curves using IGES

Interchanging spline curves using IGES

Interchanging spline curves using IGES John W Lewis Current CAD/CAM systems employ a variety of spline types, spline representations, and curve desig...

551KB Sizes 0 Downloads 85 Views

Interchanging spline curves using IGES John W Lewis

Current CAD/CAM systems employ a variety of spline types, spline representations, and curve design algorithms. The IGES (initial graphic exchange specification) was designed to enable interchange of the more commonly used spline types among CAD/CAM systems, independent of the design algorithms originally used to create them. IGES supports parametric cubic splines through a piecewise polynomial representation. This paper describes the design considerations leading to the interchange common spline curve types. A short introduction to splines and spline representations is included.

The IGES (initial graphics exchange specification) defines a file format for interchanging product definition databases among CAD/CAM systems. The format includes entities describing geometry (point, line, arc, etc), annotation (dimensions, drawing notes, etc), and structure (properties, associations, subfigures, etc). A macroprocessor enables IGES to be extended in a number of different directions (See Nagel et al I and Kennicott 2 for details of IGES). An IGES product definition transfer is a two-step process. (See Figure I .) First, the originating system used its IGES preprocessor to translate database entities into the 'neutral' IGES format. Then, each receiving system used its IGES postprocessor to translate the resulting IGES entities into its database formats. For simple geometric entities such as lines and arcs, these IGES processors are relatively easy to write. Regardless of the representations (or design algorithms) employed in different CAD/CAM systems, all of the systems use parameters in the representations of these simple entities which are easily implemented in IGES processors. IGES processors are difficult to write for systems which use totally different collections of database entities to accomplish the same tasks. Problem areas include (among others) line fonts, character sets, word lengths, floating point formats, layers, labels, dimensions, viewing transformations, properties, relationships among entities, subfigure definitions, arbitrary curves, and sculptured surfaces. (See Kennicott 2 and Lewis3 for discussion of the issues involved in writing general IGES processors.) Spline curves are a particularly difficult area. Current CAD/CAM systems employ a bewildering variety of spline curve design techniques. Curve design techniques range from simple spline interpolation schemes (with dozens of variations to B-spline B6zier polygons, Overhauser control points, and splines under tension. Excellent reviews of curve General Electric Company, USA

volume 13 number 6 november 1981

System A (Originating)

G

System B (Receiving)

Figure 1. Product definition database transmission using IGES

Figure 2. Draftsman's spline design techniques may be found in Lewis 3, Barnhill and Riesenfeld 4 and Rogers and Adams s. Fortunately, although spline design algorithms and representations do vary widely, the resulting splines can be identified as a small number of basic types grouped within a few basic families. One family, the parametric polynomial splines, includes nearly all of the spline curves commonly used in CAD/CAM systems and IGES supports a popular subset of this family - the parametric cubic curves. This paper describes some of the issues involved in using these IGES splines to communicate spline curves between CAD/CAM systems. The paper begins with a brief introduct/on to the common types of splines and their representations. Design considerations which lead to the IGES representation are discussed along with algorithms for convcrting splines to and from IGES.

CUBIC SPLINES The draftsman's spline, a traditional curve-fitting tool, has been used in designing ship hulls for many centuries. (See Figure 2.) It is composed of a thin strip of wood or plastic fixed at several points (called knots) by lead weights (called ducks). By manipulating the ducks, the draftsman created smooth and accurate representations of ships' lines. In recent years, these wooden splines have been replaced by other, less expensive drafting tools, and their approximate mathematical model: the smooth cubic spline.

0010-4485/81/060359-06 $02.00 © 1981 IPC Business Press

359

The mathematical or cubic spline is an approximate model for a thin wooden spline which is not bent too sharply. Under these simplifying assumptions, the wooden spline behaves like the well-understood 'thin beam with point supports' of classical mechanics (See Figure 3 and Timoshenko e .) A thin beam with point supports conforms to the shape minimizing its internal bending energy

f (v") 2 dx

(1)

subject to the constraints of point support at the knots. In doing so it satisfies the simple differential equation y .... = 0

(2)

in each of the spans between adjacent knots; it passes through the point supports, and it has continuous curvature at each knot. Consequently, because the solution to the differential equation (2) is a cubic polynomial, the mathematical model of the infinitely thin spline is a sequence of cubic spans joined together with continuous curvature.

h Continuous curvature

Knot

.J_

J

Cubic -Ipolynominal

Cubic polynomial

I

Figure 3. Thin beam with point supports

-I : Constant

O: Linear

I: Quoedratic

% Ouo°rot,'\ /'0 J \ \./ / - I : Cubic

Figure 4. Polynomial splines: a family tree

y

Y

_~p~l~.(

t)

i÷2

Figure 5. Wilson-Fowler spline 360

/e

2: Cubic

POLYNOMIAL SPLINES From this s;mple wooden strip and the resulting piecewise cubic mathematical model, a variety of generalizations have sprung. A very elegant (and occasionally useful) mathematical theory has been developed. (Consult de Boor 7 for a practical review of this theory and some FORTRAN codes for solving spline problems.) The most popular generalized splines are the polynomial splines. Instead of cubic pol~ nomials in each span, a polynomial spline may have a polynomial of any degree; instead of continuous curvature at each knot, a polynomial spline may have -1 (no), 0, 1 , 2 . . . (up to the polynomial degree minus one) continuous derivatives. A convenient nomenclature is to express each polynomial spline type as a (smoothness) : (degree) spline. For example, the common polynomial splines include: • • • •

0 1 2 2

: : : :

Linear: continuous piecewise linear splines Cubic: cubic splines with continuous slope Cubic: cubic splines with continuous curvature Quintic:quintic splines with continuous curvature

Many of the polynomial splines are simply special cases of other, more general polynomial splines. For example, every polynomial spline type is a special case of any less restricted spline type, ie any type with higher degree and the same smoothness or any type with lower smoothness and the same degree. (See Figure 4 for the 'family tree' showing which splines are special cases of others.) In some systems, additional restrictions are imposed to simplify coding or to improve computational efficiency. Some systems restrict knots to uniform spacing; others require a minimum of 3 or 4 knots; many limit the maximum number of knots; and a few apply zero curvature constraints at end points. Actually, these restrictions are rarely required to produce significantly simpler code or greatly improved computational efficiency. Non-uniform and small number knot algorithms are well-known (see de BoorT); limited storage algorithms are well-developed and can actually improve computational efficiency (see Lewis 8); and zero curvature constraints produce flat spots at the end points. Unfortunately, these system restrictions mean that the affected systems cannot accept the full range of spline curves. SPLINE

CURVES

Frequently the curves required in CAD/CAM applications are not single-valued, ie they cannot be represented by functions. One early method for representing such curves is the Wilson-Fowler spline. (See Fowler and Wilson 9.)This spline is still being used in the APT TABCYL routines. The Wilson-- Fowler spline defines a different coordinate system for each pair of knots, with the origin fixed at the first and the x-axis passing through the second (see Figure 5). The parameters of the polynomials defining each span are chosen so that the curve has continuous slope and curvature, but the polynomials defining the individual spans need not join with continuous slope or curvature. Unfortunately, Wilson-Fowler splines are not a perfect solution to all curve design problems. The curve smoothness equations are nonlinear and must be solved by a time-consuming iterative calculation. Moreover, for certain input data the iterative calculation may not converge to the required accuracy. A more convenient means of expressing such curves is to define each curve as two (planar curves) or three (space curves) functions of an independent parameter, eg,

s(t) = I sx(t) for t ranging from tstar t tO ten d L sv(t)

(3)

computer-aided design

Such parametric curves can follow an arbitrary number of bends in any direction, can describe closed curves, and can even cross themselves (although self intersections are usually not desirable in CAD/CAM applications).

aa (3t 2 - 2 t a) All of these representations can be expressed in the form (here for the special case of cubits)

P O L Y N O M I A L SPLINE R E P R E S E N T A T I O N S

s(t)

I

Pt (t) P2 (t)

Lps (t)

• Polynomial coefficients:

MI

=

(14)

I I

• Taylor series

@

in the ith span bounded by t(i) and t(i+l), the spline is represented by a polynomial Pi (t), ie t t t t

(13)

Where M is a 4x4 (nonsingular) change- of-basis matrix. For example, the M-matrices for the above representations are:

(4)

to < t l < t2 < . . . < t n

if if if if

(1 t t 2 t a) M (% a I a2 %) T

s(t) =

A parametric polynomial spline is simply a sequence of two or three sets of polynomials pieced together with the desired continuity. Consequently, representing a parametric polynomial spline is a simple matter of representing this sequence of polynomials. Unfortunately, this simple problem has a large number of solutions and each CAD/CAM system seems to have found a different one. In particular, consider the problem of representing a single spline function, two or three of which comprise a parametric spline curve. Assume that this spline function s(t) has n polynomial spans of degree d separated by the knots

Po (t)

ao ( 1 - 3 t + 3 t 2-t s+ a l t (1 - t ) 2 +u2 t2 ( l - t ) +

s(t)=

iies between lies between lies between lies between

to and t t and t2 and t a and

Bernstein polynomials:

-330 3-63

tt t2 t3 t4

(16)

13-3

(5)



Hermites:

M4 ti00o

100|

Local parameterization The first problem in defining a spline representation is the definition of local t, the local independent variable used to evaluate each polynomial. There are three options: Global: Local:

Normalized:

tlocaI = t tlocoI = t - t i _ t-t i tloca I - t-~ -ti

(6) (7) (8)

Option 1 (global) is the most obvious choice, but can cause roundoff problems for curves having many knots. Option 2 (local) has no local roundoff error and may make determining derivatives of the curve at the knots easier. Option 3 (normalized) yields a tlocal which varies from 0 to 1 and may enable simplified evaluation routines.

Polynomial representations The second problem is choosing a representation for the polynomials themselves (or more formally, choosing bases for the polynomials). Mathematical textbooks provide an infinite number of possible choices. The parameters defining the polynomial can be a combination of function values, derivatives, and arbitrary coefficients. Among the more popular choices in CAD/CAM systems are: • Polynomial coefficients s(t) = ao +tat + t 2 az + t 3 a~ + . . . • Taylor series d

s(t) =

aj 1_

(9)

(lO)

/=o fl • Bernstein polynomials with normalized tloca I s(t)= ~ ai ( t / ( 1 - t )

n-j

J=0 • Cubic Hermites with normalized t locaI

volume 13 number 6 november 1981

(11) (12)

-2-13| 1 1-2J

(17)

A conversion from one basis to any other is a simple matter of using equation 13 to compute the polynomial coefficients for the first set of basic coefficients, then inverting equation 13 to compute the coefficients for the second basis from the polynomial coefficients derived from the first. In particular, if a is the coefficient vector in the original basis and a' is the coefficient vector in the new basis, then a' is given by the simple formula:

a' = (M') -1 (M) a

(18)

For example, a conversion from cubic Hermites (equation 12) to cubic Bernstein polynomials (equation 11) would be performed by the matrix

o1, ,,-o, oj L-1 3-3

1000] oioo I 3-2-1 31 2 1 1-2J (19)

Spline smoothness The third problem is accounting for the smoothness inherent in splines. All of the representations just discussed will store -1 :splines, ie splines which can be discontinuous at the knots. Of course, the smoother splines, 0:splines, l:splines, • . . (which are all special cases of-1 :splines), could also be stored in this-1: representation; however, the information concerning the smoothness of the spline would be lost. Moreover, the -1 :representation would include redundant parameters, because each additional smoothness constraint means that the spline can be stored using one fewer parameter for each interior knot. For example, a - 1 :cubic requires 4n parameters, a 0:cubic requires 3n+1 parameters, a 1 :cubic requires 2n+2 parameters, and a 2:cubic requires

361

n+3 parameters. Storing a 2: cubic in a - 1 :representation requires three times the necessary number of parameters, Smooth splines can be stored in a variety of different representations. Two popular choices are:

a~(t) I

L. . . . .

I__ .......

I

I

L

I

.............

82 (t)

• Cubic Hermites (for 1 :cubics) (20) Store the function value and slope at each knot. Use equation 12 to evaluate the spline. • B-splines (for any spline) (21) Express the spline as a linear combination of the B-splines B1 (t), B2(t), B 3 ( t ) , . . .

I

e 3 (t) 84 (t) e~ (t)

s(t) =~lo/B/(t) The B-splines are a unique minimum-support basis, ie the only set of basis functions in which each covers the minimum number of knots. (See Figure 6 for the B-splines in the special case of n=lO and uniformly-spaced knots). Because'the B-splines are local-support, ie nonzero over a small number of spans, calculations using B-splines are particularly convenient. The local support principle leads to a very nice design technique based on the B-spline B6zier polygon (see Barnhill and Riesenfield 4); splines having differing degrees of smoothness at each knot can be defined and manipulated easily, and spline curve-fitting problems are easy to pose and solve using B-splines. Detailed descriptions of the properties of B-splines may be found in Barnhill and Riesenfeld4 , Rogers and Adams s , de Boor 7 and Faux and Pratt 1°. FORTRAN codes for working with B-splines (interpolating, evaluating, converting to piecewise polynomial,...) are given in de Boor 7 .

W i l s o n - F o w l e r splines The Wilson-Fowler spline is actually a special case of the parametric O:cubic spline. In span i, a Wilson-Fowler spline can be represented by the two endpoints of the span

(xi, Yi) and (xi+ 1, Yi+I) (22) along with the polynomial (assuming normalized tlocal) PWF(t) = alt (1 - t) = + bit = (1 - t)

(23)

If T(i) is the 2 x 3 rotation/translation matrix which transforms the local coordinate system for span/into the desired global coordinate system (see Rogers and Adams s and Faux and Pratt I° for details of this formulation of transformation matrices, then the parametric cubic polynomial for span i is given by (assuming normalized tlocal)

Pi(t) : T (i)

(24)

E X O T I C SPLINES The basic idea of splines is quite general. Splines can be pieced together out of all sorts of curves (both implicitly and explicitly defined) with a variety of smoothness constraints. Possibilities include conics, hyberbolics, trigonometrics, rationals, nonintegral powers, and solutions to very general differential equations (which may not even be explicitly represented).

362

B6 (t) B7 (t) B8 (t) B9 (t) I

I

I

I

I

I

I

I

B~o(t)

Figure 6. The B-splines Ignoring the mathematical curiosities, many of these spline types are formulated to provide better curve fitting performance than cubic spline design algorithms (which tend to introduce extraneous oscillations). For example, splines under tension provide a method of (quite literally) pulling the oscillations out of a fitted spline (see Schweikerr 11 ). Zero tension produces a cubic spline (which is smooth but may oscillate) and infinite tension produces a broken line (which has sharp corners but cannot oscillate). For some appropriate intermediate value of tension, smooth and oscillation-free fits may be obtained. Non-linear splines were also developed to provide improved curve fitting performance (see Mehlum 12). Nonlinear splines provide a better appro.ximation to the original wooden spline than the classical piecewise cubic polynomials do. Because the wooden spline is actually a better curve design tool than its modern mathematical mimics, these non-linear splines frequently do have fewer oscillations and produce better fits than cubic splines. All of these non-polynomial splines share the common problems of numerical inaccuracy and computational inefficiency. Such splines are considerably more difficult to compute than their polynomial counterparts. Evaluating them may involve nonlinear iterative calculations, evaluation of special functions, and extensive special case checking. One exception to this rule is the nu-spline, a polynomial equivalent of the spline under tension (see Nielson 13). Nu-splines behave very much like splines under tension but can be represented as the more tractable 1 :cubic parametric splines. The rational cubics provide a different kind of generalization (see Hinds and Kaun 14). Line segments, circles, ellipses, parabolas, hyperbolas, and cubic splines can all be stored in the rational cubic canonical form. Only one set of curve manipulation routines need be written, rather than the plethora of routines usually required for lines, circular arcs, conic areas, and cubic splines. This canonical form is particularly convenient in manufacturing applications where objects are frequently represented as composites of line segments, conic arcs, and cubic splines.

computer-aided design

Unfortunately, rational cubics are somewhat more difficult to handle than ordinary cubics and the mathematical analysis is less well developed. At the moment, relatively few systems employ rational cubics, but with the increasing popularity of the CAM-i sculptured surface packages (see their users course Is ), more CAD/CAM systems may very well adopt rational cubics.

IGES SPLINE CURVES The IGES splines are a compromise between generality and portability. A highly general representation, for example the -1 :rational quintics, would accept nearly all current or projected spline types; however, very few systems (none known to the author) could accept a general -1 :rational quintic spline. Conversely, a very restricted representation, for example the 2:cubics, would accept very few of the current spline types, but nearly all systems could accept a general 2:cubic spline. The IGES compromise is a -1 :cubic spline representation. This representation accepts all of the common cubic spline types and can also be accepted by a large number of systems.

IGES spline specification In IGES, spline curves are represented by a number of cubic spline functions, one for each of the x , y , z coordinates. Each cubic spline function s(t) is defined by n: the number of spans • t , . . . , tn+l : the endpoints and the knots separating the cubic polynomial spans • a0 (i), al (i), 0:2 (i), a3 (i), i =0, n: The coefficients of the polynomials representing the spline in each of the nth span. The n+l th span is not required to define the spline, but it is included to make the endpoint value and derivative available without evaluating the polynomial • CTYPE: the spline type• (1 =linear, 2=quadratic, 3=cubic, 4=Wilson-Fowler, 5=modified Wilson-Fowler) • H: the number of continuous derivatives •

To evaluate the spline at a point t, first determine the segment containing t, ie the segment i such that t/~< t < ti+ 1 , then evaluate the cubic polynomial in that segment, ie compute • 2 I + e3(i)tl3ocal (22) s(t) = aO(i) + el (i)tloca I + a2(t)tloca where tloca I =

t - ti

I

I

\

The polynomial is written in terms of the relative displacement tloca I so that the values of the spline at the knots can be read directly out of the representation, ie s (ti) = aO (i),

i = O, n

D s(ti) = al (i),

i = 0, n

(23)

(24)

Because IGES is essentialy a -1 smooth parametric cubic spline in a local t polynomial coefficient representation, equation 13 serves to convert any spline into IGES. If an IGES spline, although it may be stored in a -1 smooth rep resentation, actually meets the restrictions of a receiving system which supports only smoother splines, that formula can be applied in reverse. IGES includes the CTYPE and H flags to indicate if the spline satisfies any special smoothness or degree conditions.

Incompatible splines Difficulties arise when the IGES and host system spline types are incompatible. The host system might employ some exotic spline, in which case it could neither create nor accept IGES splines; or it might employ a more restricted cubic spline (such as the common 1 :cubic), in which case it could create IGES splines, but would not in general be able to accept them. When IGES and host system splines are incompatible, the splines must be refitted. Fitting smooth curves to data (or even to other smooth curves) is a black art. A variety of potions and charms are available, but none of them can guarantee success. Techniques vary from the classical interpolation and leastsquares methods (which are known to fail often), to nonlinear optimization, interactive schemes, strange mathematical functions, digital filters, medians . . . . (which seem to fail less frequently). The underlying difficulty lies in approximation theory. It is impossible to have a curve fitting scheme which is linear (computationally efficient), accurate (uses a small number of parameters), and shape-preserving (does not introduce extraneous wiggles in the fit). (See Korovkin's development of the theory 16•) A spline fit to a positive mathematical function with a single peak can easily achieve negative values and have many peaks. Spurious oscillations occur with annoying regularity (see Figure 7•) The bottom line on this rather sophisticated theory and the accompanying black art is a negative conclusion about interchanging spline curves: splines cannot be exchanged among systems having incompatible representation without human intervention to refit the curves.

CONCLUSIONS \

Figure 7. A spline fit

volume 13 number 6 november 1981

The IGES spline specification is a very workable medium for interchanging spline curves. Most common spline types can be transmitted using IGES. IGES is particularly useful for downstream processors such as SSX8 APT4 which can accept the very general -1:cubic spline produced by IGES. However, neither IGES nor any other transmission format can support the user's dream: that of starting a design on one system (perhaps using Overhauser splines) and transferring that design to another incompatible system for completion (perhaps using uniform knot 2 smooth B-splines). Because refitting incompatible splines can easily lead to loss of precision and shape, the only means of insuring full portability of spline curves is to standardize spline rep-

363

resentations among CAD/CAM systems. The -1 :cubic IGES spline is an important first step toward stabilization, but it is not smooth enough to be truly portable. The majority of current system support some form of the 1 :cubic parametric spline and cannot store or manipulate -1 :cubits or 0:cubits. Thus, to ensure full portability, any splines stored in IGES files for use by other systems should be I :cubits.

6 Timoshenko, S Strength of materials, Part I: elementary theory and problems Van Nostrand (1941 )

ACKNOWLEDGEMENTS

9 Fowler, A H and Wilson, C W 'Cubic spline, a curve fitting routine' Union Carbide Technical Report No Y-1400, Oak Ridge, TN, USA (September 1962)

This paper grew out of a commentary on spline representations included in the IGES report n . That commentary received many helpful suggestions from the members of the committee: Roger Nagel (NBS), Phil Kennicott (GE), and Walt Braithwaite (Boeing). Lon Jones (GE) and Phil Kennicott (GE) helped polish the final draft of this paper. While this paper.is derived from and provides support for the original IGES spline commentary, it does not carry any official sanction from any IGES committees.

REFERENCES 1 Nagel, R W, Braithwaite, W W and Kennicott, P R Initial graphics exchangespecification Version 1.0. National Bureau of Standards Publication NBSIR 80-1978 (R)(1981) 2 Kennicott, P R 'IGES and the translation of CAD/CAM databases' IEEE Trans. Comput. Graphics (to appear) 3 Lewis, ] W 'Designing IGES processors' (to appear)

4 Barnhill, R E and Riesenfeld, R F Computer-aided geometric design Academic Press, London (1974) 5 Rogers, D F and Adams, J A Mathematical elements of computer graphics McGraw-Hill, New York, NY, USA (1975)

364

7 de Boor, C A practicalguide to splines Springer Verlag, Berlin, FDR (1979) 8 Lewis, J W 'Spline regression and local dependence' Department of Computer Science Report No 148, Yale University, USA (December 1978)

10 Faux, I D and Pratt M I Computationalgeometry for design and manufacture I ohn Wiley and Sons, New York, USA (1979) 11 Schweikert, D C 'An interpolation curve using a spline in tension']. Math. Phys. Vol 45 (1966) pp 312-317

12 Mehlum, E 'Non-linear splines' in Computer aided geometric design Barnhill, R E and Riesenfeld, R F (eds) Academic Press, London (1974) 13 Nielson, G M 'Some piecewise polynomial alternatives to splines in tension' in Barnhill, R E and Riesenfeld, R F (eds) Computer aided geometric design Academic Press, London (1974) 14 Hinds, J K and Kuan, L P 'Sculptured surface technology as a unified approach to geometric definition' Computer and Automated Systems Association of the Society for Mechanical Engineers MS79-146, Dearborn, MI, USA 15 CAM-iSculptured surfaces users course CAM-i International, Arlington, TX, USA (June 1977) 16 Korovkin, P P Linear operators and approximation theory Hindustan Publishing Corporation, Delhi, India (1959)

computer-aided design