partitioning trimmed spline surfaces into nonself-occluding regions for visibility computation

25
Graphical Models 62, 283–307 (2000) doi:10.1006/gmod.2000.0526, available online at http://www.idealibrary.com on Partitioning Trimmed Spline Surfaces into NonSelf-Occluding Regions for Visibility Computation 1 Shankar Krishnan AT&T Research Labs, 180 Park Avenue, Room E-201, Florham Park, New Jersey 07932 E-mail: [email protected] and Dinesh Manocha Department of Computer Science, University of North Carolina, Chapel Hill, North Carolina 27599-3175 E-mail: [email protected] Received February 22, 1999; revised March 31, 2000; accepted April 24, 2000; published online June 1, 2000 Computing the visible portions of curved surfaces from a given viewpoint is of great interest in many applications. It is closely related to the hidden surface re- moval problem in computer graphics, and machining applications in manufacturing. Most of the early work has focused on discrete methods based on polygonization or ray-tracing and hidden curve removal. In this paper we present an algorithm for de- composing a given surface into regions so that each region is either completely visible or hidden from a given viewpoint. Initially, it decomposes the domain of each surface based on silhouettes and boundary curves. To compute the exact visibility, we intro- duce a notion of visibility curves obtained by projection of silhouette and boundary curves and decomposition of the surface into nonoverlapping regions. These curves are computed using marching methods and we present techniques to compute all the components. The nonoverlapping and visible portions of the surface are represented as trimmed surfaces and we present a representation based on polygon trapezoidation algorithms. The algorithms presented use some recently developed algorithms from computational geometry like triangulation of simple polygons and point location. Given the nonoverlapping regions, we use an existing randomized algorithm for vis- ibility computation. We also present results from a preliminary implementation of our algorithm. c 2000 Academic Press 1 Supported in part by an Alfred P. Sloan Foundation Fellowship, ARO Contract P-34982-MA, NSF Grant CCR–9625217, ONR Young Investigator Award, and Intel. 283 1524-0703/00 $35.00 Copyright c 2000 by Academic Press All rights of reproduction in any form reserved.

Upload: shankar-krishnan

Post on 15-Jun-2016

212 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Partitioning Trimmed Spline Surfaces into NonSelf-Occluding Regions for Visibility Computation

Graphical Models62,283–307 (2000)

doi:10.1006/gmod.2000.0526, available online at http://www.idealibrary.com on

Partitioning Trimmed Spline Surfaces intoNonSelf-Occluding Regions for

Visibility Computation1

Shankar Krishnan

AT&T Research Labs, 180 Park Avenue, Room E-201, Florham Park, New Jersey 07932E-mail: [email protected]

and

Dinesh Manocha

Department of Computer Science, University of North Carolina, Chapel Hill, North Carolina 27599-3175E-mail: [email protected]

Received February 22, 1999; revised March 31, 2000; accepted April 24, 2000;published online June 1, 2000

Computing the visible portions of curved surfaces from a given viewpoint is ofgreat interest in many applications. It is closely related to the hidden surface re-moval problem in computer graphics, and machining applications in manufacturing.Most of the early work has focused on discrete methods based on polygonization orray-tracing and hidden curve removal. In this paper we present an algorithm for de-composing a given surface into regions so that each region is either completely visibleor hidden from a given viewpoint. Initially, it decomposes the domain of each surfacebased on silhouettes and boundary curves. To compute the exact visibility, we intro-duce a notion ofvisibility curvesobtained by projection of silhouette and boundarycurves and decomposition of the surface into nonoverlapping regions. These curvesare computed using marching methods and we present techniques to compute all thecomponents. The nonoverlapping and visible portions of the surface are representedas trimmed surfaces and we present a representation based on polygon trapezoidationalgorithms. The algorithms presented use some recently developed algorithms fromcomputational geometry like triangulation of simple polygons and point location.Given the nonoverlapping regions, we use an existing randomized algorithm for vis-ibility computation. We also present results from a preliminary implementation ofour algorithm. c© 2000 Academic Press

1 Supported in part by an Alfred P. Sloan Foundation Fellowship, ARO Contract P-34982-MA, NSF GrantCCR–9625217, ONR Young Investigator Award, and Intel.

283

1524-0703/00 $35.00Copyright c© 2000 by Academic Press

All rights of reproduction in any form reserved.

Page 2: Partitioning Trimmed Spline Surfaces into NonSelf-Occluding Regions for Visibility Computation

284 KRISHNAN AND MANOCHA

Key Words:spline surfaces; hidden surface removal; 3D computer graphics; NCmachining; visibility.

1. INTRODUCTION

The problems of visibility and accessibility computations are fundamental for computergraphics, computer-aided design, and manufacturing applications. In particular, hidden lineand surface removal algorithms in computer graphics are related to visibility computations[FDHF90, Hor84, SSS74, HG77]. Similarly, accessibility computations in manufactur-ing applications are based on Gauss maps and visibility sets [Woo94, CCW93, GWT94].These problems have been extensively studied in computer graphics, computer-aided design,computational geometry, and manufacturing literature. In this paper, we are dealing withalgebraic surfaces and surfaces defined using rational splines [Far93] that are differentiable.

Given a viewpoint, the hidden surface removal problem deals with computation of thesurface boundary visible from that viewpoint. Most of the earlier algorithms in the literatureare for planar and polygonal primitives and hidden line removal [FDHF90, Mul89, SSS74].In the computational geometry literature, many of the hidden surface algorithms simplycalculate the entire arrangement of lines (projections of edges and vertices of the objects onthe viewing plane). Output-sensitive hidden surface algorithms were developed for specialinput cases likec-oriented solids[GO87],axis-parallel rectangles[PVY92], andpolyhedralterrains [RS88]. Very few algorithms are able to cope withcycles(impossible to obtainan ordering among the faces without splitting some of them) efficiently. A randomizedalgorithm to generate the visibility map was given by Mulmuley [Mul90] for the generalcase. The algorithm maintains the trapezoidation of the visibility map and updates it byrandomly adding one face at a time. The algorithm is (almost) output-sensitive. Extensionsof the hidden surface algorithm from planar to curved faces are described in [Mul90].A survey of most of the recent results in computational geometry regarding object-spacehidden surface removal is presented in [Dor94].

When dealing with curved surfaces, most hidden surface removal algorithms must becapable of manipulating semialgebraic sets [Mul89]. Results from elimination theory andalgebraic decision procedures like Gr¨obner bases are usually used for this purpose [Can88].Unfortunately, algorithms based entirely on symbolic manipulation require infinite precisionto represent algebraic numbers. Bounds based on gap theorems [Can88] have been usedto compute their bit-complexity. However, implementations of these algorithms are verynontrivial and applicability of these bounds in practical situations are still not clear.

Given a model composed of algebraic or parametric surfaces, it can be polygonized andalgorithms developed for polygonal models can then be applied. However, the accuracyof the overall algorithm is limited by the accuracy of the polygonal approximation. Otheralgorithms for visibility computations are based on ray-tracing or scan-line conversion[FDHF90]. These algorithms are slow (may take a few seconds for each patch) and lead todata proliferation. Furthermore, their accuracy is limited by the image or device precision.These techniques are device resolution dependent and many applications in modeling andrendering demand a device-independent representation [TW93]. For example, many datastandards for 2D and 3D models (e.g., the PostScript language) use higher order or device-independent representations.

Page 3: Partitioning Trimmed Spline Surfaces into NonSelf-Occluding Regions for Visibility Computation

PARTITIONING TRIMMED SPLINE SURFACES 285

FIG. 1. Local visibility computations based on silhouettes.

More recently, a hidden curve removal algorithm has been presented for parametricsurfaces by Elber and Cohen [EC90] based onsilhouette curves. A silhouette curveisdefined as the locus of points on the surface where the normal vector is orthogonal to theviewing direction. In this paper [EC90], they extract the curves of interest by consideringboundary curves, silhouette curves, isoparametric curves and curves alongC1 discontinuitybased on 2D curve–curve intersections. Given a curved surface model and a viewpoint, thesilhouettes on the model partition it into front facing and back facing regions (as shown inFig. 1). The surfaces obtained after partitioning based on the silhouette computation neednot be completely visible, as shown in Fig. 1.

We present an algorithm for decomposing a spline surface into nonoverlapping regionsfrom a given viewpoint. Given a model, we represent it as a series of B´ezier surfaces usingknot-insertion algorithms. Each B´ezier surface is partitioned into nonoverlapping regions(these regions can overlap with each other but not with themselves) based on silhouetteandvisibility curves(refer to Section 5). Each computed region has the property that it iseither entirely visible or invisible in the absence of other surfaces. The visibility curvesare computed based on the silhouette and boundary curves. Each nonoverlapping region isrepresented as atrimmedBezier surface bounded by silhouettes, visibility, and boundarycurves. Since the trimming curves are algebraic in nature, it is not possible to provide a

Page 4: Partitioning Trimmed Spline Surfaces into NonSelf-Occluding Regions for Visibility Computation

286 KRISHNAN AND MANOCHA

representation (like parametric curves) that is truly resolution independent. Instead, we pro-vide a piecewise linear approximation of the algebraic curve and an analytic representationwhich can be refined on demand using well-known minimization methods. Given a collec-tion of these trimmed surfaces, we then use a slight variation of an existing randomizedalgorithm [Mul89] to compute the visible portions for hidden surface removal.

In this paper we assume that the input model is composed of nonintersecting surfaces.Given any arbitrary model, we initially decompose it into noninteresecting surfaces usingour surface intersection algorithm [KM97]. This algorithm uses a combination of symbolictechniques and results from numerical linear algebra. We have implemented the algorithmfor decomposing each surface into nonoverlapping regions in finite precision (using 64-bitdouble precision floating-point arithmetic). The actual performance of the algorithm varieswith the viewpoint and surface geometry. On an average it takes about 40–70 ms to de-compose one bicubic patch into nonoverlapping regions. The main goal of this paper is topresent an algorithm for reducing the hidden surface removal problem for spline surfaces tothat of polygonal models. Coupled with such an algorithm for polygonal models, we obtaina complete visible surface extraction algorithm for spline surfaces. A preliminary versionof this paper appeared in [KM98].

The rest of the paper is organized in the following manner. Section 2 presents backgroundmaterial and reviews algorithms from computational geometry and numerical linear algebraused in the rest of the paper. Section 3 briefly describes an overview of our algorithm. Weoutline an efficient algorithm for computing the silhouettes based on marching methods inSection 4. We introduce the notion of visibility curves in Section 5 and show that silhouettesand visibility curves partition a general surface into nonoverlapping regions. We present al-gorithms and implementations for computation of visibility curves in Section 6. In Section 7we talk about how to apply our decomposition algorithm to accomplish hidden surface re-moval and give some details about our implementation. For the sake of completeness, wealso present a variation of an existing algorithm [Mul89] for hidden surface removal of ourdecomposed faces in the Appendix.

2. BACKGROUND

The overall algorithm for visibility computation uses algorithms from computational geo-metry and linear algebra. Some of them include trapezoidation of polygons, partitioning asimple polygon using nonintersecting chains, curve/surface intersections, and local methodsof tracing based on power iterations. We review some of these techniques in this section.Some of the algorithms presented here might not be optimal in terms of worst-case asymp-totic complexity; we compromised it in favor of simplicity and ease of implementation.

2.1. Triangulating Simple Polygons

We represent trimmed surfaces as well as portions of surfaces obtained after visibilitydecomposition using nonconvex simple polygons in the domain. These nonconvex polygo-nal domains are decomposed into triangles for many geometric operations like intersectionsand partitioning.

To decompose a simple polygon into an optimal number of triangles we use Seidel’salgorithm [Sei91]. It is an incremental randomized algorithm whose expected complexityis O(N log∗ N), where N is the number of vertices (in our application,N is typically

Page 5: Partitioning Trimmed Spline Surfaces into NonSelf-Occluding Regions for Visibility Computation

PARTITIONING TRIMMED SPLINE SURFACES 287

FIG. 2. Three stages of Seidel’s algorithm.

between 100 and 200). In practice, it is almost linear time. The algorithm proceeds in threesteps as shown in Fig. 2. They are:

• Decompose the polygon into trapezoids inO(N log∗ N) time (Fig. 2a),• Generate monotone polygons from the trapezoids in linear time (Fig. 2b), and• Triangulate the monotone polygons in linear time (Fig. 2c).

The trapezoidation of the polygon is useful in two ways. We can find whether a givenpoint is inside the polygon inO(log N) time by doing binary search on the trapezoids.Moreover, we can obtain a point inside the polygon in constant time. For the purposes ofthe visibility computation algorithm, trapezoidation is sufficient. However, the triangulationis eventually used for rendering the visible portions. While there are linear time algorithmsto triangulate simple polygons, we chose Seidel’s algorithm because there was an efficientinhouse implementation of the algorithm available to us [NM95].

2.2. Partitioning a Simple Polygon

We use algorithms for partitioning a simple polygon into connected components basedon a set of nonintersecting chains. Given a simple polygonP and a number of nonin-tersecting polygonal chainsC, our task is to partitionP. We make no assumptions onC except that each chainci ∈C in itself should partitionP. This algorithm is an impor-tant component of our overall algorithm. We use it to partition the domain of parametricpatches using silhouette and visibility curves. The goal of this algorithm is to subdividethe original domain of a patch into components each of which have a simple boundary(no interior loops). We make use of this fact later in the paper. The problem at hand hasbeen studied extensively in the computational geometry literature and has been solved ef-ficiently (namely, Bentley–Ottmann [BO79]O((n+ k) log n) or Chazelle–Edelsbrunner[CE88] O(n log n+ k)). Typically, these algorithms compute the arrangement of the linesegments and then generate the partitions by walking the faces of the arrangement. We haveimplemented a slightly modified version. A feature of our implementation is that alongwith the partitions, we also obtain the connectivity between them. This is used to verify thecorrectness of our results.

Let us assume for the sake of simplicity that the chains do not form a loop inside thepolygon. This is because partitions surrounding the loop will not have a simple boundaryanymore. We treat this case separately in our algorithm. Details are provided at the endof the algorithm description. The main idea in this algorithm is the fact that since thechains are nonintersecting, each of the partitioned regions starts and ends at intersection

Page 6: Partitioning Trimmed Spline Surfaces into NonSelf-Occluding Regions for Visibility Computation

288 KRISHNAN AND MANOCHA

FIG. 3. Partitioning a polygon with polygonal chains.

points (with the polygon) of the same chain. Figure 3 shows a simple polygonP and threenoninteresecting chainsa, b, andc. Since the vertices of each chain are given in a specificorder, we shall assume that to be the direction of the chain. The algorithm works in twosteps.

• Find all the intersection points of each chain with the polygon and number them ac-cording to the order in which they occur. We associate three fields with each intersectionpoint—the chain corresponding to each intersection point (type), the number of the inter-section point within the chain (rank), and whether the chain was coming in or going outof the polygon at this point (in or out). For example, the intersection pointa1 in the figurehastype=a, rank= 1, andin or out= outas its three fields. Thein or outfield is actuallyunnecessary becauserankhas that information. However, we use it for ease of description.• Given all the intersections, we traverse the polygon starting from an arbitrary vertex.

We use a stack as a data structure to compute the partitions. Let us assume that we starttraversing the polygon from vertexv0 in an anticlockwise order for the example given inthe figure. Given this traversal, we can order the intersection points around the polygon.In the example, the order would bea0, b3, b2, b1, c0, c1, b0,a3,a2,a1. As we proceed fromvertexvi to vi+1 in the polygon, we retrieve all the intersection points of the various chainswith the edge (vi , vi+1) in order. Ifq is an intersection point, letp be the point on the top ofthe stack. To determine ifq is pushedor p is popped, the following condition is checked.

if (q.type6= p.type)push(q);

else if ((q.rank - p.rank== 1) &&(q.in or out== out) &&(p.in or out== in))

pop(p);else if ((p.rank -q.rank== 1) &&

(p.in or out== out) &&(q.in or out== in))

pop(p);else push(q);

Page 7: Partitioning Trimmed Spline Surfaces into NonSelf-Occluding Regions for Visibility Computation

PARTITIONING TRIMMED SPLINE SURFACES 289

If p is popped, thenp andq form a partition of the polygon. The corresponding partitionis read out and the chain of vertices betweenp andq is appended to the vertex (this chainwill be a part of the partition that involves this vertex) currently on top of the stack (the onethat was belowp). After traversing the polygon completely once, we would have obtainedall the partitions.

At this point, we have partitioned the domain using chains that end at the boundary ofthe domain. However, any loop that is present inside the domain must lie inside one of thepartitioned regions. Each of the loops (starting from the innermost if the loops are nested)themselves form a partition. The remaining part of the region (they have boundaries withmultiple components) are broken into simple regions by introducing a simple horizontalcut from the loop to the boundary of the partition or the next outer loop. The horizontal cutis made by choosing a point whosey-coordinate lies between they extents of the loop anddrawing a horizontal through the point.

2.3. Curve/Surface Intersection

Computing the intersection of curves and surfaces is needed to find whether a givensurface is occluded. Given a surface patch that is guaranteed to have the same visibility forall its points, we shoot a ray from a point on the surface to the viewpoint and determine if theray intersects any other surface (between the chosen point on the surface and the viewpoint).If the number of intersections is 0, the surface is visible; otherwise it is not. We use somerecent algorithms for these intersections based on eigenvalue computations [MD94]. Thealgorithm we describe here can be used for any degree curve and its complexity is cubic inthe degree of the curve. Therefore, even though the problem of ray–surface intersection ismuch simpler, our algorithm does not suffer because of its generality.

Given a parametric representation of a surfaceF(s, t) (F:R2→R3) of degreem× n, wecompute its implicit representation using resultant methods [Dix08] and obtain a matrixformulationM (x, y, z, w). The entries of this matrix are linear polynomials inx, y, z, w(of the formax+ by+ cz+ dw) so that the set

{(x, y, z, w): Det(M (x, y, z, w)) = 0} (1)

is exactly the surface in homogeneous coordinates. One main advantage of this method isthat we do not have to compute the large determinant which is highly unstable numerically.We substitute the parameterization of the curve, sayG(u)= (X(u), Y(u), Z(u), W(u)) ofdegreed, into M (x, y, z, w) and obtain a univariate matrix polynomialM (u). The problemof intersection computation is thus reduced to computing the roots of the nonlinear matrixpolynomialM (u). The algorithms that are used to compute the roots of a matrix polynomialrequire a power basis representation. However, our polynomial which is in the Bernsteinbasis is easily converted to power basis by the transformationu= u

1− u . The resulting matrixM (u) can be represented as

M (u) = ud Md + ud−1Md−1+ · · · + uM1+ M0, (2)

whereMi ’s are matrices of order 2mnwith numeric entries. Furthermore, the roots of the

Page 8: Partitioning Trimmed Spline Surfaces into NonSelf-Occluding Regions for Visibility Computation

290 KRISHNAN AND MANOCHA

matrix polynomial,M (u), are identical with the eigenvalues of

C =

0 I2mn 0 · · · 0...

......

......

0 0 0 · · · I2mn

−M0 −M1 −M2 · · · −Md−1

, (3)

whereM i =M−1d M i [GLR82]. In caseMd is singular or ill-conditioned, the intersection

problem is reduced to a generalized eigenvalue problem [MD94]. Algorithms to computeall the eigenvalues are based on QR orthogonal transformations [GL89].

2.4. Power Iterations

We use marching methods to trace the visibility curves (see Section 5). At each iter-ation, we pose the problem as an eigenvalue problem and use local methods to computepoints on the curve. Power iteration is a fundamental local technique used to computeeigenvalues and eigenvectors of a matrix. Given a diagonalizable matrix,A, there existsan orthonormal matrixX(=[x1, x2, . . . , xn]) so thatX−1AX =Diag(λ1, λ2, . . . , λn) and|λ1|> |λ2| ≥ · · · ≥ |λn|. Given a randomly chosen unit vectorq0, thepower methodpro-duces a sequence of vectorqk as

zk = Aqk−1; qk = zk/‖zk‖∞; sk = qTk Aqk,

where‖zk‖∞ refers to theL∞ norm of the vectorzk. sk converges to the largest eigenvalueλ1, andqk converges to the corresponding eigenvectorx1.

The basic idea of power iterations can be used and modified to obtain the eigenvalue of amatrixA that is closest to a given guesss. It actually corresponds to the largest eigenvalue ofthe matrix (A− sI )−1. Instead of computing the inverse explicitly (which can be numericallyunstable), we useinverse poweriterations. Given an initial unit vectorq0, we generate asequence of vectorsqk as

Solve(A − sI )zk = qk−1; qk = zk/‖zk‖∞; sk = qTk Aqk.

We use inverse power iterations to trace curves. We formulate the curve as the singularset of a matrix polynomial and reduce it to an eigenvalue problem. Given a point on thecurve, we approximate the next point on the curve by taking a small step size in a directiondetermined by the local geometry of the curve. We use this point as our guess and use inversepower iterations to converge back to the curve. The reader is requested to refer to [KM97]to get more details on how we perform curve tracing using inverse power iterations.

3. OVERVIEW OF THE ALGORITHM

In this section, we briefly describe the algorithm. The details of individual steps of thealgorithm are described in later sections. For the purposes of this paper, we assume that theviewpoint is situated atz=−∞ so that the projection on the viewing plane is orthographic.Given a scene composed of nonintersecting B´ezier patches and a viewpoint, we perform

Page 9: Partitioning Trimmed Spline Surfaces into NonSelf-Occluding Regions for Visibility Computation

PARTITIONING TRIMMED SPLINE SURFACES 291

the following steps for each patch.

• Compute thesilhouettecurves on the patch for the given viewpoint.• Partition the domain of the B´ezier patch as determined by the silhouette curves. The

boundary of each partition is made up of the original boundary curves or the computedsilhouette curves.• For each partition so generated,

—Trace outvisibility curves (curves in the interior of the partition that have the sameprojection on the image plane as that of the boundary curves) by following the boundarycurves.

—Partition the domain according to the visibility curves

The set of partitions obtained after this algorithm is executed satisfy the property that eachpartition is nonself-occluding. This fact is proved later in Theorem 2. The main complexityof the algorithm lies in the computation of the silhouette and visibility curves. We use acombination of symbolic and numeric techniques to evaluate these curves explicitly.

4. SILHOUETTES

Silhouette computation forms an important part of visibility algorithms for curved sur-faces. Intuitively speaking, a silhouette curve is the locus of all points on the surface wherethe normal vector to the surface at that point is perpendicular to the line of sight. We shallrestrict our discussion to surfaces whose silhouette (from a given viewpoint) is a curve onthe surface. The property of the silhouette curve is that it subdivides the surface into frontand back facing regions. However, as shown in Fig. 1, silhouettes alone are not sufficientto determine all visible regions. In this section, we describe an algorithm to compute thesilhouette curve on a parametric (represented as B´ezier [Far93]) patch efficiently. Some as-sumptions are in order about the kind of surfaces we deal with. We assume that the surfacesare not self-intersecting purely for exposition. In the most general case, we can compute theintersection curve using the algorithm described in [KM95] and partition the surface intononintersecting pieces.

We assume for the sake of simplicity that the viewpoint is located at (0, 0,−∞) and thatthe view direction is toward the positivez-axis. It is easy to see that even if this is not thecase, we can always achieve it by applying an appropriate perspective transformation tothe control points of the parametric surfaceF(s, t). We also require that all the surfaces aredifferentiable everywhere. We formulate the silhouette curve as an algebraic plane curve inthe domain ofF(s, t).

4.1. Formulation of the Silhouette Curve

Let F(s, t) denote the parametric (differentiable) surface and letφ1(s, t), φ2(s, t) andφ3(s, t) denote the mappings from the parametric space to (x, y, z) space.

F(s, t) = 〈X(s, t),Y(s, t), Z(s, t),W(s, t)〉φ1(s, t) = X(s, t)

W(s, t), φ2(s, t) = Y(s, t)

W(s, t), φ3(s, t) = Z(s, t)

W(s, t).

In the rest of the paper, we shall drop the (s, t) suffixes from all the functions for moreconcise notation. Thez-component of the normal at an arbitrary point on the surface is

Page 10: Partitioning Trimmed Spline Surfaces into NonSelf-Occluding Regions for Visibility Computation

292 KRISHNAN AND MANOCHA

given by the determinant

Nz =∣∣∣∣φ1s φ1t

φ2s φ2t

∣∣∣∣, (4)

whereφi s andφi t denote the partial derivatives of the appropriate functionφi with respectto s andt .

φ1s =(W Xs −WsX)

W2

φ1t =(W Xt −Wt X)

W2

φ2s =(WYs −WsY)

W2

φ2t =(WYt −WtY)

W2.

On the silhouette curve,Nz= 0. SinceW(s, t)> 0, we can express the plane curve rep-resenting the silhouette as the determinant

Nz =∣∣∣∣(W Xs −WsX) (W Xt −Wt X)

(WYs −WsY) (WYt −WtY)

∣∣∣∣ = 0. (5)

Expanding the determinant and rearranging the terms, we can express it as the singularset of the matrixM (s, t)

M (s, t) =

X(s, t) Y(s, t) W(s, t)

Xs(s, t) Ys(s, t) Ws(s, t)

Xt (s, t) Yt (s, t) Wt (s, t)

= 0. (6)

The singular set ofM (s, t) is the values ofs andt which make it singular.There is a special case that needs to be addressed here. Earlier, we said that the silhouette

curve partitions the surface into front (Nz< 0) and back facing (Nz> 0) regions. However,there could be cases whenNz starts positive, touches zero, and then becomes positive again.Saddle-shaped regions (oriented appropriately) are examples of these cases. These are notthe generic case and small perturbations of the view direction are enough to remove thesecases [RE93]. Further, the algebraic formulation of the silhouette curve above does notpreclude the possibility of singularities (self-intersections). We believe that singularitiesof silhouettes (in object space) are also nongeneric and a similar perturbation of the viewdirection should remove them. However, we are not able to prove it or provide a goodreference for it. For the rest of this paper, we will assume that the silhouette curve does notcontain singular points.

4.2. Silhouette Computation

Let us denote the projected silhouette curve corresponding to Det(M (s, t)) by D(s, t). Ifthe Bezier patchF(s, t) is of degreem in s andn in t , the curveD(s, t) has degree at most3(m+ n). This is a high degree algebraic curve. Our task is to evaluate this curve (i.e., itstopological type) completely and efficiently inside our domain of interest.

Page 11: Partitioning Trimmed Spline Surfaces into NonSelf-Occluding Regions for Visibility Computation

PARTITIONING TRIMMED SPLINE SURFACES 293

Our approach is based on marching along the curve using local geometric properties ofthe curve. All marching methods require at least one point on every component of the curveinside the domain of interest. We adopt different methods to compute starting points onopen(intersect the boundary of the domain) andclosedcomponents (or loops).

To determine starting points on open components we substitute one of the variabless ort with the value 0 or 1. This reduces the silhouette equation to a polynomial equation in onevariable and this has only a discrete set of solutions. We find all theboundary silhouettepointsby determining the roots of four univariate matrix polynomials,M (0, t),M (1, t),M (s, 0), andM (s, 1). This problem can be reduced to finding the eigenvalues of an associatedcompanion matrix (see Eq. (3)) [MD94]. We retain only the real solutions that lie withinthe domain.

A much harder problem is to determine if the silhouette curve has loops inside the domainof the surface, and if so to compute at least one point on each of them. We use the fact thatthe silhouette curve is an algebraic plane curve that is continuous in the complex domain.Since the coefficients of the curve are real, all complex portions of the curve must occur inconjugate pairs. We characterize certain special points on loops (turning points) as placeswhere two complex conjugate paths merge to form a real component. Our idea of loopdetection is captured by the following lemma which we state without proof.

LEMMA 1 [KM97]. If the curve in the real domain[0, 1]× [0, 1] consists of a closedcomponent, then two arbitrary complex conjugate paths meet at one of the real points(corresponding to a turning point) on the loop.

By following all the complex paths inside the domain we can locate at least a single pointon each loop. Figure 4 shows the presence of loops in silhouette curves.

FIG. 4. Loops in silhouette curves.

Page 12: Partitioning Trimmed Spline Surfaces into NonSelf-Occluding Regions for Visibility Computation

294 KRISHNAN AND MANOCHA

Given a point on each component of the silhouette curve, marching methods obtainapproximations of the next point by taking a small step size in a direction determined bythe local geometry of the curve. Based on the approximate value, these algorithms use localiterative methods to trace back on to the curve to evaluate the silhouette curve. We havedeveloped an algorithm based on inverse power iterations (Section 2.4) totrace the curve.The details of the complete algorithm are presented in [KM97]. Our algorithm evaluatesthe silhouette curve at discrete steps to create a piecewise linear approximation. The tracingalgorithm has been implemented and tested on a variety of examples and has proved to befairly robust.

Consider a patchF(s, t) of degreem in s andn in t , and letN= max{m, n}. Then thecompanion matrix (Eq. (3)), whose eigenvalues correspond to the roots of the matrix poly-nomial) is of order 3N. We use the QR method [GL89] to compute all the eigenvalues. Thenumber of floating point operations performed is 8N3. In inverse power iterations, the twomain operations are theLU decomposition of the matrix and solving the resulting triangu-lar systems. Usually theLU decomposition is computed using Gaussian elimination and ittakes about13 N3 operations (without pivoting). Solving each triangular system costs about12 N2 operations. As a result, the inverse power iteration takes about1

3 N3+ k2 N2 operations,

wherek is the number of iterations. It turns out that the structure of the companion matrix canbe used to reduce the number of operations forLU decomposition (9N operations) as wellas to solve the triangular systems (12kN operations, wherek is the number of iterations).

4.3. Surface Partitioning Based on Silhouettes

Figure 5 shows the silhouette curve on an example patch along with the curve on itsdomain. It is clear from the figure that the silhouette divides the patch into front and backfacing regions.

LEMMA 2. LetC⊂<3 be the set of silhouette curves on a given surfaceS⊆<3 from agiven viewpoint. ThenScan be decomposed intoC and disjoint regions whose boundariesare surface boundaries and/or parts ofC.

Proof. Let p be a point onS−C (i.e., Nz(p) 6= 0). Define the (open) regionRp asfollows:

Rp = {s ∈ S− C | ∃ a continuous path fromp to s without crossingC}.Rq is defined similarly for a pointq /∈Rp, if such aq exists. Now we have to show thatRp∩Rq 6= ∅. Let us assume the contrary. Then there exists a pointr ∈Rp∩Rq. This implies

FIG. 5. Silhouette curve on the patch and the domain.

Page 13: Partitioning Trimmed Spline Surfaces into NonSelf-Occluding Regions for Visibility Computation

PARTITIONING TRIMMED SPLINE SURFACES 295

that there is a continuous path (without crossingC) from p to r andr to q, and hence fromp to q. This is a contradiction.

From the above lemma we can conclude thatS can be partitioned into a set of regionsR so that the boundaries of each region℘ ∈R consists of original surface boundariesand silhouette curves. The domain of each patch is represented as a simple polygon incounterclockwise order. For example, a complete tensor product B´ezier patch has its domainpolygon as{(0, 0), (1, 0), (1, 1), (0, 1), (0, 0)}. We then use ourpartition polygon(Section 2.2)routine to subdivide the domain into disjoint regions.

We now state without proof a fundamental theorem from vector calculus called theglobalinverse theorem, which provides the basis for our method [Ful78].

THEOREM 1 [Ful78]. Let F be a continuously differentiable mapping defined on anopen region D∈<2, with range R∈<2, and let its Jacobian be never zero in D. Supposefurther that C is a simple closed curve that, together with its interior, lies in D, and thatFis one-to-one on C. Then the image0 of C is a simple closed curve that, together with itsinterior, lies in R. Furthermore, F is one-to-one on the closed region consisting of C and itsinterior, so that the inverse transformation can be defined on the closed region consistingof 0 and its interior.

The importance of this theorem lies in the fact that properties of the entire region can beargued by looking at the properties of its boundary.

Consider the vector fieldM :<2→<2 so that

M (s, t) = (φ1(s, t), φ2(s, t)),

where theφ′i s were defined in the previous section. Intuitively, the vector fieldM projectsa point on the surfaceF(s, t) on to thexy plane. We now relate the silhouette curve and theJacobian of the functionM .

LEMMA 3. LetM be a mapping from<2→<2 such thatM (s, t)= ( X(s,t)W(s,t) ,

Y(s,t)W(s,t) ). Then

the locus of all points on the surface that have vanishing Jacobians corresponds exactly tothe silhouette curve.

Proof. The JacobianJ(s, t) of M is given by

J(s, t) =∣∣∣∣∣

(W Xs−WsX)W2

(W Xt−Wt X)W2

(WYs−WsY)W2

(WYt−Wt Y)W2

∣∣∣∣∣ . (7)

However whenJ= 0, we get the same equation as Eq. (5). That is precisely the equationof the silhouette curve in the domain of the surface. Therefore, the silhouette curves are theonly places on the surface where the Jacobian ofM vanishes.

We denote the set of regions obtained after partitioning byR. Henceforth, we shall beconsidering a single element of this set℘ ∈ R. Because of the previous lemma, we canconclude that the interior of each℘ ∈ R has no vanishing Jacobian. Therefore, theglobalinverse theoremapplies on each of the regions inR.

5. VISIBILITY CURVES

In the previous section, we described a method to compute silhouettes. We shall nowintroduce the notion ofvisibility curvesand elucidate their role in determining visibility.

Page 14: Partitioning Trimmed Spline Surfaces into NonSelf-Occluding Regions for Visibility Computation

296 KRISHNAN AND MANOCHA

Consider a region℘ ∈ R. Let us denote the boundary of℘ by ∂℘ and the interior of℘,the open set℘− ∂℘, by int(℘).

DEFINITION 1. Given a region℘ ∈ R, the visibility curves on℘,V(℘), is defined as thelocus of points,

V(℘) = {pi | pi ∈ int(℘), ∃pb ∈ ∂℘,M (pi ) = M (pb)}.Intuitively speaking, visibility curves are the loci of all points which lie in the interior of

such a partition that have the same projection on the viewing plane as the boundary curvesof that partition. It is precisely at these points that the visibility of a patch changes.

LEMMA 4. The visibility curves on℘,V(℘) as defined above, indeed, form a set ofcurves.

Proof. We shall prove this part by contradiction. Let us assume that there exists an iso-lated pointpi ∈V(℘). But by definition, there must be a pointpb ∈ ∂℘ such thatM (pi )=M (pb). We know that∂℘ is a continuous closed curve. Consider a small displacement,δ ∈<2, of pb along ∂℘. Since M is a smooth map, there exists anε ∈<2 such thatM (pi + ε)=M (pb+ δ) [Mun75]. In fact, in the limitδ going to zero,ε≈ J−1(pi )J(pb)δ,whereJ andJ−1 are the Jacobian and the Jacobian inverse ofM respectively. Further, weknow thatJ−1(pi ) exists becausepi ∈ int(℘). Therefore,pi cannot be an isolated point, andthe visibility curves indeed form a curve.

COROLLARY 1. The set of visibility curves V(℘) induces a partition on the region℘.

Proof. Follows from Lemma 2.

Figure 6 shows a helical patch with no silhouettes. Figure 7 shows the visibility curvescomputed on the same patch. The visibility curves are also shown in the domain of the patch.The patch in Fig. 6 is deliberately transformed to provide a better view. Lemma 4 providesa constructive method to find all the visibility curves. Given the boundary curves of eachregion, we have to determine all the intersections among the various curves comprisingthe boundary projections (including self-intersections). We are assuming that the boundarycurves are in general position so that their projections intersect only in discrete points.

FIG. 6. A helical patch with no silhouettes.

Page 15: Partitioning Trimmed Spline Surfaces into NonSelf-Occluding Regions for Visibility Computation

PARTITIONING TRIMMED SPLINE SURFACES 297

FIG. 7. Visibility curves on the helical patch.

These points form the endpoints for all the visibility curves inside the region℘. Once allthe endpoints are found, we use marching methods to trace all the curves. Details of themethod are discussed in the next section.

Given℘ ∈ R, we construct a partition of℘ induced by the visibility curves using thepartition polygonroutine. Let us denote the set of regions obtained after partitioning byK℘ . If k∈ K℘, ∂k denotes the boundary of the regionk and int(k), k− ∂k, is the interiorof k. Figure 8a shows the partition of the helical patch based on the visibility curves. InFig. 8b, we see the image ofK2 underM . It is clear that the boundary of this region is notone-to-one (as seen in the case of pointsa anda′). However, in the next theorem, we willargue that the interior of each regionk∈ K℘ is one-to-one under the mapM .

THEOREM2. Let k∈ K℘ . Thenint(k) is one-to-one under the projection mappingM .

Proof. The main idea of the proof is to show that any simple closed curveC in int(k)is one-to-one underM . Since the Jacobian never vanishes in the interior of each region, weuse theglobal inverse theoremto conclude that the entire region on and inside the closedcurveC is one-to-one. Since the choice ofC is arbitrary, we can conclude that int(k) isone-to-one. We would like to reiterate our earlier assumption thatthe boundary curves arein general position so that their projections intersect only in discrete points.

Consider an arbitrary curveC ∈ int(k). Assume thatC is not one-to-one under the projec-tion mappingM . Therefore, there exists at least two pointsp1 andp2 so thatM (p1)=M (p2).Consider a simple path (say path1) from p1 to a boundary pointpb1. SinceM is a continuous

FIG. 8. (a) Partitioning based on visibility curves (b) Image of region K2 underM .

Page 16: Partitioning Trimmed Spline Surfaces into NonSelf-Occluding Regions for Visibility Computation

298 KRISHNAN AND MANOCHA

map, there must be a corresponding path (path2) from p2. Let us assume that path1 reachesthe boundary pointpb1 first, and that the point on path2 that has the same projection aspb1

is p′2. SinceM (pb1)=M (p′2), p′2 cannot be an interior point (otherwise, it is part of thevisibility curve). So p′2 is also a boundary point. However, sincepb1 was an arbitrarilychosen point, all its choices must lead top′2s on the boundary. But this contradicts ourassumption about boundary curves being in general position. Hence any curveC must beone-to-one underM .

UsingC and theglobal inverse theorem, we conclude that the interior of every regionk∈ K℘ is one-to-one under the projection mappingM .

6. COMPUTATION OF VISIBILITY CURVES

In this section, we will describe our method to compute visibility curves. The wholealgorithm is split into two parts—(i) finding all the intersections on the projected boundarycurves and (ii) tracing each visibility curve.

6.1. Boundary Intersections

After partitioning based on silhouettes, we obtain regions whose boundaries consist ofparts of the original boundary curves of the patch and the silhouette. Let us consider a singleregion whose boundary is made up of a set of original boundary curves,B, and another setof silhouette curves,L. Each element ofB is represented by the corresponding B´ezier curveand the interval of parameter values in which it is valid. We also maintain the projection ofthe boundary curves as a polygonal chain in order to obtain its intersections with silhouettecurves. Each element ofL and its projection underM is maintained just as a polygonalchain. In order to compute all the intersection points on the projection, we must detect allself-intersections in each element ofB andL and intersections between elements. Overall,there are only four basic categories in which all of them fall. We shall discuss each one indetail.

1. Intersection between two boundary curves: Basically, this case reduces to findingthe intersection points between two B´ezier plane curves. Letf andg be two plane curvesparametrized byu andv respectively. The two equations that give rise to the solution are

X f (u)

Wf (u)= Xg(v)

Wg(v)

Yf (u)

Wf (u)= Yg(v)

Wg(v),

whereX f ,Yf ,Wf , andXg,Yg,Wg are the componentwise functions off andg respectively.By eliminatingu from these two equations using Sylvester’s resultant [Sed83], we obtaina matrix polynomial inv. We can reduce it to an eigenvalue problem of an associatedcompanion matrix [MD94]. After all the eigenvalues (using LAPACK routines) are obtainedonly the solutions that lie within the intervals are taken. Using this method, all the intersectionpoints are determined accurately and efficiently.

2. Self-intersections on boundary curves: Consider a plane B´ezier curvef=〈X(s),Y(s),W(s)〉 of degreen. This curve self-intersects if there exist parameter valuesu and

Page 17: Partitioning Trimmed Spline Surfaces into NonSelf-Occluding Regions for Visibility Computation

PARTITIONING TRIMMED SPLINE SURFACES 299

v, u 6= v, so that

X(u)

W(u)= X(v)

W(v)

Y(u)

W(u)= Y(v)

W(v).

Sinceu= v is a trivial solution to the above pair of equations, we eliminate it by dividingeach of the equations by the factor (u− v). Thus the equations become

(X(u)W(v)− X(v)W(u))

(u− v)= 0

(Y(u)W(v)− Y(v)W(u))

(u− v)= 0.

These are two equations each of degreen− 1 in u andv. By eliminatingu from theseequations using Sylvester’s resultant, we get a (2n− 2)× (2n− 2) matrix polynomial ofdegreen− 1. We reduce this problem to one of finding eigenvalues of an associated matrixof size 2(n− 1)2. This gives all the self-intersections on the boundary curve.

3. Intersection between two silhouette curves: The equations governing the solution setare

D(s, t) = 0

D(u, v) = 0

X(s, t)

W(s, t)= X(u, v)

W(u, v)

Y(s, t)

W(s, t)= Y(u, v)

W(u, v),

whereD(s, t)= 0 is the equation of the silhouette curve defined in Section 4.2 andX,Y, ZandW are the componentwise functions of the patch. These four equations in four variables,typically, give rise to a zero dimensional solution set. However, it is not feasible to solve thesefour equations directly because of the high degree of the silhouette curve and the algebraiccomplexity of the resulting system. Therefore, we use piecewise linear approximation ofall silhouette curves as the first iteration in our intersection computation. We treat thechain as a set of line segments. Each intersection point obtained is then refined using localminimization methods (we use Powell’s method) using the energy equationE(u, v, s, t)given by

E(u, v, s, t) = D2(s, t)+ D2(u, v)+ (X(s, t)W(u, v)− X(u, v)W(s, t))2

+ (Y(s, t)W(u, v)− Y(u, v)W(s, t))2.

Self-intersections are also found using the same method. We found that in practice thismethod of finding intersections works well and gives accurate results.

4. Intersection between boundary curve and silhouette: Consider a boundary curvefparametrized byu. X f ,Yf , Z f , andWf are the scalar functions ofF. X f , for example,could represent any one of the four functions,X(s, 0), X(s, 1), X(0, t), andX(1, t). The set

Page 18: Partitioning Trimmed Spline Surfaces into NonSelf-Occluding Regions for Visibility Computation

300 KRISHNAN AND MANOCHA

FIG. 9. Generation of visibility curves near the boundaries.

of intersection points of this curve with the silhouette satisfy

D(s, t) = 0

X(s, t)

W(s, t)= X f (u)

Wf (u)

Y(s, t)

W(s, t)= Yf (u)

Wf (u).

In this case, we use the approximated version of the boundary curves (as a piecewise linearchain) and apply a similar procedure as in the previous case. The minimization equation inthis case is

E(u, s, t) = D2(s, t)+(X(s, t)Wf (u)−X f (u)W(s, t))2+(Y(s, t)Wf (u)−Yf (u)W(s, t))2.

Accuracy of silhouette curve.The use of a piecewise linear approximation for the sil-houette curves may seem limiting considering that points on this curve are used as startingpoints for tracing visibility curves. However, the points are not chosen from the linear ap-proximation. We maintain the linear chain only to compute a starting guess to the actualpoint on the silhouette curve quickly. Given this approximation, we refine it using the an-alytic form of the silhouette curve and the boundary curve (if given in analytic form). Therefinement is carried out until the point is within a user specified tolerance to the actualsilhouette curve. (The generation of visibility curves near the boundaries is shown in Fig. 9.)

Once all the intersection points are computed, we are ready to trace all the visibilitycurves.

6.2. Tracing Visibility Curves

Given the starting point of each visibility curve, we are ready to trace it.Figure 10 shows the tracing of a visibility curve in the domain of a region and projection

space. Pointsa and b have the same projection pointp. Let the curveb2 in Fig. 10bcorrespond to the portion of the boundary froma to c (see Fig. 10a). The boundary of theregion on the domain is represented as a polygon (obtained after we partition based onsilhouettes). Let us assume that at an arbitrary step of the tracing method we are at pointeandb2 and atf on the visibility curve. Botheand f have the same projection pointp1. Letthe domain coordinates off be (fu, fv). If we move frome to g on b2, the point f must

Page 19: Partitioning Trimmed Spline Surfaces into NonSelf-Occluding Regions for Visibility Computation

PARTITIONING TRIMMED SPLINE SURFACES 301

FIG. 10. Tracing of visibility curves.

move to a neighboring point,h, on the visibility curve. If (gu, gv) are the domain coordinatesof g, let x= X(gu,gv )

W(gu,gv )andy= Y(gu,gv )

W(gu,gv ). X,Y, andW are the componentwise functions of the

original patch. We would like to find (hu, hv) in the local neighborhood of (fu, fv) such that

X(hu, hv)

W(hu, hv)− x = 0

Y(hu, hv)

W(hu, hv)− y = 0.

Eliminatinghv from these two equations results in a matrix polynomial inhu. The singularset of this polynomial determineshu, and from the corresponding eigenvector, we can findhv. However, a lot of unnecessary work can be avoided by observing that (hu, hv) is inthe neighborhood of (fu, fv). Using fu as a guess tohu and building a correspondingeigenvector out offv, we perform inverse power iterations (described in Section 2.4) toobtain (hu, hv).

It is possible to use Newton’s method to solve the above set of equations. However, as wewill see, this method has some problems. Let us assume that pointb on the boundary is on asilhouette. We proved that a silhouette point is one where the Jacobian vanishes. Therefore,Newton’s method does not perform well close to silhouette points. Inverse power iterationsuffers from no such problem.

Tracing terminates when one of the following two cases occur.

• (hu, hv) goes out of the region, or• (hu, hv)= (gu, gv).

The first case occurs more often. For example, if we trace further from pointc, d goesout of the region. Therefore, after each step of the tracing process we have to check forcontainment of a point inside an arbitrary (simple, but not necessarily convex) polygon.This could be very expensive unless some processing is done on the polygon. We useSeidel’s trapezoidation algorithm (created during triangulation) to create trapezoids byhorizontal decomposition inO(N) time. Any point can then be determined inside or outsidein O(log N) time.

The second case occurs when the visibility curve hits the boundary curve and thencontinues along it. This will not be detected in the previous case and, hence, has to bechecked explicitly.

Page 20: Partitioning Trimmed Spline Surfaces into NonSelf-Occluding Regions for Visibility Computation

302 KRISHNAN AND MANOCHA

FIG. 11. (a) Partitioning of patch in Fig. 1 based on visibility curves and (b) visibility curves in the domain.

After computing all the visibility curves, we calculate all the partitions induced by thevisibility curves in each region using thepartition polygonroutine. Figures 11 and 12 showthe partitioning of the patches in Fig. 1 and Fig. 6 using the visibility curves. Each partitionthus obtained is one-to-one under projection. It transforms the original visibility probleminto one ofn polygon-like surfaces in space. The analysis given so far partitions all partsof a given surface, while only the far regions need to be partitioned. A simple check beforetracing visibility can reduce the time and space complexity of the algorithm.

6.3. Device Independence

In this paper, we have shown that the silhouette and visibility curves, which form thetrimming boundaries of the surface patches, are algebraic curves. Most of these curvesdo not have a rational parameterization. Therefore, we use tracing based algorithms toevaluate these curves. There has been significant work done in the symbolic and algebraiccomputation literature on evaluating these curves to any desired precision [AB88, Abh90,BHHL88, FS90, BR90, KM95]. In many ways, that is the best we can do to provide anexplicit representation of these curves. As compared to earlier approaches, we provide thedevice with both the piecewise linear approximation and the analytic representation of this

FIG. 12. Partitioning of patch in Fig. 6 based on visibility curves.

Page 21: Partitioning Trimmed Spline Surfaces into NonSelf-Occluding Regions for Visibility Computation

PARTITIONING TRIMMED SPLINE SURFACES 303

curve. If the resolution provided by the approximation generated by the tracing algorithmis not sufficient, the device has to evaluate intermediate points using the analytic form andsimple minimization strategies [KKMN95]. Our approach is certainly not very efficient,but the complexity of the problem precludes us from using any other simpler method.

7. APPLICATION TO HIDDEN SURFACE REMOVAL

In the previous sections, we looked at the visibility problem for a single patch. After wepartition each patch based on silhouettes and visibility curves, each region is one-to-oneunder the projection operation and can now be treated as a polygon. We shall, therefore, referto each such region as aface. Recently fast randomized algorithms have been developedthat can handle this problem for polygonal models [Mul89]. We present a slight variationof Mulmuley’s algorithm for the sake of completeness in the Appendix.

Our final goal is to output trimmed patches of the scene that are visible from the givenviewpoint. We shall assume for simplicity that the faces input to this algorithm are noninter-secting. If they are intersecting, we may have to compute all the pairwise surface intersection[KM97] and split them into nonintersecting faces. It is possible that in many curved surfacemodels (generated using constructive solid geometry or surface fitting algorithms), adjacentpatches almost always share sections of boundary curves. This can cause problems whenone such curve is projected into the domain of the other and curve–curve intersectionsare computed. However, if any extra information about the adjacency between the variouspatches in the model is known, we can avoid the computation of such degenerate intersec-tions. Many of the current modelers are capable of producing the adjacency information ofsuch models.

7.1. Implementation and Performance

The algorithm to compute nonoverlapping regions using silhouette and algebraic curveshas been implemented. The algorithm uses existing EISPACK and LAPACK routines forsome of the matrix computations. At each stage of the algorithm, we can compute boundson the accuracy of the results obtained based on the accuracy and convergence of numericalmethods adopted like eigenvalue computation, power iteration, and Gaussian elimination.Our implementation uses EISPACK [GBDM77] routines (in Fortran) to compute the eigen-values of matrices. The algorithm was run on a SGI Onyx workstation with a R4400 CPUwith 128 Mbytes of main memory.

We have not implemented the randomized algorithm for performing the general hiddensurface removal. Currently, our system takes a set of parametric patches and computesits decomposition into nonoverlapping regions. Table 1 shows the performance of our

TABLE 1

Performance of Our Algorithm

Degree of Curve computation Running timeModel patch time (in ms) (in ms)

Fig. 4 3× 3 27.8 53.0Fig. 5 3× 3 23.6 42.4Fig. 6 1× 8 17.3 33.2

Page 22: Partitioning Trimmed Spline Surfaces into NonSelf-Occluding Regions for Visibility Computation

304 KRISHNAN AND MANOCHA

algorithm on certain parametric patches. The time shown for curve computation is the totaltime for silhouette and visibility curve generation, and the column for running time givesthe total time taken by the algorithm for curve generation and producing the nonoverlappingpartitions.

8. CONCLUSION

We have presented an algorithm for computing the visible portions of a scene com-posed of curved (parametric) surfaces from a given viewpoint. We have also given amethod to compute the silhouette curve efficiently and correctly. We introduced the no-tion of visibility curves, which are used to partition each patch into nonoverlapping regions.The algorithm has been implemented in floating point arithmetic and performs well inpractice.

9. APPENDIX

We now present a slight variation of the hidden surface removal algorithm of Mulmuley[Mul89].

The input to the algorithm is a set ofn faces with their boundaries represented as acollection of Bezier curves and piecewise linear chains. We also have the entire face bound-ary as a closed simple polygon. It will be used during the tracing step. We provide anoverview of the algorithm first. Let us represent the set of faces byH ={h1, h2, . . . , hn}.Let Vi denote the collection of visible regions afteri faces are added in random. Theifaces already added are kept in the setQ. We want to computeVn. After i steps of thealgorithm, we maintainVi . At the (i + 1)st step, we pick a random facehi+1 from theset H\Q. For each face inVi , we find all the boundary intersections with the facehi+1

using the method described in the previous section. Let us consider a specific intersec-tion point (p,q) such thatp lies on the boundary of one of the faces inVi andq lieson the boundary ofhi+1. If the z coordinate ofp is less than that ofq (p lies in frontof q), then project the boundary curve on whichp lies onhi+1, or else project the otherway around. Tracing is accomplished by inverse power iteration, which was described inboth Sections 2.4 and 6. The equations used to trace these curves are exactly the sameas those used in Section 6. Tracing is done for all the intersection points. We partitionappropriate faces by their projection curves and locate a pointr inside each of the parti-tioned faces. Since all points inside one region are now entirely visible or not, we checkonly on one point. We shoot a ray from the pointr to−∞ in thez direction and find thenumber of intersections with faces ofVi ∪ {hi+1}. The curve/surface intersection methodused is described in Section 2.3. If the number of intersections is 0, this face is added;otherwise it is discarded. All the faces that were not partitioned in step (i + 1) are retainedin Vi+1. After all then faces are added, we obtainVn. We shall now provide the pseudo-code for this algorithm. For case of writing the pseudo-code, we shall assume that wehave a routineproject boundarycurvesthat takes two faces as parameters and computesall the projected boundary curves as described above. It returns 0 if there are no bound-ary curves between the two faces; otherwise, it returns 1. We also have another routinecalledpartition facethat computes the partition of the face using the projected boundarycurve.

Page 23: Partitioning Trimmed Spline Surfaces into NonSelf-Occluding Regions for Visibility Computation

PARTITIONING TRIMMED SPLINE SURFACES 305

Q=∅;H ={h1, h2, . . . , hn};V0=∅;for (i = 1; i ≤ n; i ++){

hi = random face from setH\Q;Q= Q∪ hi ;Vi =∅;T =∅; /∗ stores faces that are partitioned in this iteration∗/for each facef ∈Vi−1 do {

j = projectboundarycurves(f, hi ,&c);if ( j == 0)Vi = Vi ∪ { f };else{T = T ∪ partition face(f, c);T = T ∪ partition face(hi , c);}}for each facet ∈ T do {

(sx, sy, sz)= some point insidet ;r = semi-infinite ray from (sx, sy, sz) to (sx, sy,−∞);if (ray intersectioncount(r ) == 0) Vi =Vi ∪ {t};}}outputVn;

Figure 13 shows how our algorithm works. Each face boundary is made up of curves andpiecewise straight lines. The dark broken lines shown in Fig. 13a are the projected boundary

FIG. 13. Visibility computation on a set of faces.

Page 24: Partitioning Trimmed Spline Surfaces into NonSelf-Occluding Regions for Visibility Computation

306 KRISHNAN AND MANOCHA

curves drawn on the objects behind. Figure 13b shows the result of the algorithm on the setof faces. The complexity of this algorithm varies according to the order in which the facesare added. Therefore, by adding the faces randomly we reduce the expected running time ofthe algorithm. The output of the algorithm is a set of visible portions of patches representedas trimmed surfaces. The accuracy of the trimming curve can be adjusted according to thepreferences of the user by changing the step size in the tracing method.

ACKNOWLEDGMENTS

We thank David Banks, David Eberly, Brice Tebbs, and Turner Whitted for all the productive discussions andhelpful insights. We also thank Brice Tebbs for providing the patch in Figs. 1 and 5.

REFERENCES

[AB88] S. S. Abhyankar and C. Bajaj, Computations with algebraic curves, inLecture Notes in ComputerScience, Vol. 358, pp. 279–284, Springer-Verlag, Berlin/New York, 1988.

[Abh90] S. S. Abhyankar,Algebraic, Geometry for Scientists and Engineers, Am. Math. Soc. Providence,1990.

[BHHL88] C. L. Bajaj, C. M. Hoffmann, J. E. Hopcroft, and R. E. Lynch, Tracing surface intersections,Comput.Aided Geom. Design5, 1988, 285–307.

[BO79] J. L. Bently and T. A. Ottmann, Algorithms for reporting and counting geometric intersections,IEEETrans. Comput.C-28, 1979, 643–647.

[BR90] C. Bajaj and A. Royappa, The ganith algebraic geometry toolkit, inLecture Notes in ComputerScience, Vol. 429, pp. 268–269, Springer-Verlag, Berlin/New York, 1990.

[Can88] J. F. Canny,The Complexity of Robot Motion Planning, ACM doctoral dissertation award, MIT Press,Cambridge, MA, 1988.

[CCW93] L. Chen, S. Chou, and T. C. Woo, Separating and intersecting spehrical polygons: Computing machin-ability on three, four and five axis numerically controlled machines,ACM Trans. Graph.12(4), 1993,305–326.

[CE88] B. Chazelle and H. Edelsbrunner, An optimal algorithm for intersecting line segments in the plane,in Proc. 29th Annual IEEE Sympos. Found. Comput. Sci., 1988, pp. 590–600.

[Dix08] A. L. Dixon, The eliminant of three quantics in two independent variables, inProceedings of LondonMathematical Society, 1908, Vol. 6, pp. 49–69, 209–236.

[Dor94] S. E Dorward, A survey of object-space hidden surface removal,Internat. J. Comput. Geom. Appl.4, 1994, 325–362.

[EC90] G. Elber and E. Cohen, Hidden curve removal for free form surfaces,Comput. Graph.24(4), 1990,95–104.

[EC93] G. Elber and E. Cohen, Second order surface analysis using hybrid symbolic and numeric operators,ACM Trans. Graph.12(2), 1993, 160–178.

[EC94] G. Elber and E. Cohen,Exact Computation of Gauss Maps and Visibility Sets for Freeform Surfaces,Technical report CIS 9414, Computer Science Department, Technion University, 1994.

[Far93] G. Farin,Curves and Surfaces for Computer Aided Geometric Design: A Practical Guide, AcademicPress, San Diego, 1993.

[FDHF90] J. Foley, A. Van Dam. J. Hughes, and S. Feiner,Computer Graphics: Principles and Practice,Addison–Wesley, Reading, MA, 1990.

[FS90] R. T. Farouki and T. Sakkalis, Singular points of algebraic curves,J. Symb. Comput.9(4), 1990,457–483.

[Ful78] W. Fulks,Advanced, Calculus: An Introduction to Analysis, Wiley, New York, 1978.

[GBDM77] B. S. Garbow, J. M. Boyle, J. Dongarra, and C. B. Moler,Matrix Eigensystem Routines—EISPACKGuide Extension, Vol. 51. Springer-Verlag, Berlin, 1977.

Page 25: Partitioning Trimmed Spline Surfaces into NonSelf-Occluding Regions for Visibility Computation

PARTITIONING TRIMMED SPLINE SURFACES 307

[GL89] G. H. Golub and G. F. Van Loan,Matrix Computations, Johns Hopkins Press, Baltimore, 1989.

[GLR82] I. Gohberg, P. Lancaster, and L. Rodman,Matrix Polynomials, Academic Press, San Diego, 1982.

[GO87] R. H. Guting and T. Ottmann, New algorithms for special cases of the hidden line elimination problem,Comput. Vision Graph. Image Process.40, 1987, 188–204.

[GWT94] J. G. Gan, T. C. Woo, and K. Tang, Spherical maps: Their construction, properties, and approximation,ASME Trans. J. Mech. Design116(2), 1994.

[HG77] G. Hamlin and C. W. Gear, Raster-scan hidden surface algorithm techniques,Comput. Graph.11,1977, 206–213.

[Hor84] C. Hornung, A method for solving the visibility problem,IEEE Comput. Graph. Appl.4(7), 1984,26–33.

[KKMN95] S. Kumar, S. Krishnan, D. Manocha, and A. Narkhede, High speed and high fidelity visualization ofcomplex csg models, inBCS International Conference on Visualization and Modeling, Leeds, UK,1995, pp. 228–249.

[KM95] S. Krishnan and D. Manocha, Numeric-symbolic algorithms for evaluating one-dimensional algebraicsets, inProceedings of International Symporium on Symbolic and Algebraic Computation, 1995,pp. 59–67.

[KM97] S. Krishnan and D. Manocha, An efficient surface intersection algorithm based on the lower dimen-sional formulation,ACM Trans. Graph.16(1), 1997, 74–106.

[KM98] S. Krishnan and D. Manocha, Decomposing spline surfaces into non-overlapping regions for visi-ble surface computation, inProc. of Indian Conference on Computer Vision, Graphics and ImageProcessing(Santanu Chaudhury and Shree Nayar, Eds.), pp. 207–215, 1998.

[Li81] L. Li, Hidden-line algorithm for curved surfaces,Comput. Aided Design20(8), 1981, 466–470.

[MD94] D Manocha and J. Demmel, Algorithms for intersecting parametric and algebric curves I: Simpleintersections,ACM Trans. Graph.13(1), 1994, 73–100.

[Mul89] K. Mulmuley, An efficient algorithm for hidden surface removal,Comput. Graph.23(3), 1989, 379–388.

[Mul90] K. Mulmuley, An efficient algorithm for hidden surface removal, ii. Report TR-90-31, University ofChicago, Chicago, Illinois, 1990.

[Mun75] J. R. Munkers,Topology: A First Course, Prentice Hall, New York, 1975.

[NM95] A. Narkhede and D. Manocha, Fast polygon triangulation based on seidel’s algorithm, inGraphicsGems V(A. Paeth, Ed.), pp. 394–397, Academic Press, San Diego, 1995.

[PVY92] F. P. Preparata, J. S. Vitter, and M. Yvinec. Output sensitive generation of the perspective view ofisothetic par allelepipeds,Algorithmica8, 1992, 257–283.

[RE93] M. F. Roy and T. Van Effeleterre, Aspect graphs of algebraic surfaces, inProceedings of InternationalSymposium on Symbolic and Algebraic Computation, Kiev, Ukraine, 1993.

[RS88] J. H. Reif and S. Sen, An efficient output-sensitive hidden-surface removal algorithms and its paral-lelization, inProc. 4th Annu. ACM Sympos. Comput. Geom., 1998, pp. 193–200.

[Sed83] T. W. Sederberg,Implicit and Parametric Curves and Surfaces, Ph.D. thesis, Purdue University, 1983.

[Sei91] R. Seidel, A simple and fast randomized algorithm for computing trapezoidal decompositions andfor triangulating polygons,Comput. Geom. Theory Appl.1(1), 1991, 51–64.

[SSS74] I. Sutherland, R. Sproull, and R. Schumaker, A characterization of ten hidden-surface algorithms,Comput. Surveys6(1), 1974, 1–55.

[TW93] B. Tebbs and T. Whitted, Numerical design limited, personal communication, 1993.

[Woo94] T. Woo, Visibility maps and spherical algorithms,Comput. Aided Design26(1), 1994, 6–16.