AN ACCURATE ALGORITHM FOR RASTERIZING ALGEBRAIC CURVES

12
AN ACCURATE ALGORITHM FOR RASTERIZING ALGEBRAIC CURVES Gabriel Taubin IBM T.J.Watson Research Center P.O.Box 704 Yorktown Heights, NY 10598 Abstract In this paper we introduce a new algorithm for ras- terizing algebraic curves, and we discuss applications to surface and surface-surface intersection rendering and visualization. By rustm”zing an algebraic curve we mean to determine which cells, or pixels, from a square mesh of cells in the plane, are cut by a curve represented as the set of zeros of a polynomial in two variables. By using a recursive space subdivision scheme, the prob- lem is be reduced to testing whether the curve cuts a square or not. Other mwearchers have followed this approach, but their tests are either computationally ex- pensive, or apply just to special cases. Curves with singularities are particularly difficult to deal with, and most know algorithms fail to nmder these curves cor- rectly. Our contribution in this paper is the introduction of a computationally effiaent and asymptotically cor- rect test, which applies not only to dimension two, but also to dimension time and above. We prove that the recursive space subdivision algorithm based on this new test renders a curve of constant width, even in neighborhoods of singular points, and with no missing parts. For example, if ~ is a polynomial, it produces the same results whether the coefficients of ~ or ~z are given as input to the algorithm. Not many algorithms satisfy this property. Finally, the same methodology can be applied to compute a set of voxels containing an algebraic surface, and by representing it as a sin- gular surface, space algebraic curves (surface-surface intemections) can be approximated as well. We show examples of these applications. This sets of voxels can be used for tolerance analysis and to compute polyhe- dral or piecewise linear approximations of the curves or surfaces for interactive nmdering purposes as well. Permission (o copy without fee all or pan of this material is granted provided {hal the copies are not made or distributed for direct commercial advantage, the ACM copyright notice and the title of the publication and its date appar, and notice is given that copying is by permission of the Association for Computing Machinery. To copy otherwise. or to republish, requires a fee arrd/or specific permission. 2nd ACM Solid Mcdeling ‘93-5/93/Montreal. Canada @ 1993 ACM 0-89791 -584 -4/93/0005r022 1...$1.50 1 Introduction Planar curves can be rvpmsented parametrically or implicitly. A parametric curve is the image set of a two dimensioml vector function of one variable {(z(t), y(t)) :t6 R}, while an implicit curve is the set of zeros of a function of two variables Z(f) = {(z, y) : ~(z, y) = 0}. Very efficient methods exist to render several families of parametric curves, but im- plicit curves are difficult to render. Since a local parameterization always exists in a neighborhood of a regular point of an implicit curve, i.e., a point p = (u, v) such that f(p) =O and V~(p) # O, one approach that several reseamhers follow, called tracing, is to approximately parametrize the implicit curve, and then render it using the methods for para- metric curves [1, 2, 3, 4, 13, 19, 20, 27, 28, 30]. The basic difficulty with this method lies on the fact that implicit curves can be multiply comected, and often have singular points (where f(p) = O and Vj(p) = O), where they intersect themselves, or split into several branches. To render the curve correctly, the singular points and the comected components must be identi- fied [8, 9]. The problem with this approach is that the algorithms are intrinsically complex, computatiomlly expensive, and can only deal with curves with isolated singularities. In order to find all the singular points, all the solutions of a system of polynomial equations have to be found. Tracing algorithms follow a bottom- up approach, while recursive subdivision algorithms follow a top-down approach. Somewhere in between is a family of algorithms that compute piecewise lin- ear approximations [5, 7, 11, 14]. They am based on a single teselation of the initial box into a regular mesh of cells, triangles or squares in the plane, and cubes or tetrahedra in space, and a marching cubes [22, 10, 21] type of algorithm to move from a;occupied cell to a neighboring one. Inside an occupied cell the curve is approximated by a straight line segment, or a polyhe- dron in the spatial case. There am two basic problems with this kind of approach. The first problem is how to choose the resolution of the mesh. The second problem is how to find an occupied cell to start the marching 221

Transcript of AN ACCURATE ALGORITHM FOR RASTERIZING ALGEBRAIC CURVES

Page 1: AN ACCURATE ALGORITHM FOR RASTERIZING ALGEBRAIC CURVES

AN ACCURATE ALGORITHMFOR RASTERIZING ALGEBRAIC CURVES

Gabriel Taubin

IBM T.J.Watson Research CenterP.O.Box 704

Yorktown Heights, NY 10598

AbstractIn this paper we introduce a new algorithm for ras-

terizing algebraic curves, and we discuss applicationsto surface and surface-surface intersection renderingand visualization. By rustm”zing an algebraic curve wemean to determine which cells, or pixels, from a squaremesh of cells in the plane, are cut by a curve representedas the set of zeros of a polynomial in two variables. Byusing a recursive space subdivision scheme, the prob-lem is be reduced to testing whether the curve cuts asquare or not. Other mwearchers have followed thisapproach, but their tests are either computationally ex-pensive, or apply just to special cases. Curves withsingularities are particularly difficult to deal with, andmost know algorithms fail to nmder these curves cor-rectly. Our contribution in this paper is the introductionof a computationally effiaent and asymptotically cor-rect test, which applies not only to dimension two, butalso to dimension time and above. We prove that therecursive space subdivision algorithm based on thisnew test renders a curve of constant width, even inneighborhoods of singular points, and with no missingparts. For example, if ~ is a polynomial, it producesthe same results whether the coefficients of ~ or ~z aregiven as input to the algorithm. Not many algorithmssatisfy this property. Finally, the same methodologycan be applied to compute a set of voxels containingan algebraic surface, and by representing it as a sin-gular surface, space algebraic curves (surface-surfaceintemections) can be approximated as well. We showexamples of these applications. This sets of voxels canbe used for tolerance analysis and to compute polyhe-dral or piecewise linear approximations of the curvesor surfaces for interactive nmdering purposes as well.

Permission (o copy without fee all or pan of this material is grantedprovided {hal the copies are not made or distributed for directcommercial advantage, the ACM copyright notice and the title of thepublication and its date appar, and notice is given that copying is bypermission of the Association for Computing Machinery. To copyotherwise. or to republish, requires a fee arrd/or specific permission.

2nd ACM Solid Mcdeling ‘93-5/93/Montreal. Canada@ 1993 ACM 0-89791 -584 -4/93/0005r022 1...$1.50

1 Introduction

Planar curves can be rvpmsented parametrically orimplicitly. A parametric curve is the image set ofa two dimensioml vector function of one variable{(z(t), y(t)) : t 6 R}, while an implicit curve is theset of zeros of a function of two variables Z(f) ={(z, y) : ~(z, y) = 0}. Very efficient methods exist torender several families of parametric curves, but im-plicit curves are difficult to render.

Since a local parameterization always exists in aneighborhood of a regular point of an implicit curve, i.e.,a point p = (u, v) such that f(p) = O and V~(p) # O,one approach that several reseamhers follow, calledtracing, is to approximately parametrize the implicitcurve, and then render it using the methods for para-metric curves [1, 2, 3, 4, 13, 19, 20, 27, 28, 30]. Thebasic difficulty with this method lies on the fact thatimplicit curves can be multiply comected, and oftenhave singular points (where f(p) = O and Vj(p) = O),where they intersect themselves, or split into severalbranches. To render the curve correctly, the singularpoints and the comected components must be identi-fied [8, 9]. The problem with this approach is that thealgorithms are intrinsically complex, computatiomllyexpensive, and can only deal with curves with isolatedsingularities. In order to find all the singular points,all the solutions of a system of polynomial equationshave to be found. Tracing algorithms follow a bottom-up approach, while recursive subdivision algorithmsfollow a top-down approach. Somewhere in betweenis a family of algorithms that compute piecewise lin-ear approximations [5, 7, 11, 14]. They am based on asingle teselation of the initial box into a regular meshof cells, triangles or squares in the plane, and cubes ortetrahedra in space, and a marching cubes [22, 10, 21]type of algorithm to move from a;occupied cell to aneighboring one. Inside an occupied cell the curve isapproximated by a straight line segment, or a polyhe-dron in the spatial case. There am two basic problemswith this kind of approach. The first problem is how tochoose the resolution of the mesh. The second problemis how to find an occupied cell to start the marching

221

Page 2: AN ACCURATE ALGORITHM FOR RASTERIZING ALGEBRAIC CURVES

process. In principle, all the cells must be visited inorder not to miss discomected components, but somerecent results show how to deal with this problem [6].Recursive space subdivision algorithms am generallybased on subdividing boxes, the subject of this paper,and on subdividing triangles or tetrahedra [18, 24]. Itis our understandti~ thatso far no altzorithm has dealtwith arbitraxy sin~”lar curves and s“urfaces correctly.The algorithm described in this paper does. For a m-recentattempt to deal with singular surfaces in a similarmanner see [25].

By using a space subdivision scheme, i.e. by lookingat the original square as a low resolution pixel, discard-ing pixels which are not cut by the curve, and subdivid-ing those which might be cut, the problem of renderingan algebraic curve in a raster device, such as a CRTdisplay or a laser printer, can be mciuced to determini-ng whether the curve cuts a given square or not. In apnwious work [29] we introduced a correct algorithmfor rasterizing algebraic curves based on this scheme.Instead of using a test that provides a yes-or-no answerto the question of whether the curve cuts the square ornot, i.e. evaluating a necessary and sufficient condi-tion for zeros of the associated ‘polynomial in the box,a difficult problem [26, 23], we introduced a much lesscomputationally expensive test based on a simple poly-nomial inequality. This test provides a no-or-may-beanswer to the same question, i.e. it constitutes a suffi-cient condition for a polynomial not to have roots insidea circle, but an empty circle could pass the test. Squarescan be tested by testing the circumscribed tides. Thus,squares that do not pass the test can be safely discarded,but theiv is no guarantee that the curve cuts the squaresthat pass the test. However, the test is proven to beasymptotically cornxt near regular points of algebraiccurves, and the results are rendered curves of constantwidth in the neighborhood of regular points. Figure1 shows some examples of algebraic curves renderedwith this algorithm.

Although practical and simple, producing correctrasterizations of regular curves, and almost correctrasterizations of curves with low order isolated sin-gularities, this nmdering algorithm does not behavecorrectly near singular points. In this paper we in-troduce an improved version of the intersection testwhich solves the problem. First of all, by switchingfmm the 2-norm [l(z, y)[lz = (Z2 + #)1/2 to the oo-norm 11(z,~)11~ = max{lzl, IYI}, and modifying thecorresponding inequality, we obtain a new test that isa sufficient conditions for an algebraic curve not to cuta square, instead of a circle. Fewer arithmetic opera-tions are need to evaluate this test, and the results areequivalent to those obtained with the old test. In thesecond place, the pnwious algorithm is too conserva-tive near singularities, empty squares near a singularityam not discarded, resulting in thickerlines in the neigh-borhood of a singular point. We solve this problem bydesingukizing the polynomial. We construct a rational

degree 3

(xldegree 4 , de 10

D

v

degree 4

Elde 8

m

degnx 6 degree 6 degree 8

Figure 1: Examples of algebraic curves rasterized with the algo-rithm described in [29], on a grid of 512 x 512 pixels. Note thatisolated zeros and singularities of low order a~ correctly rsmdered,but neighborhoods of singularities are thicker. The curve on thelower rightcomer is the union of thee circumferences, but all thepoints in one of them are singular.

function, a ratio of two polynomials, continuous ev-erywhere, with the exactly the same zeros as the ori-ginalpolynomial, but with constant multiplicity. Thisratioml function behaves locally as a second degreepolynomial. The previous test is applied to this seconddetpe approximation to the rational function to deter-mine whether or not a box should be discatied or not.With this new test we how have a practical algorithmwhich renders a curve of constant width everywhere,even in neighborhoods of singularities. Figure 2 showsthe same curves of figure 1 rendered with this new al-gorithm. Note that neighborhoods of singular points,even when they are not isolated, are rendered correctly.

We end the paper with a section on applications ofthe algorithm to three dimensioml problems : surfaceand surface-surface intersection nmdering and visual-ization.

Many readem might be skeptical about the robust-ness and numerical stability of the algorithm, particu-larly near singular points. We originally had the sameconcerns, mainly after the work of Farouki and Ra-jan [16, 171, but the experimental results have clearlyshown us that these concerns am not sound in prac-tice in the case of this algorithm. Due to lack of space,we only show a few examples hem, but we have doneextensive experimentation with these algorithms, andtheir performance is very good. In [29] we show curves

222

Page 3: AN ACCURATE ALGORITHM FOR RASTERIZING ALGEBRAIC CURVES

F(xl

1

degree 10

degm 6 degree 6 degree 8

Figure 2: Same algebraic curves of figure 1 rasterized with thealg;rithm described h this paper. Note-the curves have constantwidth, even in the neighborhoods of singular points.

of degree 50 with many singdar points correctly nm-dered with the previous version of the algorithm, andthe impmved version described in this paper produceseven better pictures.

The issue of speed might also be a source of concernto some readers. Again, due to lack of space, we do notpresent timing information here, but the running timesare acceptable. For low degree curves, the runningtimes for the pictures shown ranges from a fraction ofa second to a few seconds. Tiiing information for theold algorithm is given in [29]. We nxognize, however,that this is an area that needs further exploration, andwe are curnmtly studying ways to speed up the process.

2 Recursive subdivision algorithmsFigure 3 describes an ideal algorithm for xvndering

an algebraic curve

z(j) = {(z, y) : /(z, y) = 0;

in the square box of side n centered at the pointp = (u, o). The square is scanned, and only thosepixels cut by the curve are painted. We call this al-gorithm ideal because every correct algorithm shouldpaint exactly the same pixels, but it is impractical. Itrequires n2 test evaluations, one for each pixel in thesquare. But since in general it will be rendering a curveon a planar region, the number of pixels it is expectedto paint is only O(n). We need a more efficient algo-rithm. Them are two issues to look at. The first one is

223

how to reduce the computatioml complexity by recur-sive subdivision. The second issue, to be discussed inthe next section, is how to test whether or not the curveZ(f) cutsa square.

promh.m IdealPaintCurve(f, B((u, u), n/2))forz+u– n/2+1 /2tou+n/2- l/2stepldo

for~tv– n/2+1 /2tou+n/2– l/2stepldoif Intersect (z(~), B((z, v), 1/2))) # NO

PaintPixel (z, y)

Figure 3: Ideal algorithm for rendering the curve Z(f)= {(z,v) :f(z, y) = O} on a square of side n centered at the point (u, v)B((u, v),6) denotes the square box {(zjy) : max{lz - tilt [y – wI} <6}.

The number of test evaluations can be easily rvducedusing a recursive space subdivision scheme describedin figwe 4, where n is assumed to be a power of 2.The rationale behind this algorithm is very simple. Itstarts by considering the initial square region as a singlepixel. Then, every square region which had pnwiouslysatisfied the test for its resolution is divided into fourequal size square regions, which are then tested. Thesquares which pass the distance test are kept into astack. The size of the squares is divided by two at eachiteration, and when the square regions become singlepixels, the iteration stops, and the pixels are painted.

3 Tests for zeros of an algebraic curve in abox

In this section we are concerned with the problem oftesting whether or not the algebraic curve Z(f) definedby a polynomial of two variables ~(z, y) intersects thebox B((u, v),6) = {(z, y) : max{lz – uI, Iv– vi} < 6}.Tests that give a yes or no answer, i.e., tests for neces-sary and sutlicient conditions for the curve to intersectthe box, exist [26, 23], but they am computationallyvery expensive, involving elimination techniques, andprobably not numerically well behaved, for to the samemason. Approximate tests can be used instead, butthe main problem with approximate tests is to provethe correctness of the algorithm. An approximate testshould satisfy three main properties. First of all, itshould never discard a box that intersects the curve,otherwise parts of the curve could be missing. Thatis, the test should be a sufficient condition for a curvenot to intersect the box. Second, it should be asymp-totically correct, i.e. if a box does not intersect thecurve, and it is not rejected by the test, after a numberof subdivision steps all the resulting sub-boxes shouJdbe rejected. Third, and very much dated to the previ-ous property, it should render curves of approximatelyconstant width. The last two properties are difficult toachieve, in particular close to singular points. Thereis also the issue of how well the test performs in prac-tice, because even if it is asymptotically correct, it could

Page 4: AN ACCURATE ALGORITHM FOR RASTERIZING ALGEBRAIC CURVES

procedure RecursivePaintCurve (~, B((u, v), n/2)input-stack + 0output-stack + 0Push ((u, U), input-stack)while n >1 do

n + n/2

while input-stack # 0 do(u, u) + Pop(input-stack)

(a3, V3) ~ r (Wl 7J4)

(?q, tn) J ~ (U2, V2)

fori=lto4stepldoif Intersect (Z(~), B((ui, vi), ~/2)) # NO

Push((u;, vi), output-stack)input-stack +- output-stackoutput-stack + 0

while input-stack # 0 do(Z, y) + pop (input-stack)PaintPiiel (z, y)

Figure 4: hnpmved ideal rendering algorithm.

converge very slowly.Now we will bmafh describe a slkhtly modified ver-

sion of a test that we have recently ir%oduced [29]. Thistest satisfies the fimt property, and the second and thidones only in the neighborhoods of the regular points ofthe curve. The test fails to discaxd enough pixels closeto singular points, resulting in thicker regions, i.e. thewidth of the rendered curve increases in the neigh-borhood of singular points. We have already seen infigure 1 examples of algebraic curves rendered with therecursive subdivision algorithm of figure 4 using thistest. We will then modify the test to correct its behaviornear singular points. This is the main contribution ofthis paper.

Note that by first translating the origin to (u, v), i.e.by expanding the polynomial in Taylor series around(u, v), the problem isn?duced to the case (u, v) = (O,O).An effiaent algorithm for transforming the polynomial

where d is the degree of f, to the form

O<i,j,i+j~d

is Homer’s algorithm [12],rithms exist to do so [15].

and even parallelGoing from (1) to

(2)algo-(2) is

equivalent to evaluating the polynomial and all its par-tial derivatives at (u, v). Homer’s algorithm requires0(m2) operations, where m is the number of coeffi-cients of the polynomial. The same order of operationsrequired to evaluate a polynomial in Bernstein form.

So, from now on we will concentrate on finding a suf-fiaent condition for the polynomial (1) not to have zerosin the box B((0,0),6) = {(z, Y) : ll(z,v)llrn S ~}~ andwe can assume that f (O,O) = fm # O, because other-wise the curve clearly intersects the box. The approachis as follows. We construct a polynomial of one variableF(6), whose coefficients am functions of the coefficientsfij of j, and Su& that F(O)= 1~(0,0)1> O, and

VE > Ov(z, y) E B((O, O),E) : If(%y)l 2 F(c) .

Clearly, if 6 is smaller than the fimt positive root ofF (if any), the polynomial f will not have zeros inB((o, o),4) .

In [29] we constructed the bounding polynomialF(e) to provide a sufficient condition for the poly-nomial (1) not to have zeros in a circle C((O, O),6) ={(z, y) : /~ < 6}. The following constructionprovides a test for boxes, and it requires less arithmeticoperations to evaluate. We first rewrite the polynomial(1) as a sum of homogeneous terms, or@rrns

f(’, Y) = ~{ ~ fij Zi??} = ~fh(~,Y) , (3)h=O i+j=h hdl

and apply the triangular inequality to the last sum

lf(~~v)l 2 IfOl–~lf%,v)l . (4)h=l

We now consider each one of the forms tl,..., ~d in-dividually, and we use the following inequality

where

E = M% Y)IlOo = m={lzl, IYI}Fh = ll(fh& ...,foh)lll = ~ Ifajl

~+j=h

because it is trivial to verify that

If we defie F(c) = FO – ~~=1 Fh ●h, frOrn eqUaliOnS(4) and (5) we obtain

1~(~, Y)I a F(c).

224

Page 5: AN ACCURATE ALGORITHM FOR RASTERIZING ALGEBRAIC CURVES

Note that, since F(c) is positive at the origin ( F(O) =F. = 1~(0,O)I > O), and it is monotonically decreasingfor E >0, because the coefficients ~1,..., Fd a~ non-negative and 1’~ is positive, it has a unique positivemotdd. Since ~(~) >0 foro<~<bd, we haveasufficient condition for the polynomial f not to havezeros inside a box: if O < c < 6d then F does nothave zeros inside the box B((O, O), ~) . In fact, althoughthe number 6d can be computed very quickly with acouple of Newton iteration steps, it does not need tobe computed. Since the polynomial F(c) is positive atthe ori@, and it is strictly decreasing for c ~ O, to testwhether the curve intersects the box B((O, O),4) or notwe just evaluate F(J). If the value is positive, the curvedoes not cut the box.

In the old test [29], the coefficients F1, ,.., Fd weredefined as follows

Fh = { ~ (~)-1[fij12}1’2 .i+j=h

In this case F(6) > 0 implies that ~ does not havezeros in the circle C((O, O),E) instead. The differencebetween the old and the new tests is related to theswitching fmm the 2-norm 11(z,U)112= /~ tothe co-norm 11(z,y)ll~ = max{lzl, Iyl}. We will referto the old test as the 2-norm test, and to the new one asthe co-norm test. In fact, these am just two particularinstances of a more general construction. For everymal number r such that O< r <00 we can construct ar-norm test in a similar way by defining the coefficientsFl,..., Fd &5 fO~OWS

.,x+j=h

In this case F(c) >0 is a sufficient condition for thepolynomial ~ not to have zeros in the r-ball

‘r((o,o),~) = {(Z, Y) : ll(z,y)llr = (121’ + l$/lr)l/’ < c .

However, since we will not use these tests, and it ismore expensive to evaluate them, we will not describethem in detail hem. The only reason we have to men-tion this family of testis the fact that the only positiveroot bd of the bounding polynomial F(c) associatedwith the r-norm is a lower bound estimate for the r-distance from the origin to the curve, and since all thenorms am equivalent to each other, in the sense thatwhen one goes to zem all of them go to zero at thesame rate, using any one of these tests as the basisfor the rendering algorithm should produce almost thesame results. Due to lack of space we will not givea formal proof for this fact, but we have confirmed itexperimentally. Although the results are not identical,them is no pemeptual difference. So, to understand thelocal behavior of a rendering algorithm based on thesetests, it is sufficient to analyze any one of them.

In [29] we analyzed the case of the 2-norm test. Wep :mred that the 2-norm approximate distance 6d(P),define as above by first translating the origin to thepoint P = (u, v), then evaluating the coefficients of thebounding polynomial, and finally finding its uniquenonnegative root, has the following property, whichexplains the behavior of the algorithm near regularpoints.

Lemma 1 If f is a polynomial qf degree d > 1, ~ is aregular point @ Z{ f ), w is a unit length normal vector toZ(f) at~, and~=~+ tw,fmt EZR, then

Cf@)=1,

~ ciist (~, Z(f))

where dist (p, Z(f)) is the Euclidean distance@m the pointp = (u, v) to the cuwe Z(f).

The behavior of the algorithm near singular points ismore difficult to analyze. Near a singular point the ap-proximate distance 6~(p) always undenxtirnates theEuclidean distance, and in general the width of thecurve increases proportiomlly to the multiplicity ofthe singularity. We will be mom specific in the nextsection, but for example, if 2(f) is a regular curve,i.e. Vf(z, ~) + O for every point (z, y) E Z(f), andwe set g(z, y) = f(~, y)2, the algorithm based on thetest described above will still render the curve Z(g)correctly, i.e., without erroneously discarding occupiedboxes, but at almost twice the width. It is important tonote that most rendering algorithms, in particular trac-ing algorithms, camot deal with this kind of situation.Fi@m- 5 show some examples of these curves.

Tz(f)

EZ(fz)

+

Hl_?zZ(fz) Z(fz)

Figure 5: Exarnplesof algebraic curve pairs (Z(f), Z(~2)). Z(f’)is rendered at ahnoat twice the width of Z(f)

4 DesingularizationOurgoal in this section is to modify the test described

above, to coned its behavior near singular points. Weneed to start with a definition.

225

Page 6: AN ACCURATE ALGORITHM FOR RASTERIZING ALGEBRAIC CURVES

4.1 Multiple pointsThe multiplicity of a point p = (u, u) as a zem of

the polynomial f is the minimum index h such thatat least one partial derivative of f of order h is notidentically zero at p

m(p;f) = min{h : f; # O} ,

where the form f; is the form f h of equation(3), aftertranslating the origin top, as in equation (2). The mt.d-tiplicity of a point as a zem of an analytic function canbe defined in a similar way. In this case we will have toexpand the function in Taylor series around p to obtainthe forms f: . The multiplicity of a point with respectto a rational function, a ratio of two polynomials, isdefined as the multiplicity of the point with respect tothe numerator minus the multiplicity of the same pointwith respect to the denominator. Points with positivemultiplicity are called zeros, and points with negativemultiplicity are called poles. We will make use of thisconcept later.

Since $ = f(p) is a constant, the set Z(f) is exactlythe set of points with positive multipliaty

Z(f) = {p E IR2 : m(p;f) > O} .

A point p of multiplicity one is called a simple, or regu-lar, point of Z(f). If m(p; f ) >1, p is called a multiple,or singular, point of Z(f). The setof singular points ofthe curve Z(f) is exactly the set of points with muhi-plicity at least two

Z’(f) = {p E IR2 : m(p;f) > 1} ~ Z(f) .

4.2 Reducing multiplicitiesThe main reason for the approximate distance fid to

underestimate the Euclidean distance near a singularpoint is illustrated in figure 6. The graphs of the poly-nomial f (s, y) and of its bounding polynomial F(c) atthe origin am ~presented along a line that cuts a zempoint p (marked with a vertical line segment on theright side of the figures). When approaching a regularpoint, the value of If (~, y) I goes to zem linearly whilewhen the multiplicity increases, If I goes to zero muchfaster. Note that the graph of If I is concave near a zeroof f, while the graph of F(e), which is always belowthe graph of If 1, is convex. For a good approximationof the former by the later we need almost linearity ofboth graphs. If the concavity of the graph of If I is toopmnourtced, it is just not possible to obtain an accurateapproximation with a convex function.

Our approach is to linearize the behavior of f nearZ(f), or todesingulariz.e it. By this we mean to constructa new function g(z, y), it will not be a polynomial buta rational function, with exactly the same set of zerosZ(g) = Z(i), but such that all the points in Z(g) haveexactly the same multiplicity with ~spect to g. Wefirst set #(z, y) = f(2, y)2. Thedegree of#is2d andthe multiplicity of a point as a zero of # is twice the

Km(p; f) = 1

ETm(p; f) = 2 m(p; f) = 4

Figure 6: 6ehaviorof Jd nearregr,darand singularpoints. methickcurveis thegraphof f andthethincurveis thegraph of the

boundingpolynoxkd F at the origin. The closest zeru ~o &e originis p, marked with a vertical segment on the left hand side of thepictures.

multiplicity of the same point as a zem of f. Now weshow how to construct a polynomial #(z, y) with thefollowing properties

1. [email protected]. The set of zeros of @is a subset of the set of zeros of

#. In fact, Z(+) will be the set of singular pointsoff.

3. If p is a zero of +, and thus of #, the multiplicity ofp as a zero of @ is exactly equal to the multiplicityof p as a zero of ~ minus 2.

Under this conditions, the ratioml function g(z, y) =4(z, y)/@(z, y) is well defined and continuous every-where ( g does not have poles), it has exactly the samezeros as f, and the multiplicity of every point p inZ(g) = Z(f) as a zem of g is exactly 2.

SO,let us construct @. First of all, let us denote withf= and fv the two partial derivatives of f. A point pis singular if and only if it is a common zero of f, f=,and fy . Since the degrees of f= and fY are at mostd– 1 while thede~ of f is d, let us definea newpolynomial

fm(%y) = ~f(%Y) - (~f.(%Y) + Yf,(% Y)) o

The degree of f~ is at most d – 1 because of Euler’sformula [31], i.e., the leudingjorm f d of f satisfies thefollowing identity

d fd(z, y) = zf~(z, y) + yf~(z, y) ,

and the common zeros of f, f= and fy am exactly thesame as the common zeros of f~, f= and fg, becausethe construction is ~versible

f(&Y) = ;(fm(z, u) + ~f.(~,Y) + Yfy(% Y)) .

Another way to construct fm is to first homogenizef(~, Y) with a new variable w

d

f(W%Y) = ~wd-hfh(%Y) ,h=O

obtaining an homogeneous polynomial of degree d inthreevariables, then differentiate with respect to the

226

Page 7: AN ACCURATE ALGORITHM FOR RASTERIZING ALGEBRAIC CURVES

new variable

d–1

~w(%%y) = ~(~– ~)~d-’’-’fh(%y) ,h=O

and finally dehomogeneize and divide by d

fcm(~,v) = ;L(l, Z,Y) =; +#h(z, Y) .

Let 4(z, Y) = f~(z,v)2+ f.(z, y)z + fy(z, y)z. Thedegree of @ is exactly 2d – 2, because at least one ofj. or jy should have degree d – 1, and neither one ofthe three has degree larger that d – 1. By construction,the set of zeros of @is exactly equal to the set of singularpoints of ~, and so, a subset of Z(f) = Z(d). The onlyproperty that remains to be proved is the following

Lemma2 I,f#(p) = O,then tn(p; @) = rn(p; ~) –2.

PR~F : If m(p; ~) = k >0, after translating the originto p, we can write the polynomial ~ as follows

with the form ~~ not identically zero. The two partialderivatives are then

fz(z, y) = ~ f:(z, y)h=kd

f,(zlv) = ~f/(%Y) ,h=k

where f~ and ~~ are forms of degree k – 1, and atleast one of them is nonzero, again because of Euler’sformula [31]. It follows that either m(p; ~z ) = k – 1,or m(p; fv) = k – I, i.e.,

min{m(p; f=), m(p; fY)} = m(p; f) – 1,

and this is also true for functions of mom than twovariables. Finally, by construction, m(p; ~~ ) ~ k – 1as well. We conclude that m(p; @) = 2k – 2. •l

Note that the construction of f~ , as well as the con-struction of @, depends on the location of the originof the coordinates system. Once a point p = (u, v) ischosen, we first translate the origin of the polynomialto p, and then construct #1and +. Different rationalfunctions are used in different locations.

Now we need to extend our intersection test for poly-nomials to the rational function g = @J/@,and as be-fore, after translating the origin we can just assume thatp = (O,O). The second assumption is that +(p) # O,and so d(p) # O, because in such a case the curve

clearly cuts the box. Since rational functions am an-alytic, in a certain neighborhood of the origin we canexpand g as an convergent series

m

9(%Y) = ~9h(%Y) ,hnO

where gh is a form of degree h or identically zero. Theforms g’J,gl, . . . can be computed from the followingrecursive equations

#o = +090#l = *ogl + *’g’J

;Zd-z= #@-2 + . . . + @+-jJ (6)~2d-1 =_ ~Og2d-1~2d __ #og2d : ::: : $::::;:o $Og2d+k

+ . . .2d–2 2+k

++9

with the last equation valid for k = 1,2,3, . . . . Then theinequality I}(z, y) I ? FO–~h = 1‘~h Chis generalizedto an infinite sum

where the coefficient Gh is computed from the coeffi-cients of the form gh(z, y) as befons

i+jzh i+j=h

(7)The analytic function of one variable G(E) behaves asF(E). That is, it is positive at the origin, and decreasesmonotonically for e > 0. So, it has a unique positiveroot. We don’t need to compute this root either. Totest whether g has no zeros in a box B((O, O),6), wejust need to evaluate G(6). If G(6) >0, then g hasno zeros in the box. And here we have a problem. If

a partial sum ~~=o Gh /ih is negative, we can stop theevaluation, and accept the box for further subdivision,but to be sure that G(6) >0, we need to perform aninfinite number of operations, and we cannot do that.The solution is to truncate the series, and redefine G(c)as a polynomial plus an extra term

2dG(E) = Go – ~ Gh Eh – G2~+1(c) , (8)

h=l

where Go, . . . . Gzd are defined in equation (7), but&+l (c) will be chosen to bound the tail of the seriesexpansion of g

for Il(z, y)ll ~ E. To construct Gzd+lfollowing result

1

we need the

227

Page 8: AN ACCURATE ALGORITHM FOR RASTERIZING ALGEBRAIC CURVES

Lemma 3 M <1,..., i,vl,v,vn, hfvn, hf bereal numbers.Let us de@ vJ+n = ~lv~+n-l + ..0 + (nvj, and Kj =max{l~l,..., lv~+’’-ll}, jbr j 21. ~ M, satis&s theinequality 1<1I+ ““”+ l(nl<lw<l,then

15 # < nKIMr/(l– M),‘ j=rn+l ‘

PRmF : First of all, note that for every j 21 we have

lvj+~l = l(lti+-1 +... +~~v~l

s {1<11+. ..+ lf~l} max{l#l,...,lvjJ’ll}l}

< Kjl

with the last inequality because M < 1. This clearlyimplies that

Kj+~ = max{lti’+ll,..., Iti+’’-ll, lti+nl} < Kj .

Now, from the previous two inequalities we obtain

Kj += = max{l~”+nl, . . . . l@”+2n–11}~ max{MKj,... , MKj+._l} z .MKj ,

and by induction, Ifj+hn ~ MhKj , for h ~ 1. Finally,for r ~ 1 we have

w

lx dj=rn+lm

nKIM’ ~Mh = nKIM’/(l– M).h=O

Now we compute G2~+1(t) as follows. We first com-pute the coefficients of the forms go,..., g2~ with therecursive equations (6), and then evaluate the coeffi-cients Go, ..., GM of the bounding polynomial. Nowwe apply the lemma for n = 2d, r = 1, (j = –@j /+0forj= l,..., 2d–2, ~2d-1 =~2d=0, and @ =~, forj= l,..., 2d. Note that the recursive equation of thelemma is nothing but the last equation of (6), and ev-erything hem is function of the point p = (z, y), eventhe bounds M and K1 . But there is some freedomin choosing M, which we will make a function of c.As we have done for other forms, the form (h(z, y)satisfies the inequality <h(z, y) S ~hll(z, Y)I12, Where

‘h = ~i+jnh !’& I ~‘d th = ~a+jch %z$d - ‘e ‘ake

Note that M(c) is a monotone function, and M(0) = O.So, for small E the hypothesis M(E) <1 is satisfied.If it is not satisfied for the curmmt value of E, the cube

should not be rejected, and subdivided even further. Itis clear that the condition M(c) <1 will eventually besatisfied after a number of subdivisions. With respectto K1 = max{lgll, . . . . lg2d-21}, we can always replaceit with an upper bound function of c. Since &&1 =&d = O, we take

K1 (e) = max {Glq... , Gzd-&d-2} .

This isalsoa monotone functionof c, and K1(0) = O.Observe that K1 (c) is independent of Go, which isassumed to be diffem-tt from zero. Finally,

Gzi+](f) = u K1(E) WE)/(1 – Jf(E)) .

Note that at least Gzd+l(~) = O(&).Figure 2 shows examples of curves rasterized with

the algorithm of figure 4 based on this test.

5 Visualizing surfaces and surface-surfaceintersections

The algorithms described above can be trivially ex-tended to dimension three and above. In dimensionthee we start with a cubical box 13((u, v, w), 4)

{(z, y,z) : max{lz - Ml,Iv- vI, Iz - wI} < 6}

and a polynomial of three variables ~(z, y, z) of de-gree d. The recursive subdivision algorithm can beextended to three dimensions by subdividing the cubeinto eight subcubes. We introduced the tests in dimen-sion two just not overload the reader with notation, buthere is how it can be extended to dimension three. Ex-tensions to higher dimensions zue left to the reader, butthis kind of approach is not practical in very high di-mensioml space because each box must be subdividedinto 2“ subboxes, where n is the dimension of thespace, and one could very easily encounter a storageproblem.

Homer’s algorithm can also be used in dimensionthe and above, so for testing whether the polyno-mial ~ has zeros in a box lil((u, v, w), 6), we first trans-late the origin to (u, v, w), and then we test the boxB((O, O,O),6). After translating the origin we write thepolynomial !(z, y, z) as a sum of forms of increasingdegree

d

h=O

wherefh(x, Y,z) = ~ fajk~i~zk

i+j+k=h

For the first test, we define the coefficients of the bound-

ing polynomial F(f) = Fo – ~;=l Fh ●h as follows

and we obtain the corresponding test for dimensionthree: if F(6) >0 the polynomial f does not have

228

Page 9: AN ACCURATE ALGORITHM FOR RASTERIZING ALGEBRAIC CURVES

zeros m the box B((O, O, O), 6) Fype 7 shows the m-resultof applying the algorithm based on tlus test to thesimple case of a sphere The results at the end of eachsubcimson level have been rendered with a standardray-tracing algorithm The new test mtmduced m thepnwlous sechon cart be extended to the three dm-ten-slonal case m a smular way We leave the detads to thereader

The set of regularzeros of a polynomial define a sur-face (If not empty), but the set of singular points can bea uruon of Isolated points, curves, and even surfacesFor example, m the case of the heart of figure 8, thesurface has two ~olated singular points, the two cusps,one at the top, and the other at the bottom, and also acurve of singular points The 2ntersect20nof the surfacewith the plane z = O 1san elhpse, an all the points ontlus elhpse are sutgular Since we have used the sunplertest for tius pictures, that w why we observe a fatterurtgaround that curve

■■■mmm

level 6 level 7 Raytraced

Flgu~ 7 Sphere .2 + ~ + .2 -225 = O Box center (0,0,0)Box s]de 4

❑ mm

mmmlevel 6 level 7 Raytraced

Figure 8 Heart (2.2 + & + .2 1)3 (1/IO)Z2Z3 – tj-z3 %x

center (O O O) Box side 25

In the case of the Cartan’s umbrella, the z am ]s theset of singular points of the Polynomial In the case ofthe heart all the singular points belong to the boundaryof the set of regular points, but not here The algorithmcorrectly keeps track of a ne@borhood of all the pointsof the surface, mcludmg the singular points

■ mm

mmmlevel 5 level 6 level 7

Flgu~ 9 Cartans umbrella(0,0,0) Box s]de 4

‘(Z2 + l?) - 23 = O BOX center

In fact, the mtersectlon of two regular surfaces canbe rendered with d-us algorithm by representing It asa completely .wngular surface For example, figure 10shows an example of tlus process The mtersetion oftwo cylinders 1s rende~d by applying the subdnwonalgorithm to the sum of squares of the two polynomialsdefmmg the mdnudual surfaces

■ um

mmmlevel 5 level 6 level 7

Flgu~ 10 hte~on of two cyhnders .2 + (z - I )2 2 =

O ~ + (z + 1)2 – 2 = O asmgular surface (Z2 + (z 1)2 – 2)2 +(d+ (z+ 1)2 - 2)2 = O Box center (O 0,0) Box side 4

As a parhcular case, we can use the algorithm towsuahze and explore surfaces with smgulantws Thesingular space, defined as the set of zeros of the polynomlal #(z, y, z)

fuJ(%Y, z)2 + fz(~, Y!z)2 + fy(~, Y,z)2 + fz(z!Y, z)2

229

Page 10: AN ACCURATE ALGORITHM FOR RASTERIZING ALGEBRAIC CURVES

used in the desingularization test, can be mndemcl si-multaneously, and the user can choose regions to ex-plore in more detail based on this.

As we have seen, in dimension three this algorithmprovides a primitive tool to visualize algebraic surfacesand space curves, and to seamh for singularities. As itis, the result of the algorithm is a set of cubes containingthe curve or surface. For regular surfaces, a marchingcubes [22, 10, 21] type of algorithm can be used to com-pute an approximate triangulation of the surface. Theproblem is how to deal with singular cases, and we arecurrently investigating how to deal with the problem.

References[1]

[2]

[3]

[4]

[5]

[6]

[n

[8]

[9]

[10]

[11]

[12]

[13]

S.S. Abhyankar and C. Bajaj. Automatic parametri-zation of rational curves and surfaces I: conies andconicoids. Computer Aided Design, 19(1):11-14, Jan-uary/February 1987.S.S. Abhyankar and C. Bajaj. Automatic parametrizat-ion of rational curves and surfaces II: cubics and cubi-coids. Computer Aided Design, 19(9):499-502, November1987.S.S. Abhyankar and C. Bajaj. Automatic parametrizat-ion of rational curves and surfaces ILI:algebraic planecurves. Technical Report CSD-TR-619, Purdue Univer-sity, Computer Sciences Department, W=t Lafayette,Indiana, February 1987.S.S. Abhyankar and C. Bajaj. Automatic parametrizat-ion of rational curves and surfaces N algebraic spacecurves. Technical Report CSD-TR-703, Purdue Univer-sity, Computer Sciences Department, West Lafayette,Indiana, February 1988.E. Allgower and K. Georg. Simplicial and continuationmethods for approximating fixed points and solutionsto systems of equations. SIAM Review, 22(1):28-85, Jan-uary 1980.E.L. Allgower and S. Gnutzmanrt. Sirnplicial pivotingfor mesh generation of implicitly defined surfaces. Comp-uter Aided Geometric Design, 8:305-325,1991.E.L. Allgower and P.H. Schmidt. An algorithm forpiecewise-linear approximation of an implicitly definedmanifold. SIAM Journal of Numerical Analysis, 22(2)322-346, April 1985.D.S. Amen. Topcdogically reliable display of algebraiccurves. Computer Graphics,17(3)219-227, July 1983.C.L. Bajaj, C.M. Hoffmann, J.E. Hopcmft, and R.E.Lynch. Tracing surface intersections. Twhnical ReportCSD-TR-728, Department of Computer Science, PurdueUniversity, West Lafayette, Indiana, December 1987.H. Baker. Building surfaces of evolution: The weavingwall. International journal of Computer Viswn, 3:51-71,1989.J. Bloomenthal. Polygonization of implicit surfaces.Computer Aided Geometric Design, 5:341-355,1988.A. Borodin and I. Munm. TheComputational Complexityof Algebraic and Numeric Problems. American Elsevier,New York, 1975.Y. De Mountaudouin. Resolution of P(Z, y) = O. Com-puter Aided Design, 23(9):653454, November 1991.

[14] D.P. Dobkin, S.V.F. Levy, and Thurston W.P, Contourtracing by piecewise hnear approximation. ACM Trans-actions on Graphics, 9(4)389-423, October 1990.

[15]

[16]

[17]

[18]

[19]

[20]

[21]

[22]

[23]

[24]

[25]

[26]

[27]

[28]

[29]

[30]

[31]

M.L. Dowting. A fast parallel homer algorithm. SIAM)ourmd on Computing, 19(1):13>142, February 1990.R.T. Farouki, and V.T. Rajan. On the numerical conditionof Berstein polynomials. IBM Research Diviswn TechnicalReport RC-12626, March 1987.R.T. Famuki, and V.T. Rajan. On the numerical conditionof algebraic curves and surfaces. IBM Research DiviswnTechnical Report RC-13263, November 1987.M. Hall and J. Warren. Adaptive polygonalization ofimplicitly defined surfaces. IEEE Computer Graphics andApphcations, pages 3342, November 1990.J.D. Hobby. Rasterization of nonparametric curves.ACM Transactions on Graphics, 9(3):162-277, July 1990.B.W. Jordan Jr., W.J. Lennon, and B.D. Hohn. An im-proved algorithm for the generation of nonparametriccurves. IEEE Transactions on Computers, C-22(12) :1052–1060, December 1973.A.D. Kalvin. Segmentatwn and Su@ce-Based Modelingof Objects in Three-Dirnenswnal Bwmedicd Images. PhDthesis, New York University, New York, March 1991.W. Lcmmson and H. Cline. MaAing cubes: A highresolution 3d surface construction algorithm. ComputerGraphics (Prvc. SKGRAPEO, 21(4):163-169,July 1987.P.H. Milne. SymtKIlicand Numerical Computatwn fir Ar-tificial Intelligence, chapter On the Solution of a Set ofPolynomial Equations, pages 89-101. Academic PressLtd., London, UK, 1992.D. Moore and J. Warren. Adaptive mesh generationii: Packing solids. Technical Report Rice COMP TR90-139, Department of Computer Science, Rice University,Houston, TX, March 1991.R. Morns. A new method for drawing algebraic sur-faces. In R. Fisher, editor, The Mathematics of Su@cesV, Edinburgh, Scotland, September 1992. IMA, OxfordUniversity Press. (to appear).P. Pedersen. Counting Real Zeros. PhD thesis, New YorkUniversity, 1991.T.W. Sederberg, D.C. Anderson, and R.N. Goldman. Im-plicit representation of parametric curves and surfaces.Computer Vision, Graphics, and Image Processing, 28:72-84,1984.T.W. sederb~ D.C. Anderson, and R.N. Goldman. Im-plicitization, inversion, and intersection of planar ratio-nal cubic curves. Computer Wwn, Graphics, and hnageProcessing, 31(1):89-102, July 1985.G. Taubin. Rasterizing implicit curves by space subdi-vision. IBM Research Diviswn Technical Report RC17913,April 1992.J. Van Aken and M. Novak. Curvedrawing algo-rithms for raster displays. ACM Transactions on Graphks,4(2):147-169, A@ 1985.R. Walker. Algebraic Curves. Princeton University Press,1950.

230

Page 11: AN ACCURATE ALGORITHM FOR RASTERIZING ALGEBRAIC CURVES

SESSION 4: Constraints

231

Page 12: AN ACCURATE ALGORITHM FOR RASTERIZING ALGEBRAIC CURVES