Interactive Interpolation and Approximation by Bezier

Embed Size (px)

Citation preview

  • 8/12/2019 Interactive Interpolation and Approximation by Bezier

    1/9

    Interactive interpolation and approximation by BezierpolynomialsA R ForrestComputer-Aided Design Group Computer Laboratory University of CambridgeCambridge CB2 3QG

    One of the main problems in computer-aided design is bow to input shape information to the com-puter. The paper describes a method developed for the interactive interpolation and approximationof curves which has been found in pr actice to provide a natu ral interface betweenthemathematicallyunsophisticated user and the computer.(Received May 1971)

    1. IntroductionIn computational geometry th ecomputer representat ion,analysis and synthesis of shape information*) interpolation andapproximation techniques are often used for both curves andsurfaces. However, the proper ties of 'sha pe ' are different fromthe properties of functions and the well-known techniques offunctional interpolation and approximation are not necessarilysuitable. Shape is, fo rexample, anaxis indepen dent phen o-menon and vector valued parametric curves and surfaces areoften adopted for this reason alone. Indeed, param etricnotation will be used throughout this paper, both for conven-ience and toemphasise tha t the p aper isconcerned with th eapproximat ion of shapes rather than th e approximat ionoffunctions. Sometimes, but by no means always, the functionalform of a particular shape isknowna curve may be a cir-cular arc. In such cases conventional fitting techniques may beused, but in general what is required is an acceptably closefit(to within a given tolerance) which ma intains the characterof the curve or surface and is smooth or fair.

    This paper considers th einteractive design of curves,abinitio, and theinteractive approximation ofcurves. Justasmathematical techniques are modified o rdeveloped tocopewith shape, so they must be am ended when interaction betweena computer and ahum an operato r is involved.A particularlyelegant technique has been developed by Bezier (1968a, 1968b,1970) of Regie Renault. This paper develops the mathematicalproperties ofBezier's method s for interactive appro xima tion.

    In the car industry the problem is to finda mathematicalrepresentation for a stylist's clay model orsketch. The datahas two basic kinds of error: measurement error and error dueto th estylist and theinherent properties of hisworkingmedium. The former are tosome extent predictable but thelatter errors are only really apparent to the stylist himself.There is nodefinable 'bes t' fit; rather th e goodness of fitdepends onhuman judgement . It is thus logical to us eaninteractive technique because nofully auto ma tic techniquecan be expected to distinguish between the intent of the stylistand his errors and will atthe best employ ad hoc procedures.Fig. 1 shows the kind of curve data which might be encounteredin the car industry and acceptable and unacceptable (in theauth or's opinion ) solutions. In order to be useful the interactiveprocedure must be easy to apply andauser should n ot need toknow the mathematical principles involved. At Renault, datafrom a small clay model, orahand sketched curve, is plotted,full size, on a drafting mac hine. Th e stylist then e stimatesgraphically the parameters ofan ap proxim ating curve whichis then drawn by the machine. Three-dimensional curves areapproximated in two plane projections. An acceptable approxi-mation is usually achieved inafew iteratio ns by adjusting thecurve parameters.In some cases, no doubt, the stylist will do

    some redesigning as well as fitting. As smoothness is of para-mount importance the system ineffect gives the desig ner a'perfect ' medium inwhich to w ork rather than animperfectone such asclay because the shapes which are createdarebasically smooth and irregularities mu st deliber ately bedesigned.I tis much easier to createa ' bump' inacurve tha nto remove an unintended 'bump' caused by bad data .2. The basic principleA curve segment, in Bezier's method, is defined bya polygon,two of whose vertices are the end points of the arc, Fig. 2. Fora curve which is an wth degree polynomial or which is expressedas alinear com bination of (n 4- 1) linearly indepen dent func-t ions ofthe parameter the polygon has n +1) vertices. Letthe vertices be denoted by the vectors P(i), 0 < i

  • 8/12/2019 Interactive Interpolation and Approximation by Bezier

    2/9

    Fig. 2. Bezier's notationP(n)to the last side of the polygo n; in general themth derivativeat P(0) is dependent on the vertices P(0) to P(m)and the mthderivative at P(ri)is dependent on the vertices P{ n m) toP(n).There are two basic ways of defining the curvein termsof the polygon vertices, and in terms of the polygon sides. Weshall first consider the latter as it is the form used by Bezier(1968a, 1968b, 1970).Let the sides ofthedefining polygon be denoted by the vectorsa{i)where

    a{i)= P(i) - P(i - 1) 1 < / i(t) have the following pro-perties:WO) = i J.o( l) = 0 for 0 < p < n (3.3)^,n(l) = 1. *,n() = 0 for 0 < q < n (3.4)

    where the indices denote derivatives with respect to t, and for1 < i

  • 8/12/2019 Interactive Interpolation and Approximation by Bezier

    3/9

    Thus the vertex/*(//n) has its maximum influence on the shapeof the curveBeJJ;t) at the point t = i/n.The Bezier polynomials, in parametric form, are axis indepen-dent, because the polynomial interpolation functions obey theCauchy relationship:

    J.M = (3-11)(since the successive polynomial interpolation functions /,;(/)are terms in the binomial expansion of [(1 t) +/]").Because of the binomial form of the interpolation functions,there are symmetry relationships between the /,,(

  • 8/12/2019 Interactive Interpolation and Approximation by Bezier

    4/9

    /,( ) = 1, = 0, 0

  • 8/12/2019 Interactive Interpolation and Approximation by Bezier

    5/9

    initially the same shape, or a higher order curve segment,again of the same shape, may be substituted. Curve splittingis simple, mathematically, and may be advantageous where it isdesired to use only curves of up to a certain order. Increasingthe order of a curve whilst retaining the same shape is slightlymore involved. It is probably simplest to use the followingeasily proved procedure (Talbot, 1971) to increase the orderfrom n ton + 1:

    0 < / < / + 1 (6.1)Fig. 5 shows an example of increasing the order of Bezierpolynomials. Note how the higher order polygons convergetowards the curve.It might sometimes be desired to attempt to decrease theorder of the curve from n to ( 1) in order to reduce com-plexity. This is a rather more tricky procedure as some inform-ation has to be discarded. Ifnis odd, then in effect two verticesare merged, but ifnis even then the middle vertex is eliminated.In general, the reduction of degree of a curve will cause achange in shape, but the procedure outlined here is such that,in the case of polynomials at least, if the polynomial describedby an M-sided polygon is in fact a polynomial of degree lessthan n then the reduction of the number of sides from n to(n 1) will not change the shape of the curve.The two casesn even andn odd differ slightly. In both caseswe use the formulae:

    (6.2)an d

    Forn even, compute / * I\(6.3)

    n - 2from (6.2) for 0 < i

  • 8/12/2019 Interactive Interpolation and Approximation by Bezier

    6/9

    ) ( : ) * -Suppose

    an d

    are to be joined so that5/d)=7/(1)=9n(0)=7,1(0)=

    Let

    (a)

    ma n d

    . (m - 2m = r

    Then for first order continuity, in the Cartesian sense,

    whereA is a +ve scalar constant.For second order continuity, in the Cartesian sense,

    (6.5)

    (6.6)

    (6-7)

    g iiX) =w(0 ) (6.8)and for curvature continuity, /x= A2.

    Evaluating the end derivatives forg , andg n we can show: forfirst order continuity,(6.9)

    (6.10)

    (Fig. 7(a))

    (Fig. 7(b))

    and in addition for curvature continuity,

    In the casem = n, A = 1

    and- = p + 3o _ ,

    These relationships lead to simple graphical constructions for1st and 2nd order continuity. Higher order relationships can bederived but are obviously more complex. In Fig. 7(c), Fig. 7(d)I = 1,m = 3,n = 5.7 .Interactive design and approximation by Bezier methodsIt might be thought that because all the vertices of the polygoncan be re lated to the end derivatives of the curve, there is littlepoint in thu s disguising what is essentially a Taylor or Herm itetype approximation or interpolation. This is not so, for tworeasons which are connected with computational geometry. Inthe first place, as remarked earlier, when the Bezier method isused for appro ximation the polygon vertices need not be relatedto the end derivatives of the curve to be approximated but maybe selected m anually (in some interactive system); they will, ofcourse, control the end derivatives of the approximant.Secondly, for reasons of axis independence, convenient bound-

    Fig. 8. a)6th order polynomial approximated by 5th order polynomial(b) 4th order polynomial approximated by 4th order polynomialing of segments, ease of affine transformation, etc., parametriccurves are often used in computational geometry. This intro-duces problems. In a Lagrange type of interpolation, para-meter values have to be assigned to each of the interpolation

    / -x 1 -16 x-l)2)

    Fig . 9. Interactive approxim ation of functions76 The Computer Journal

  • 8/12/2019 Interactive Interpolation and Approximation by Bezier

    7/9

    -t-

    Fig. 10(a). Successive approximations toahand-drawn curvepoints and even to a mathematically sophisticated user thispresents difficulties. The shape of the interpolated curvedepends somewhat critically on the selected parametric values;automatic methods are not generally satisfactory. In Hermiteor Taylor type interpolation, parametric derivative vectorsmust be defined. The difference between the tangent and thetangent vector is sometimes difficult for users to grasp, as isthe exact role of the tangent vector's m agnitude. The difficultiesare compounded as the order of derivative increases. WithBezier's method both these problems are avoided. The userneed not consider parametric derivatives or parameter values(although the polygon vertices are associated with the para-meter values t = i/n, and control the end parametric deriv-atives) because the polygon vertices directly control the curveshape in a manner which may readily be appreciated. Withvery little experience a user can predict the shape of curvewhich can be generated by a particular polygon. Figs. 8, 9and10 show examples oftheuse of Bezier polynomials for approxi-mation. Fig. 8 illustrates the approximation of vector valuedpolynomials, Fig. 9 the approximation of other analytic func-tions (explicit, not vector valued, in this case) and Fig. 10, thesuccessive approximation of hand drawn curves, starting fromthe vector valued Bernstein approximation.

    Bezier has shown (in the English edition of his book, 1970)that the hodographs of polynomial Bezier curves can readilybe computed using the sides of the curve polygon.Given the curve

    (O

    Fig. 10(b). Successive approximations to a hand-drawn curvethen the (n l)th degree Bezier polynomial h{t)whose suc-cessive polygon vertices are

    is the hodograph oi g(t), i.e.:

    =-V (0 (7-1)n(The proof is simple and is omitted.)The hodograph provides a convenientgraphical method fordetecting points with zero curvature and points of inflexion.If a vector can be drawn from the origin tangent to the hodo-graph h(t) then there is a point of zero curvature (Fig. l l (a))or a point of inflexion (Fig. ll(b)) at the corresponding pointon git).If the hodograph passes through the origin, there is acusp at the corresponding point ongit)(Fig. ll(c)). In practicethe hodograph also provides a good indication of whether acurve under design is tending towards an undesirable shape (anunwanted flat or point of inflexion).8. Prac tical experience in the use of Bezier methodsIt is clearly evident from the decision of Regie Renault toincrease the number of its computer-controlled drafting

    Volume 15 Number 1 77

  • 8/12/2019 Interactive Interpolation and Approximation by Bezier

    8/9

    machines and numerically controlled machine tools thatBezier's meth od is well-suited to the types of problems encoun-tered at Renault.Experience at Cam bridge Universityhasbeen gained from fourBezier curve programs. Pankhurst's program (1970) is for thedesign of single curve segments of any order; polygon verticesare changed positionally by typed commands. The order of thecurve may be increased or decreased, as outlined in Section 6,and a vertex may be constrained to move along one of thepolygon sides which intersect at that vertex. Bezier's curveshave also been implemented by A rmit (1970) in his M ultiobjectsystem. Again the curve is manipulated by the typed com mandsof an interactive language and more powerful facilities areprovided. In addition, curve splitting is implemented, andmultiple curve segments may be constructed. Although intendedprimarily for design, the system can also be used for interactiveapproximation to point data. Talbot (1971) starts from anassembly of cubic spans with C continuity, each span beingobtained by a local least squares fit. Successive improvementsto the curve shape with automatic creation and maintenance ofC 1 continuity between spans are effected by moving polygonvertices.All Figures in this paper were produced by a small experi-mental program written by the author for a PDP-7 computer.Input to the program is either a data tape describing the curveto be approximated (this method was used for Figs.4(b), (c),8 and 9) or curves hand drawn using light pen (as in Fig. 10).The program computes Bezier polynomials of 2nd to 9thdegree. At present only single curve segments may be handled.The program is intended primarily for interactive approxi-mation, and unlike the Pankhurst, Armit and Talbot programs,a visual comparison between the required curve, whether hand-drawn or analytic, and the approximation is always available.As an initial approximation the vertices of the polygon areequally distributed along the arc of the curve to be approxi-mated; the initial approximation is thus a vector valuedBernstein polynomial (top curve in Figs. 10(a) and 10(6)).Thereafter interior vertices of the polygon may be repositionedby light pen with the curve distorting accordingly in real time.There ar e several shortcomings oftheauthor's program which

    must be borne in mind. Approximations are made visually andalued polynomial Corresponding hodograph

    zero curvature

    b inflexion

    c cusp

    Fig. 11. Hodog raphs of polynomial curves

    a discrepancy of less tha n 1 pa rt in 500 can not be detected.Fo r exam ple, mo st of the errors in Figs. 8 and 9 could not bedetected on thec.r.t.display but were revealed when the displayfiles were plotted. However, Bezier's system using a highresolution plotter overcomes the disadvantages of a lowresolution device. It proves difficult to draw a really smoothcurve with the light pen, and it would be reasonable to assumethat much bet ter approximat ions to hand-drawn smooth curvesthan those shown in Fig. 10 could be o btained. Surprisingly,no difficulty has been found in manipulating high ordercurves. A mu ch better initial approxim ation would be thevector valued Lagrange polynomial through points spacedequidistantly on the curve, but this has not been implementedbecause of the limited arithmetic capabilities of the PDP-7.More experience is needed in using Bezier curves in a piecewisemanner with automatic maintenance of continuity. The presentprogram has already demonstrated to the author's satisfactionthat successful approximations can readily be constructed bythe mathematically uninitiated.9. Extensions to surfacesBezier's method may obviously be extended to the interpolationand approximation of surfaces. There are three basic ways inwhich this may be achieved. The method actually employed

    Fig. 12. Typical Bezier surface and netby Bezier and others (Bezier 1968a, 1970, Armit, 1970, Sabin,1969) is the product method in which the surface is defined bya grid of points, only four of which (the surface corner points)lie on the surface, Fig. 12. In the polynomial case,

    ;= o j=o(9.1)

    A surface may also be defined by Bezier interpolation to asingle family of curves

    ( )]in a manner akin to lofting:

    (9.2)

    (in the polynomial case)Thirdly, the surface may be defined in a manner analogous tothat of Coons (Coons, 1967, Forrest, 1968) by two families ofcurves :78 The Computer Journal

  • 8/12/2019 Interactive Interpolation and Approximation by Bezier

    9/9

    = 0m n

    j = 0- 0 1

    (9.3)Of these methods the first is probably the most suitable forinteractive design.

    10.ConclusionsThe Bezier method is one of the most convenient methodsdevised for the interactive approximation ofcurves.Moreover,the method extends naturally to surface description and pro-vides a simple way of controlling surface parameters. Surfacetwist vectors which have been stumbling blocks in interactivesurface design (they are essential for doubly curved surfaces)are easily defined, in a disguised manner.It is hoped that this paper will stimulate further work both inthe field of shape description and in the field of interactiveapproximation.11.AcknowledgementsThe author is indebted to Professor Bezier, Professor W. J.Gordo n of Syracuse University, and members of the CambridgeCAD Group for criticisms of a preliminary version of thispaper.

    ReferencesARMIT, A. P. (1970). Systems for Interactive Design of Three-dimensional Shapes, Cambridge University CA D G rou p Ph .D . Thesis,November, 1970.BEZIER,P. (1970). Emploides Machines a CommandeNumerique,M asson et Cie., Paris, 1970 (to be published, revised, in English translatio nby John Wiley, London and New York).BEZIER,P. (1968a). Procede de Definition Numeriqu e des Courbes et Surfaces Non Ma thema tiques; Systeme UN IS U RF ,Automatisme13,May 1968.BEZIER, P. (1968b). How Renault uses Num erical Control for Car Body Design and Tooling,Society of Automotive Engineers, Paper SAE

    680010.COONS, S. A. (1967). Surfaces for Comp uter-Aided Design of Space Forms ,MIT MAC-TRAl.DAVIS,P. J. (1963). Interpolationand Approximation, Ginn-Blaisdell, New York.FORREST,A. R. (1971). Com putational Geometry,Proc. Roy. Soc.Lond. A. 321,p p. 187-195.FORREST,A. R. (1970a). Coo ns' Surfaces and Multivariable Function al Interpolation. Camb ridge University CA D Gro up , Docu men t No .38,July 1970.FORREST,A. R. (1968). Curves and Surfaces for Compu ter-Aided Design. Cambridge University CAD Grou p Ph .D. Thesis, July 1968.FORREST,A. R. (1970b). The Twisted Cubic Curve. Cambridge University CAD G rou p Docum ent, No . 50, Novem ber 1970.GORDON,W. J. (1971). Private comm unication, May 1971.LEE, T. N. P. (1969). Three-Dimensional Curves and Surfaces for Rap id Com puter Display, Ph .D. Thesis, Harv ard U niversity, April 1969.MINSKY,M., and PAPERT,S. (1969). Perceptrons: AnIntroduction to ComputationalGeometry,MIT Press, Cambridge, Mass.PANKHURST, R. J. (1970). Notes on Experiments with Command Languages for Graph ic Interaction. Camb ridge University CAD Gr ou pDocument N o. 37, February 1970.SABIN,M .A .(1969). A 16-Point Bicubic Form ulation S uitable for Multipatch Surfaces. British Aircraft C orpo ration , Weybridge . VTO/M S/155,March 1969.TALBOT, J. E. (1971). Experiments towards interactive graphical design of mo tor bodies. Cambridge University CAD G rou p D ocum ent

    No . 56, April 1971.

    Book reviewPicture LanguageMachines, by S. Kaneff (editor), 1970; 425 pages.{Academic PressLtd., 450)This book is concerned with pictures and with attempts to describethem in a precise language having meaning to a machine (the term'machine' implying an appropriately programmed computer). Thesedescriptions are formulated in such a way that the machine receivesessentially the same information about a picture as would anobserver viewing the picture.Generally speaking, it is the structure of a picture which carrieswhat is regarded as the important information. Thus the relativepositions of black areas in a picture is more informative than a countof the areas. In the same way, the ordering of words in a sentence,together with a notion of how such words interrelate, enables themeaning of a sentence to be conveyed. It is suggested that picturescan be regarded as two-dimensional sentences and that studies of thestructured description of natural languages, as has been proposedby Chomsky, can be adapted to the analysis of pictures.A conference held in Canb erra in 1966 drew together workers fromvarious disciplines including Picture Languages, Graphical Com-munication, Interaction Systems, Pattern Recognition, Linguisticsand Psychology in an attempt to explore aspects of these areas ofstudy which would throw light on the development of picturelanguage machines. Asisstated in the Foreword by D r. Max Clowes,the first four papers were intended to be primarily tutorial incharacter to provide an introduction to the notion of a picture

    language machine wh ereas the remaining 11papers reported c urrentresearch interests of the authors.The volume taken as a whole provides a valuable review of thisrelatively new and fast developing subject and is particularly usefulin a field where publications tend to be d istributed over a wide rang eof journals. The important discussions during the conference arereported verbatim; these discussions add useful comments to theformal papers and are effective in putting over some of the atmos-phere of the Canberra conference. The photographed typescriptis beautifully printed and the illustrations are both clear andplentiful. Academic Press Ltd. have produced an attractive 425-pagevolume at the reasonable price of 4-50. M. J. B. DUFF(London)ErrataIn Algorithm 69, Trigonometric curve fitting to equally or unequallyspaced data (thisJournal,Volume 14, Number 2, pp. 213-214) therewere a number of typing mistakes. These were all at the top of thesecond column of page 214.Line 2 should read

    we will have afull set ofcoefficientsA; .In line 11 A[mmax, mmax] should read a[mmax, mmax] .In line 16 A[k, / ] should read a[k, / ] .In line 17 A[k, k]; should read a[k, k]\Volume 15 Number 1 79