Efficient Rasterization of Implicit Functions
Total Page:16
File Type:pdf, Size:1020Kb
Efficient Rasterization of Implicit Functions Torsten Möller and Roni Yagel Department of Computer and Information Science The Ohio State University Columbus, Ohio {moeller, yagel}@cis.ohio-state.edu Abstract Implicit curves are widely used in computer graphics because of their powerful fea- tures for modeling and their ability for general function description. The most pop- ular rasterization techniques for implicit curves are space subdivision and curve tracking. In this paper we are introducing an efficient curve tracking algorithm that is also more robust then existing methods. We employ the Predictor-Corrector Method on the implicit function to get a very accurate curve approximation in a short time. Speedup is achieved by adapting the step size to the curvature. In addi- tion, we provide mechanisms to detect and properly handle bifurcation points, where the curve intersects itself. Finally, the algorithm allows the user to trade-off accuracy for speed and vice a versa. We conclude by providing examples that dem- onstrate the capabilities of our algorithm. 1. Introduction Implicit surfaces are surfaces that are defined by implicit functions. An implicit functionf is a map- ping from an n dimensional spaceRn to the spaceR , described by an expression in which all vari- ables appear on one side of the equation. This is a very general way of describing a mapping. An n dimensional implicit surfaceSpR is defined by all the points inn such that the implicit mapping f projectspS to 0. More formally, one can describe by n Sf = {}pp R, fp()= 0 . (1) 2 Often times, one is interested in visualizing isosurfaces (or isocontours for 2D functions) which are functions of the formf ()p = c for some constant c. Different classes of implicit surfaces are of importance. Implicit surfaces that are defined by a polyno- mial are called algebraic surfaces. Since almost all continuous functions can be approximated by poly- nomials, algebraic surfaces represent a powerful class. Since polynomials have been studied and understood fairly well, one has a better mathematical handle at algebraic surfaces. Another special class of implicit surfaces have density functions as their defining functions. Density functions decrease exponentially with increasing distance to a certain center point. The models where these functions find usage usually arise in the study of physical phenomena, e.g. atom models. Blinn [4] was one of the first to try to visualize these surfaces on a computer. They became to be known as Blinn’s “Blobby Model” or Metaballs. Yet another model which is gaining importance is the discrete data set. Such data set is commonly gen- erated by various medical scanners such as MRI and CT. These data sets can also be seen as implicit functions, wheref ()p = v and v is the scanned value at the location p. We assume that if p is not on a grid point then some sort of interpolation from neighboring grid points defines v at p. Rendering implicit surfaces is very difficult and computationaly very expensive. Usually existing algo- rithms to render implicit surfaces work only for special cases or special sets of functions. In fact, to date there is no such algorithm that can render arbitrary implicit surfaces accurately and in a stable and timely manner. Algorithms for rendering 3D implicit surfaces can be classified into three groups: representation trans- forms, ray tracing, and surface tracking. The first approach tries to transform the problem from implicit surfaces to another representation which is easier to display such as polygon meshes [1][5][10][15] or parametric representations [16]. The second approach to rendering of implicit surfaces is to ray-trace them. Efficient ray-object intersection algorithms have been devised for algebraic surfaces [11], meta- balls [4], and a class of functions for which Lipschitz constants can be efficiently computed [12][14]. The third approach to rendering implicit functions is to scan convert or discretize the function. Seder- 3 berg and Zundel [17] introduced such a scan line algorithm for a class of implicit functions that can be represented by Bernstein polynomials. When it comes to drawing 2D implicit functions (curves) an attractive approach is to follow the path of the curve. The algorithm starts at a seed point on the curve. It then looks at the pixels adjacent to the seed point to see if any of them is the next pixel along the curve. Various algorithms exist which mainly differ in the method they use to find the next pixel along the curve. One way to find the next pixel is based on digital difference analysis (DDA). A lot of work has been done in this field and the most popular algorithm applying this technique are Bresenham's and the mid- point line and circle drawing algorithms [8]. The rate of change in x and y is computed through fast inte- gral updates of dx and dy, which are then used as decision variables to determine the next pixel center. This idea was generalized for algebraic curves by Hobby [13]. One problem of this approach is that the inherent integer arithmetic can only be exploited for a small set of algebraic functions. Furthermore, this algorithm is not able to deal properly with self intersecting curves. Hobby assumes that these inter- section points are given by the user. A different way to continue a curve would be to evaluate the underlying function at the center of the neighboring pixels to find the one with the smallest absolute function value. This idea has been imple- mented by Jordan et. al. [9] and was improved by Chandler [7]. Since there are only eight neighboring pixels, eight function evaluations are the maximum needed to find the next pixel on the curve. Since we will very likely be traveling in the same direction we have been traveling when we picked the current pixel, Chandler tests first the pixel continuing in the same direction, then its neighbors etc. For most 'nicely' behaving functions two to three function evaluations per pixel will be sufficient. To increase accuracy, Chandler prefers to look for a sign change rather than the smallest absolute value. Therefore, he evaluates the function not at pixel centers but rather halfway in between pixels. Although the algo- rithm does not depend on the actual description of the function and therefore is applicable to arbitrary functions, it is still not able to deal with self intersecting functions. To deal with such points the algo- rithm requires user intervention. Alternatively, it includes a brute-force Monte Carlo method to visual- ize the positive and negative regions of the function. Finally, if the curve enters and leaves the pixel in- 4 between the same two neighboring sample points, this algorithm will not be able to register a sign change and therefore fail. For density functions, Arvo et. al. applied a numerical method known as the predictor-corrector method [2]. Their main goal is the rendering of iso-curves of medical data sets. In this paper we introduce an efficient and more robust predictor-corrector method. Our algorithm deals with self intersecting curves properly and increases the efficiency of the algorithm to less than one function evaluation per pixel on the average. Finally, unlike existing curve tracking methods, our algorithm can be applied to a large family of implicit functions including selfintersecting functions with at most two branches at the inter- section point. 2. The Predictor-Corrector Method The predictor-corrector method is a well known numerical algorithm which has its origin in solving ordinary differential equations and bifurcation theory. Arvo and Novins [2] used a two dimensional standard method for extracting isocurves in a 2D medical image. Although the predictor-corrector method offers ways to detect and properly deal with self intersecting curves and curves “very close” to themselves, Arvo and Novins did not explore these capabilities. The predictor-corrector method is a numerical continuation method (tracking algorithm). The goal is to find a point set which represents a discretized approximation of a curve that is defined by some implicit function as in Equation (1). As the name suggests, the predictor-corrector method consists of two steps. In the predictor step we take a (more or less sophisticated) guess of a point on the curve, denoted bypp . Depending on how much thought and work we put into predicting the pointpp , it will be closer or far- ther away from an actual point on the curve. Depending on the assumption we make about the curve and its actual shape, we will not be able to always accurately predict an exact point on the curve. In the corrector step we use our predicted pointpp as a starting point for an iterative method that converges to an actual point on the curve. We denote this new, corrected point, bypc . We repeat these two steps until we tracked the whole curve. The resulting discrete point set can then be displayed on a screen. 5 There are many different ways to implement the predictor or corrector steps. We use the standard Euler- Newton method with an adaptive step size and introduce techniques to handle selfintersecting curves. 2.1 The Predictor Step The focus of the predictor step is to find a pointpp that is very close or even on the curve, so that the costs for the corrector step are reduced or even eliminated. If we already know points on the curve, we can approximate the curve through a polynomial and get a new approximate for this curve through extrapolation or interpolation. Finding the very first point on the curve is not always easy. One usually has some understanding of the kind of function one tries to discretize and can therefore provide an initial seed value to the algorithm.