||||||||||||III USOO540.8598A United States Patent (19) 11 Patent Number: 5,408,598 Pryor, Jr. 45 Date of Patent: Apr. 18, 1995

54 METHOD FOR FAST GENERATION OF 4,943,935 7/1990 Sate ...... 364/518 PARAMETRC CURVES EMPLOYNGA 4,949,281 8/1990 Hillenbrand et al. . ... 364/518 CULA NUMB 4,999,789 3/1991 Fiasconaro ...... 395/127 SEE SEREEE 5,133,052 7/1992 Bier et al...... 395/133 X 5,214,754 5/1993 Okamoto et al...... 395/142 DETERMINED ERROR THRESHOLD saw is is 75 Inventor: Duaine W. Pryor, Jr., Berkeley, OTHER PUBLICATIONS Calif. Computer Science Press, Inc., “Algorithms for Graph s ics and Image Processing', Theo Pavlidis Bell Labora 73 Assignee: tail Rte Mahines tories, pp. 221-231., 1982. is all y o a I. D. Faux et al., "Computational for Design 21 Appl. No.: 202,678 and Manufacture', Dept. of Mathematics 1979, pp. 127-145. Publisher: E. Horwood Ltd. 22 Fed:e Feb. 25, 1994 Wolfgang Dahmen, “Subdivision Algorithms Con verge Quadratically”, 1988, pp. 145-158, Journal of Related U.S. Application Data Computational and Applied Mathimatics. 63 Continuation of Ser. No. 705,041, May 23, 1991, aban- s doned. Primary Examiner-Almis R. Jankus 51 Int. Cl6 11/00 Attorney, Agent, or Firm-Perman & Green 52 U.S.C.. 395/2,39571.43 (57) ABSTRACT 58 Field of Search ...... 395/141-143, A method enables the prediction of the number of sub 395/119, 123, 127, 133, -140, 155, 150, 151 divisions of a curve that will be required by control (56) References Cited polygons to assure that a resulting straight line repre sentation of the curve will not exceed a preset error U.S. PATENT DOCUMENTS threshold. The method is applicable to cubics and para 3,806,713 4/1974 Ryberg ...... 235/151.11 metric quadratics including , ellipses and hy 4,648,024 3/1987 Kato et al...... 364/169 perbolas. In each case, the prediction of the number of 4,654,805 3/1987 Shoup, II ...... 364/520 subdivisions eliminates the need for a detailed error 4,674,0584,760,548 6/19877/1988 LindbloomBaker et al. et...... al...... 364/518E. calculation at each subdivision8 step, thereby enabling an 4,855,935 8/1989 Lien et a 364/521 error calculation to be carried out only once in the 4,907,282 3/1990 Daly et al...... 382/9 process. 4,912,659 3/1990 Liang ...... 364/521 4,912,664 3/1990 Weiss et al...... 395/123 X 14 Claims, 9 Drawing Sheets

CUBC CURE APPROXAO

20 CREATE BEAERFOR CONTROLCRE POLYGO

SET ACCEPTANCE ERROR = AE

COPUTE ODIFIEDERROR as "m 24

DRAW LINE(S) FRO SUBDIVIDE POLYGON(S) BEGINNINGO ED EYNG TO POLYGONS FOR COORONATES OF EACH, i.e., EF AND RIGHT CONTROL POLYGONS) POYCOS U.S. Patent Apr. 18, 1995 Sheet 1 of 9 5,408,598

p2 mid p5

2 r3

POLYCON POLYCON U.S. Patent Apr. 18, 1995 Sheet 2 of 9 5,408,598

BEZIER SECOND ORDER CURVE () (10) P0 FIG. 5

O. A. PERSPECIVE PROJECTION OF A 3-D PARABOLA TO A 2-D CONIC

HREE-D PARABOLA

s c VIEW POINT Y WEW PLANE

FIG. 6 U.S. Patent Apr. 18, 1995 Sheet 3 of 9 5,408,598

11 15 12 14.

MCRO EPROM RAM PROCESSOR

13

16 17

DISPLAY CONTROL

F.C. 7 U.S. Patent Apr. 18, 1995 Sheet 4 of 9 5,408,598

CUBC CURVE APPROXMATION

CREATE BEZER CONTROL POLYCON 20 FOR CURWE

22 SET ACCEPTANCE ERROR = AE

COMPUTE MODIFIED ERROR = "m" 24

m c.

DRAW LINE(S) FROM SUBDIVIDE POLYGON(S) BEGINNING TO END YELDING TWO POLYCONS FOR CORPIASE EACH, i. e., LEFT AND RIGHT |CONTROL POLYCONS) POLYCONS 28 30 COMPUTE m / 4 32

FG. 8 U.S. Patent Apr. 18, 1995 Sheet 5 of 9 5,408,598

CUBIC CURVE APPROXIMATION (ALTERNATE)

CREATE BEZIER CONTROL POLYCON | FOR CURVE

SET ACCEPTANCE ERROR = AE

COMPUTE :

= log ( v2 max (Ix"(0)|, |x"(1), y(0),

YES

DRAW LINE(S) FROM BEGINNING TO END

SUBDIVIDE POLYCON(S) YELDING TWO POLYCONS FOR COORDINATES OF EACH, i. e., LEFT AND RIGHT CONTROL POLYCON(S) POLYCONS

COMPUTE L -

FIG. 9 U.S. Patent Apr. 18, 1995 Sheet 6 of 9 5,408,598

CONCS CURVE APPROXMATION

CREATE BEZIER CONTROL POLYCON 40

SET MAXIMUM ERROR = AE 42

DENTIFY CURWE TYPE W() > W(O) = W). KWO) = EPSE W(1) = WO) = PARABOLA

CALCULATE MODIFIED ERROR FOR DENTFED CURWE

"ellipse E O=x,yTOX (s - 2a1 + q2 + 2 wo - Wilmax (a(t)) 2(wo- w) AE

W - wo E FOX lanO - 2a1 +t q2u2 + 4 max(a(t))( w1 + wo (parabola)hyperbola dily ( - 4 AE - - -

CONTINUE AT DECISION Y BOX 26 N FIG. 8

F.G. 10 U.S. Patent Apr. 18, 1995 Sheet 7 of 9 5,408,598

CONICS CURVE APPROXIMATION (ALTERNATE)

CREATE BEZIER CONTROL POLYCON

SET MAXIMUM ERROR = AE

DENTIFY CURVE TYPE 1) > WO = HYPERBOLA W(1) { WO = ELLPSE W1) = W O = PARABOLA

CALCULATE L = LOG4 m FOR IDENTIFIED CURVE WHERE n:

?usellipse E d'EyOX (i. - 2c + l2 + 2wo - will sen) 2(w + w)AE

lan - 2a1 + qi + 4 max(a(t) W" -, W"O hyperbold 9 O t u2. w1 + wo w1 - wo yperDola driy 4A + 2 W + wo (parabola) E

CONTINUE AT DECISION BOX IN FC, 9

F.C. 11 U.S. Patent Apr. 18, 1995 Sheet 8 of 9 5,408,598

NCREMENTAL ALCORTHM FOR CUBCS INPUT: BEZIER CUBIC POLYGON, SPECIFIED BY COORDINATEFUNCION : ERROR TOLERANCE = AE

COMPUTE: (4.max (Ix"(0)|, |x"(1), y(0), ly(1)) 52 L = io94 — a

CHOOSE STEP SIZE At = 2 154

COMPUTE

56 y(0), y(0), y(0), y t(0) TO A PRECISION AE(2)

FOR (t = At TO 1, BY At INCREMENTS) COMPUTE:

x(t) = x(t - At) + x(t - A t) x(t) = x(t- At) + x(t - A t) 58 Xt(t) e Xt(t - A t) + Xtt (t - At) y(t) = y(t - At) + y(t At) y(t) = y(t- At) + y tact At) y(t) = ytt (t - At) + ytt (t - At)

DRAWx(t), y(t) LINE FOR FROM EACH x(t AtA?ia: INCREMENT - A t) TO FG, 12 U.S. Patent Apr. 18, 1995 Sheet 9 of 9 5,408,598

INCREMENTAL ALCORTHM FOR CONCS INPUTRATIONAL QUADRATIC AND ERROR TOLERANCE AE

F: CONC = EPSE THEN: COMPUTE L = log 4 (mellipse) O

IF: CONIC = HYPERBOLA, PARABOLA THEN: COMPUTE L = log 4 ("hyperbola )

CHOOSE STEP SIZE At = 2 64

COMPUTE: X(0), Xi(0), Xt(0) Y(0), Y(0), Y(0) 66 w(0), w (0), W(0) ALL TO A PRECISION AE(2)

FOR (t = At TO 1, BY At INCREMENTS) COMPUTE: X(t) = X(t - At) + X(t-A t) X(t) = X(t - At) + Xt(t.-At) 68 Y(t) = Y( - At) + Y( - A ) Y(t) = Y(t - At) + Y( - A t) w(t) = w(t - At) + w(t - At) w(t) = wi(t- A t) + w(t - At) x(t) = X(t) / w(t) y(t) = Y(t) / w(t)

DRAWx(t), y(t) LINE FOR FROM EACH x(t Atlike: INCREMENT - At)TO

F.G. 13 5,408,598 1. 2 proximate the curve with errors no larger than AE. The METHOD FOR FAST GENERATION OF curve itself is described by a control polygon consisting PARAMETRC CURVES EMPLOYING A of 4 points, p1, p2, p3, p4. Such a control polygon is PRE-CALCULATED NUMBER OF LINE shown in FIG. 1 and which also includes cubic curve 10 SEGMENTS IN ACCORDANCE WITH A is being approximated. The dimension E is the error and DETERMINED ERROR THRESHOLD defines the distance between the chord p1-p4 and the apogee of curve 10. If E is greater than AE two more This is a continuation of application Ser. No. polygons are constructed from the original polygon, 07/705,041, filed on May 23, 1991, now abandoned. with the property that curve 10 lies within each new FIELD OF THE INVENTION O polygon, and that each new polygon is the control poly gon for the part of the curve which it contains. This This invention relates to computer graphics, and subdivision proceeds recursively. more precisely, to a method and apparatus for rapidly An iteration of this subdivision process has three generating curves on a computer display. stages. The first stage is indicated in FIG. 2 wherein the BACKGROUND OF THE INVENTION 5 following values are found: Computer graphics employ a number of techniques to reproduce curved lines and surfaces. One commonly used technique involves producing a set of points and connecting those points with straight lines to approxi 20 n = p 2 mate the curve. The curve is successively divided into smaller pieces and then checked to see if each piece can be approximated by a straight line to within a given mid = 2 P error threshold. It turns out that the check of the accu r4 = p4 racy of the approximation is the dominant part of the 25 cost of executing the curve approximation algorithm. r3 = p P3 In a two-dimensional space, a curve is often expressed 2 as a function of orthogonal components x and y, i.e., y is equal to f(x). In a three-dimensional coordinate sys The second stage of the calculation is shown in FIG. tem, the x, y and z coordinates may also be represented 3 and shows the derivation of points 13 and r2 as fol as functions of one or two of the orthogonal compo 30 lows: nents. However, these representations may cause diffi culty in generating the coordinate values. One alterna i2 + mid tive technique is to use a parametric representation of 3 2 the curve or a representation where each coordinate value on a curve is represented as a function of some 35 r2 = 3 ind common variable, that is, a variable common to all coordinate components. For a three dimensional sys ten, such a variable may be described as t resulting in The third stage involves the derivation of points 14 the following: x=f(t); y = g(t); and z=h(t); for 0

By rewriting the above quantities in terms of the deriva 15 tives of y it can be seen that ytt is constant with respect Suppose the values of the coordinate functions are to t. Now, to get y(t+At) simply add y(t)--y1(t), con known for some to and it is desired to know them for tinue in this fashion and compute y(t--At) in order to some other value to--At. Define make the next step forward by At. This leads to the following algorithm for generating coordinates. 20 o choose. At = for some in o compute y(0), y(0), yi(O), x(0), x(0), x(0) 25 for( -- to by .)

By rewriting the above quantities in terms of the deriva tives of X and y, it can be seen that Xtt and yttr are con stant with respect to t. Now, to get x(t--At) add x(t)+x(t). To continue in this fashion, compute x(t--At) in order to make the next step forward by At. Similarly, xt must be updated. This leads to the follow 35 ing algorithm for generating points of the curve.

o choose At = for sonner

e compute x(0), x0), x0), x(0) o compute y(0), y0), y0), ytt0) This may be extended to an algorithm for rational qua dratics in the same way the subdivision algorithm was. 45 Namely, the above algorithm which works for a coordi nate function is applied to the numerator, CX(t), Y(t)) for ( -- to 1 by .) and the denominator, w(t), and then divide to get the result. Both prior art incremental algorithms suffer from x(t) - (-i)+ i. ( – ) 50 similar problems which will be explained using cubics as an example. The incremental algorithm is more efficient than subdivision, but is also numerically ill-conditioned x(t) - (-)-(-) in the sense that errors in yatt grow cubically with the number of steps taken. That problem can be skirted, to 55 some extent, by calculating yt to high precision, how ever, precision grows cubically with the number of xt(t) = -(-h)+ t ( -) steps. The proper choice of value for At is a more diffi cult problem. One approach to solving this problem is adaptive subdivision which varies the size of At based upon the distance moved in the last step. This makes the x) - (-): (-) function more expensive and more complicated. While the Bezier subdivision technique has been de scribed above, other derivations employ the Hermite y(t) -, (-i)+...( – ) form and the B-spline form, which forms are also con 65 sidered in the above cited texts. In U.S. Pat. Nos. 4,760,548 to Baker et al, 4,912,659 to Liang 4,949,281 to yo-y(-i)+y+(-) Hilenbrand et al. and 4,907,282 to Daly, various aspects of B-spline curve approximation techniques are de 5,408,598 7 8 scribed. In U.S. Pat. Nos. 4,674,058 to Lindbloom et al. ticularly applicable to cubics, conics, quadratics, and and 4,943,935 to Sato, Bezier calculations are described other high order curvilinear equations. for curve approximation. All of the aforedescribed pa tents either precalculate the curve approximations and SUMMARY OF THE INVENTION then store the results for subsequent display or calculate A method is described which enables the prediction error values as the curves are being constructed. of the number of subdivisions of a curve that will be In U.S. Pat. 4,855,935 to Lein, the problems inherent required by control polygons to assure that a resulting in recursive subdivision methods are recognized and it straight line representation of the curve will not exceed is suggested that a technique called "forward differenc a preset error threshold. The method is applicable to ing' (advancing along a parametric curve or surface in 10 cubics and parametric quadratics including parabolas, constant parameter increments) be utilized to more ellipses and . In each case, the prediction of efficiently generate the curve. This adaptation is per the number of subdivisions eliminates the need for a formed by transforming the equation of the curve to an detailed error calculation at each subdivision step, identical curve with different parameterization, such thereby enabling an error calculation to be carried out that the step sizes increase or decrease so that the curve 15 only once in the process. proceeds in substantially uniform increments. DESCRIPTION OF THE DRAWINGS In U.S. Pat. No. 4,648,024 to Kato et al., curved lines (circles) instead of straight lines are employed at the FIGS. 1-4 illustrate the prior art Bezier subdivision lowest level of approximation for the algorithm. Other of a curve to enable representation of a curve by prior art concerns itself with the construction of curves 20 straight line segments. that can be parameterized by arc length, i.e., a curve FIG. 5 illustrates a prior art Bezier subdivision of a whose points, at equally stepped times t, are separated second order curve (parabola). by a constant function or distance along the curve, (e.g. FIG. 6 illustrates a perspective projection of a 3-d a circle). Such a system is shown in U.S. Pat. No. parabola onto a viewplane to obtain a 2-d conic. 25 FIG. 7 is a high level block diagram of a data process 4,654,805 to Shoup, II. ing system for carrying out the invention. In U.S. Pat. No. 3,806,713 to Ryberg, a curve approx FIG. 8 is a high level flow diagram of the method of imation system is described for curves having a rota the invention as applied to a cubic curve. tional axis. Ryberg's system is based on an error in ap FIG. 9 is a high level flow diagram of an alternate proximation of a circle by a line. Ryberg does not at 30 method of the invention as applied to a cubic curve. tempt to overcome the error calculation problem men FIG. 10 is a high level flow diagram showing the tioned above by determining, in advance, the number of application of the invention to a conic curve. straight line segments that will be required to approxi FIG. 11 is a high level flow diagram showing a modi mate the curve. The length of each straightline approx fication to the method of FIG. 10. imation is expressed by Ryberg in terms of the number 35 FIG. 12 is a high level flow diagram showing an of steps along the rotational axis of the curve, for each application of the method of the invention to an incre straightline approximation. That value is determined by mental algorithm for approximating a cubic curve. multiplying the total number of steps to be taken along FIG. 13 is a high level flow diagram showing the the rotational axis times a function that results from application of the method to an incremental algorithm dividing a predetermined maximum error in the number for the approximating a conic curve. of steps to be taken along a radial axis, by the total number of steps to be taken along the radial axis for a DETAILED DESCRIPTION OF THE given curve. While Ryberg's procedure is useful for INVENTION curves that can be parameterized by arc length, he does As indicated in the Background of the Invention, in not teach any method for more complex curves that do 45 the process of subdividing a curve into smaller segments not lend themselves to such parameterization. and checking to see if each segment can be approxi Recently, it has been proved by Dahmen that subdivi mated by a line to within a given threshold, substantial sion algorithms used to reproduce curves converge in a computation time is taken up at each subdivision by the quadratic fashion. In specific Dahmen found that the calculation of an error function. When it is realized that class of subdivision algorithms that includes Bezier 50 each subdivision creates a tree wherein the next level of subdivision, converges quadratically. This is equivalent subdivision doubles the number of control polygons, it to the statement that at some indeterminate point in the can be seen that error calculations greatly hinder the subdivision algorithm, the error E began to reduce in curve approximation procedure. As further indicated in size by a factor of approximately 4 at each division step. the Background, Dahmen has determined, theoreti See "Subdivision Algorithms Converge Quadratically', 55 cally, that at some point in the subdivision procedure Dahmen, Journal of Computational and Applied Math the error decreases by a factor of four at each subse ematics, Vol. 16, 1986, pp. 145-158. While Dahmen's quent subdivision. results indicate that widely used subdivision algorithms It has been found, for a curve which can be expressed do have a convergency, he does not indicate at which as a cubic, that the reduction in error by four occurs stage that convergency occurs and at which point in the generally after the second subdivision. Also, the largest subdivision process the error begins to be divided by a contribution to the error function occurs as a result of factor of 4. attempting to simulate a complex curve with a straight Accordingly, it is an object of this invention to pro line, and arises from the fact that a straight line cannot vide an improved method for approximating a curve approximate the second derivative of the curve. It has through the use of straight lines, and to reduce the 65 been further determined that the number of subdivisions number of error calculations. of control polygons to simulate a curve within a certain It is another object of this invention to provide an error tolerance can be predicted by carrying out an improved curve approximation algorithm which is par initial error computation and then dividing the found 5,408,598 9 10 error by a factor (e.g. the value 4) an integer number of right polygon (box 30). The value of m is then divided times until the resultant error is less than a predeter by four and tested to determine if its new value is less mined value. The number of times the error function is than or equal to one. If not, the process repeats until the divided is then equal to the number of subdivisions that condition set in decision box 26 is met. need to be accomplished. As a result, the required num It can thus be seen that the modified error calculation ber of subdivisions is then known. This allows the re need only be made once, after which, the value of m is quired number of control polygons to be constructed, divided subsequent to a next subdivision and the effort and thus gives the starting and end points of the straight repeated until the error condition is met. As a result, lines to simulate the curve. No further error function sufficient polygons are generated to meet the error calculations are required. O condition without requiring additional calculations of The method of this invention can be carried out on a the error function. In effect the number of control poly personal computer-sized data processing system, such gons to be used is equal to 2, where n=the number of as is shown in FIG. 7. The firmware for carrying out modified error values calculated. the method is stored in electrically programmable read The following is a pseudocode listing for the proce only memory (EPROM) 11. The operation of the sys 15 dure shown in FIG. 8. tem is controlled by microprocessor 12 which commu Input is a Bezier cubic with its control points, and an nicates with the various elements of the system via bus error tolerance, AE 13. A curve's coordinate points are stored, for instance, Derive the second derivatives of the coordinate func on disk drive 14 and are transferred into random access tions at the end of points of the cubic. memory (RAM) 15 when the curve approximation and Compute the Modified Error, display method is to be performed. Once the required number of control polygons has been determined, the coordinates of the beginning and end of each control polygon are employed by display control. 16 to con struct a curve approximation that is then shown on 25 display 17. where the primes denote differentiation. The procedure has been found applicable to not only Call the subdivision routine subdivision (cubic, m) curves described by a cubic function, but also to ra End procedure processcubic tional quadratics (i.e. conics, ellipses, parabolas, and Begin procedure subdivision (cubic, m) hyperbolas) and further to incremental algorithms for 30 If nS 1, draw a line from one endpoint of the poly simulating curves. Hereafter, the algorithms for both gon to the other. Bezier subdivision and incremental subdivision will be Otherwise, described, followed by a proof section which substanti Subdivide the polygon as in the prior art, yielding two ates the illustrated relationships. polygons, Left Polygon and Right Polygon. 35 BEZIER SUBDIVISION FOR CUBICS call subdivision (Left Polygon, m/4) The algorithm takes as its input, a cubic curve speci call subdivision (Right Polygon, in/4) fied by its control polygon (as indicated in the back end procedure subdivision ground of the invention and with respect to FIGS. 1-4). An alternative procedure (see. FIG. 9) for accom An error tolerance AE is specified and is the maximum plishing the same result as above described is as follows: error which the user is willing to tolerate in the curve Input is a Bezier cubic with its control points, and an approximation. error tolerance, AE Referring to FIG. 8, a flow diagram illustrating the Derive the second derivatives of the coordinate func algorithm is shown. Initially, the Bezier control poly tions at the end of points of the cubic. gonis provided for the curve (box20) and the maximum 45 Compute a value error AE is selected (box22). A modified error in is then calculated by the equation shown in box. 24. It will be noted that the numerator of that equation is the maxi L = Log4 7 \ 2 max(|x"(O), Pl y'O), y'(1)) mum of the second derivatives of the x and y coordinate functions at the beginning and end points of the curve. 50 It turns out that the maximum second derivative value where the primes denote differentiation. will always occurat either the beginning or end point of Call the subdivision routine subdivision (cubic, L) the curve, so by testing for the maximum second deriva End procedure processcubic tive at those points, one is able to derive the maximum Begin procedure subdivision (cubic, L) second derivative coordinate function for the curve. 55 IfLs 1, draw a line from one endpoint of the polygon The numerator result is divided by the maximum to the other. error AE and the quotient multiplied by a constant TV2 Otherwise, to derive the modified error m. The constant 7V2 as subdivide the polygon as in the prior art, yielding two sures that the modified error m does not affect the cal polygons, Left Polygon and Right Polygon. culation, substantially, until after approximately the call subdivision (Left Polygon, L-1) second subdivision. The modified error m is then tested call subdivision (Right Polygon, L-1) (decision box 26) to see whether its value is less than or end procedure subdivision equal to one (i.e. if the real error is less than or equal to The value of log4 (x) can be easily calculated by shift AE), and if it is, a line is drawn from one end of the ing. When L= log4(m) is computed, where n is the control polygon to the other since the error limit has 65 modified error, what is desired is that L= the smallest been reached. If not, the polygon is subdivided (or if positive integer which is not greater than log4(m). It is this is a subsequent step, the polygons are subdivided) also known that m) 1. So, m may be computed as foll leaving, for each subdivided polygon a left polygon and lows: 5,408,598 11 12 if mC4, then L=1; required to achieve the desired error is determined by otherwise: L= 1 the number of divisions by 4 required to reduce the while (m24) m= m/4; L = L-1 value of m to less than or equal to 1. return (L) The following is a pseudocode listing for the proce This computes L by successive shifting since division by 5 dure shown in FIG. 10: 4 is equivalent to right shifting by 2. begin procedure processconic (conic, Ae) BEZIER SUBDIVISION FOR PARAMETRIC input is a conic specified as a rational quadratic, m and an error tolerance, Ae RATIONAL QUADRATICS (CONICS) if the conic is an ellipse, compute m= mellipse As will be remembered from the Background section, 10 if the conic is an hyperbola, compute m=mhyperbola the coordinate functions for a rational quadratic are call the conicsubdivision routine conicsubdivision expressed as a fraction having quadratics in the both (conic, m) denominator and the numerator. If x(t), y(t) are the end procedure processconic coordinate functions of the conic, it will be recalled (for begin procedure conicsubdivision (conic, m) ease of expression) that the x(t) function in the numera 15 ifms 1, draw a line from one endpoint of the conic to tor and denominator, is defined as X(t)/w(t). Similarly, the other. the expression for y(t) is simplified by letting its numera otherwise, subdivide the conic as in the prior art tor and denominator respectively equal Y(t)/w(t). The section, yielding two polygons, LeftConic and value of AE is then chosen as the maximum error to be 20 RightConic. tolerated in the approximation. In the following equa call conicsubdivision (LeftConic, m/4) tions, 'a' can represent either xory, as the case may be. call conicsubdivision (RightConic, m/4) end proce Two quantitites are defined in terms of X, Y, w. The dure conicsubdivision modified errorm for an ellipse and a hyperbola (parab An alternative procedure (see FIG. 11) that accom ola) are as follows: plishes the same result as above is as follows: 25 begin procedure processconic (conic, Ae) rhyperbola - max woaomawa-no-no - 2a1 + a2 + 2wo - w imax(a(t)) input is a conic specified as a rational quadratic, m a = x,y 2040 - w)AE and an error tolerance, Ae if the conic is an ellipse, compute L= Log4.mellipse w1 - wo max a0 - 2a1 + a2 + 4max(a(t)) w -- wo 30 if the conic is an hyperbola, compute L= Log4m hyper mellipse = a = x,y 4AE bola call the conicsubdivision routine conicsubdivision 2 w1 - 40 (conic, L) w -- wo end procedure processconic begin procedure conicsubdivision (conic, m) To determine if a particular curve is an ellipse or a 35 if LS1, draw a line from one endpoint of the conic to hyperbola, the values of woand w1 are compared. It will the other. - be recalled that a rational quadratic has, for its begin otherwise, subdivide the conic as in the prior art ning and end coordinates, three coordinate functionsX, section, yielding two polygons, LeftConic and Y, and w, with w being a “weight' or third dimensional RightConic. value which determines in which direction the curve is call conicsubdivision (LeftConic, L-1) "pulled' and vice versa. If wo and wi are the beginning call conicsubdivision (RightConic, L-1) end proce and end coordinate point weights, whether a curve is a dure conicsubdivision hyperbola, ellipse or parabola can be determined from the following (The hyperbola modified error function is INCREMENTAL ALGORTHM FOR CUBICS used for parabolas). 45 As indicated in the Background, incremental algo rithms are also used to approximate curves. Such algo w>wo=hyperbola rithms start at one end of the curve and successively step along the curve by a predetermined amount and at w1

7 W2 max(|x"(0)|, |x"(1), y'(0),y'(1)) L = loga. AE 25 choose step size At=2-L. compute x(0), x(0), x(0), xit(O) to a precision draw line from x(t-At), y(t-A) to x(t), y(t) AE2-E end procedure processconic compute y(0), y(0), yt(0), ytt(0) to a precision PROOFS AE2-L. 30 for (t= At to 1, by At increments) (1) Proof of correctness of the bound for cubics This section gives a proof of the correctness of the bound on the depth of the cursion which is necessary to make the algorithm work. 35 Dahmen proved Journal of Computational and Ap plied Mathematics 16(1986) 145-158 "Subdivision algo rithms converge quadratically' that a class of subdivi sion algorithms which includes Bezier Subdivision con verges quadratically and that this bound is tight in the sense that no cubic bound is possible. Using this result, along with several computations, a formula has been found for an upper bound on the depth of the tree neces sary to subdivide to a given error threshold. Further draw line from x(t-At), y(t-A) to x(t), y(t). more, this formula is readily computed (requiring 13 end procedure processcubic 45 additions, 6 shifts, 3 compares and a variable number of shifts which is less than half the word size.) and needs to INCREMENTAL ALGORTHM FOR CONICS be computed only once, using quantities available be In lieu of using the Bezier subdivision for conics, an fore the subdivision starts. incremental subdivision technique can be employed. In Dahmen's result, is an estimate for the distance of the this instance, the modified error expressions for both 50 control points from the curve in terms of a constant, the ellipses and hyperbolas are utilized, as above described. granularity of the partition of the time variable, and the With reference to FIG. 13, a rational quadratic and second derivative. The general form of his Theorem 2.1 error tolerance AEare input (box. 60). Then, if the conic gives an estimate of the form is determined to be an ellipse, L is computed as shown in box 62 using the modified error equation shown in 55 box 46, FIG. 6. If, on the other hand, the conic is deter mined to be a hyperbola, then L is computed, as shown Where Sd-P(td) is the distance between the control in box 62, using the equation shown in box 46, FIG. 6. points and the curve, evaluated at a point which is the At this point, the number of increments required to average of neighboring partition points. 8 is a measure achieve an error tolerance AE is known. Thus, knowing of the granuality of the partition, and P' is the second the value of L, the number of steps chosen are 2, and derivative of the curve. If oo is the Loo norm of the the step size. At is chosen as 2-E (box 64). function, f. k is the order of the curve. Ci is a constant At this point, the procedure continues, as in prior art which depends only onk. A special case of this result is incremental algorithms, and computes the values shown needed where 6 is a (negative) power of 2, since the in box 66. Subsequently, the specific increments and 65 subdivision can be thought of as evaluation of points on their weights are derived as shown in box 68, and the the curve for t equal to multiples of some power of 2. requisite lines drawn. Due to the fact that cubics are considered, the LHS can A pseudocode description for this procedure follows: be thought of simply as the distance from the control 5,408,598 15 16 points to the curve. This special case result is assumed To estimate moland m11 the following fact is used with this interpretation. together with the exact form of the transformation be If C is known, then it can be found exactly how far tween the B-B basis and the power basis and the relation the iteration will need to go. Dahmen's proof does not, of the coordinates of the power basis to the derivatives. however generate a value for Ck. The proof relies on 5 For Osa (b. the fact that the basis for the subdivision is uniformly stable and uses the uniform stability inequality as the starting point. In fact, a careful reading of the proof f reveals that Ck is exactly the reciprocal of the constant PPMax P0(O)llo )- 19f -1 (ii;a ... b ( b -2 a ) which appears in the uniform stability inequality. So, an 10 upper bound on Ck=m is computed where where T-10) is the ith derivative of the n-1th Cheby shev polynomial, and p is the n dimensional vector space of all polynomials of degree less than n-1. In this Xribir ) 15 special case, this formula becomes n-mr ( Note that uniform stability of a basis is the same as m being finite and for the purposes of the proof, will be i. –f4)-|Poo T(1)Dry + 2pi taken as the definition. The control vector r has k-1 20 components and the norm on the space of control vec Suppose a third degree polynomial, P(t). Call its co tors is given by, ordinates in the B-B ri and its coordinates in the power basis ai, then, Biare some basis functions for the polynomial space. So, 25 r0=ao the XrBi is an element of the polynomial space with control vector r. Note that control points are simply r1 = a1--ao coefficients in a basis. They are called control points a0=P(O) because they also have some geometric significance. That element is called P. In this case, the Bi are the 30 Bernstein-Bezier (hence called B-B) Basis functions for polynomials of degree 3. It can be seen, now that mol= 1

PO) mo- - i =- mist IPIro )-= m. ( P.I. )- T3(1) = 1 The argument for m11 is more involved. Pick some cubic polynomial, P, with coordinates r in the B-B basis and a in the power basis. So, m measures how small the sup norm of the function can get when the control points are made small. deBoor 1. calculates the value of m for the power basis. The calcu -la--, is + -it- +--- lation of m for the B-B basis will follow his closely, but 45 ||P. T. P. 3 IP P. will have some differences which exploit features of the B-B basis. deBoor shows that an equivalent formula for 43 - IP 2 - + -i-P. m is Since this inequality is valid for every polynomial in the space, it must be valid for the maximum over all polyno ) 50 mials in the space.

The following quantitites may be defined 55 a?-fillV ||P. )sJ. "V3m(+ ||P.|PO) PO)P. ):J. m = m(III ) V Pll r(+V 3 |P(O)|| Pll )- (V |||PO) Pll ) So that m-1=maximi-1 Now consider the B-B basis 60 So, under the reparameterization as t goes to 1-t. This exchanges ro with ra and r1 with r2 but leaves the image of the curve (and hence its sup norm) unchanged. From r <-- T. 18 this it can be concluded that m -TA)- 4 to 2 + r() --- + 1-7 65 mol=m3 At the end of this calculation, the desired result is, In 1 -1-=m2 5,408,598 17 18 This may or may not be the best bound. However another calculation yields C323.5. The difference in the upper and lower bounds is a factor of 2. Since a factor of 4 in C3 is required to double the average execu- 5 (2) Derivations of the ending conditions for rational tion time for the algorithm there is little to gain from quadratics (conics etc.) tightening the bound. This section is devoted to calculating formulae for Now that an upper bound on C3 has been found, a ending conditions for conic subdivision. In para 2.2 a calculation is needed to get the precomputable ending simple test at each iteration is shown to be an ending condition. If Dahmen's result is rewritten using the 10 condition. In para 2.5 a uniform bound on the depth of upper bound, subdivision necessary for a given ellipse is derived. This bound is a worst case estimate for the ending condition |Ss-P(ts) is 782 P'o in 2.2. In para 2.6 a similar bound is derived for hyper bolae. In the next subsection, a bound is generated on So, if it is required 15 the error in a straight line approximation to a parametric quadratic after Bezier subdivision is carried out to a SS-POts)SA depth of n. This will be used in later paragraphs to derive an ending condition and a bound on the maxi This can be accomplished by requiring mum possible depth of the tree for the subdivision of 20 rational parametric quadratics. 782+|PVs A (2.1) Prerequisite Calculations Consider the Bezier quadratic coordinate function then the following is needed

6 s -7 * TAT-||P. 25 Now, consider the error made in approximating this curve for 0

Aeta = \ A - A. Take the Taylor expansion of c(t) about t=0 and calcu 40 late If the Euclidean error is bounded by AE, Ax and Ay must be bounded by Now, let 1(c) and r(c) be the curves produced by 45 subdividing c. The arguments for right and left side are mem.2 AE. identical, so only the left side will be shown. So,

This gives a formula 1 in terms of the Euclidean error E(l(c), t) (21(c)1 - (c)o - (c)2); which is acceptable in the rasterized curve. 50 E(I(c), t) E(r(c), t) -its Hence, with each subdivision, pointwise error is re 2 s SigriAE duced by a factor of four. This is also true of the worst 55 CaSe eTO. Since P is assumed to be a cubic, P' is a linear func So, for a Curve, c(t), lets (c)(t) denote n applications tion and hence must take its maximum and minimum of either r or 1 to c(t). Hences (c)(t) is short hand for values at the endpoints of its interval of definition. This any of the curves which appear at depth n in the tree. In gives order to simplify the notation, lets(c) denote the par ticular segment at depth in which is being tested for termination. This corresponds to lettings take on spe cific value. For example, s2 takes the values r1, rr, lir, and re 7 11. The pointwise error after n subdivisions is 65 which is the precomputable ending condition. In the most often used special case, of AE=3, the following The largest absolute value of the error occurs when results t=2 so, 5,408,598 19 20

If the curve for 0

rt wo 2wo - w max(s"(a)(i)) Es(a),t) is (+) ( min(s(w)(i)) ) In order to make this more computationally tractable, weighted points where X=xiwi, Y=yiw which then 25 the fact that max(s(a)(t)s max(a(t)) is used and re project down under perspective projection to the cor sults in rect answer. Each of these coordinate functions behaves like c of the previous paragraph. Let A denote X or Y and let a denote x or y respectively so the argument E(s(a),t) is asK need be given only once. 30 (s(a),t) (+) min(s(w)(t)) The curve may be reparametrized in order to get wo=w2. So using equation 2 it can be concluded that where for approximation by the legs of the triangle, K = a0 - 2a1 + a + 2wo - wimax(a(t)) E(s"(A), t)=(A)(2a1 wi-woao-woa2); 35 4. and is precomputable before any subdivision begins. Since the control points of s(w)(t) are known at each Now, translate so that a lands at 0. In this new coordi iteration, and are a weighted average of two quantitites, nate system, a0 becomes ao-a1, a1 becomes zero, a2 an estimate is derivable for min(s(w)(t)) at each itera becomes a2-al, so the error bound for s(A)(t) becomes 40 tion by using the smallest control point. E(s"(A), t)=(A)"wo(2a1-ao-a2); Suppose that it is wanted to ensure that E(s(a),t)Sb. This can be done by ensuring that the right hand side of For approximation of an ellipse by the base, equation 4 is less than b. With rearrangement, the check 45 for termination becomes E(s"(A), t) s(x) two.2a1-ao-a2 (+) is min()() recall that for an ellipse, woew1, 50 (2.4) Error in a fraction which takes one shift and one comparison at each node Suppose the two quantities, X--Ax and y--Ay. x and to compute. y are the true values while Ax and Ay are errors in the Up to this point, ellipses and hyperbolas have been quantities. What is then the error in the quotient of the treated together. However, in order to prove that this is two quantitites. Algebra gives. 55 a good bound and to derive a formula to precompute the sufficient depth of a uniform tree, each case must be 2 EA- - 2 = PA = A. analyzed separately. J - Ay Jy yO -- Ay) (2.5) Precomputable Bound for Ellipses For ellipses, it can be shown that such an estimate generates a for Applying this formula to the problem, i.e. letting 60 mula for the sufficient depth of a uniform tree. This is x=s(A)(t) and y=s(w)(t), the following results done using the fact that for ellipses, wood wi and

s"(w) 2 -40 - w 65 where s(a)(t) = -its s the desired curve. Beginning with formula 3, plugging in the bounds for ellipses, and applying the above facts, along with the Dividing top and bottom by s(w)(t) fact that s(a)(t)s max(a(t)) the following results 5,408,598 21 22

(n-1) 2 4. E(s(a),t) s fl-(4 ) ( --wO -- w Iana0 - 2a1 + a2 + wO -- w po)

If it is required that E(s(a),t)Sb, any n satisfying -continued

in 2 log4 (s a0 - 2a1 -- 3. - wimax(a(t)) ) 10 4 4(n-1)- 8. (wo -- w1) (+) |ao - 2a1 + a2 t + s(a)(i) t will do. So, for an ellipse, the ending condition will 4 - 2 - -w1 - -- - wo - never generate a tree deeper than the bound given in the previous equation. Hence subdividing uniformly to that 15 So with rearrangement,

a0 - 2a1 - a - EG'(a), s? 4'-2' to (ecial -- spotis)t depth will also generate an accurate curve. (2.6) Precomputable Bound for Hyperbolas In this section a precomputable bound for hyperbolas Requiring E(s(a),t)

65 displaying the approximated curve on a computer dis play, whereby a display delay time for the step of dis playing is related to an execution time for the computer graphics method. 5,408,598 27 28 14. A computer graphics system for approximating a it exceeds AE and if yes, modifying said error value curve having beginning and end coordinates by a series that was calculated by a factor and testing said of connected straight line segments, said system em modified error value to determine if said modified ploying a recursive subdivision procedure for said error value is greater than AE, and if yes, again curve and control polygons to accomplish subdivision 5 modifying said modified error value by said same of said curve, each control polygon having at least a first straight line segment extending between two coor factor and repeating said testing, said modifying dinates on said curve and additional connecting line being repeated on a last modified value by said segments to create a closed plane figure, a maximum means for calculating until a new modified value is distance between said first straight line segment and said 10 equal to or less than AE; curve defined as an error value, said system including a means for establishing 2 control polygons between stored error value threshold AE, said system compris said beginning and end coordinates of said curve, Ing: where n equals a number of error values calculated means for establishing a control polygon whose first by said means for calculating; and straight line segment has terminal vertices coinci 15 means for creating an approximated curve by joining dent with beginning and end coordinates of said said first straight line segments of each of said 2 curve; control polygons and displaying the approximated means for calculating an error value for said control C.We polygon and testing said error value to determine if 20

25

30

35

45

50

55

65 UNITED STATES PATENT AND TRADEMARK OFFICE CERTIFICATE OF CORRECTION PATENT NO. : 5,408,598 DATED Apr. 18, 1995 INVENTOR(S) : Pryor, Jr

It is certified that error appears in the above-indentified patent and that said Letters Patent is hereby Corrected as shown below: In Column 24, line 69, the expression reads "y(0)=y (to-Alt)-y(t),". It Should read --y(0)=y(to-At)-y(t),--.

In Column 25, line 20, before the expression insert --mellipse = In Column 25, after line 62, insert the expression --Xtt (0)=x(0) (totAt)-X t O) (t 0) In Column 26, line 54, the expression reads "X(0)=x(0) (t +At)-X (O) (to)". It Should read --X (0)=x(0) (totat)-x(0) (tO)

Signed and Sealed this Eighteenth Day of July, 1995 Attest: (a (eam

BRUCE LEHMAN Attesting Officer Commissioner of Patents and Trademarks