# Hidden line removal

Solid objects are usually modeled by polyhedra in a computer representation. A face of a polyhedron is a planar polygon bounded by straight line segments, called edges. Curved surfaces are usually approximated by a polygon mesh. Computer programs for line drawings of opaque objects must be able to decide which edges or which parts of the edges are hidden by an object itself or by other objects, this problem is known as **hidden line removal**.

The first known solution to the hidden-line problem was devised by Roberts^{[1]} in 1963. However, it severely restricts the model: it requires that all objects be convex; in 1966 Ivan E. Sutherland ^{[2]} listed 10 unsolved problems in computer graphics. Problem number seven was *"Hidden line removal"*; in terms of computational complexity, this problem was solved by Devai ^{[3]} in 1986.

Models, e.g., in computer-aided design, can have thousands or millions of edges. Therefore, a computational-complexity approach, expressing resource requirements, such as time and memory, as the function of problem sizes, is crucial. Time requirements are particularly important in interactive systems.

Problem sizes for hidden line removal are the total number *n* of the edges of the model and the total number *v* of the visible segments of the edges. Visibility can change at the intersection points of the images of the edges. Let *k* denote the total number of the intersection points of the images of the edges. Both *k* = Θ(*n*^{2}) and *v* = Θ(*n*^{2}) in the worst case^{[3]} but usually *v* < *k*.

## Algorithms[edit]

Hidden-line algorithms published before 1984 ^{[4]} ^{[5]} ^{[6]} ^{[7]} divide edges into line segments by the intersection points of their images, and then test each segment for visibility against each face of the model. Assuming a model of a collection of polyhedra with the boundary of each topologically equivalent to a sphere and with faces topologically equivalent to disks, according to Euler's formula, there are Θ(*n*) faces. Testing Θ(*n*^{2}) line segments against Θ(*n*) faces takes Θ(*n*^{3}) time in the worst case.^{[3]} Appel's algorithm^{[4]} is also unstable, because an error in visibility will be propagated to subsequent segment endpoints.^{[8]}

Ottmann and Widmayer ^{[9]} and Ottmann, Widmayer and Wood^{[10]} proposed *O*((*n* + *k*)log^{2} *n*) time hidden-line algorithms. Then Nurmi ^{[11]} improved the running time to *O*((*n* + *k*)log *n*). These algorithms take Θ(*n*^{2}log^{2} *n*), respectively Θ(*n*^{2}log *n*) time in the worst case, but if *k* is less than quadratic, can be faster in practice.

Any hidden-line algorithm has to determine the union of Θ(*n*) hidden intervals on *n* edges in the worst case, as Ω(*n*log *n*) is a lower bound for determining the union of *n* intervals ^{[12]} it appears that the best one can hope to achieve is Θ(*n*^{2}log *n*) worst-case time and hence Nurmi's algorithm is optimal.

However, the log *n* factor was eliminated by Devai,^{[3]} who raised the open problem if the same, optimal *O*(*n*^{2}) upper bound existed for hidden surface removal. This problem was solved by McKenna ^{[13]} in 1987.

The intersection-sensitive algorithms ^{[9]}^{[10]}^{[11]} are mainly known in the computational-geometry literature, the quadratic upper bounds are also appreciated by the computer-graphics literature: Ghali ^{[14]} notes that the algorithms by Devai and McKenna *"represent milestones in visibility algorithms"* breaking a theoretical barrier from *O*(*n*^{2}log *n*) to *O*(*n*^{2}) for processing a scene of *n* edges.

The other open problem raised by Devai ^{[3]} that whether there exists an *O*(*n* log *n* + *v*)-time hidden-line algorithm, where *v*, as noted above, is the number of visible segments, is still unsolved at the time of writing.

## Parallel algorithms[edit]

In 1988 Devai^{[15]} proposed an *O*(log *n*)-time parallel algorithm using *n*^{2} processors for the hidden-line problem under the concurrent read, exclusive write (CREW) parallel random-access machine (PRAM) model of computation. As the product of the processor number and the running time is asymptotically greater than Θ(*n*^{2}), the sequential complexity of the problem, the algorithm is not work-optimal, but it demonstrates that the hidden-line problem is in the complexity class NC, i.e., it can be solved in polylogarithmic time by using a polynomial number of processors.

Hidden-surface algorithms can be used for hidden line removal, but not the other way around. Reif and Sen ^{[16]} proposed an *O*(log^{4} *n*)-time algorithm for the hidden-surface problem, using *O*((*n* + *v*)/log *n*) CREW PRAM processors for a restricted model of polyhedral terrains, where *v* is the output size.

In 2011 Devai ^{[17]} published an *O*(log *n*)-time hidden-surface, and a simpler, also *O*(log *n*)-time, hidden-line algorithm. The hidden-surface algorithm, using *n*^{2}/log *n* CREW PRAM processors, is work-optimal.

The hidden-line algorithm uses *n*^{2} exclusive read, exclusive write (EREW) PRAM processors, the EREW model is the PRAM variant closest to real machines. The hidden-line algorithm does *O*(*n*^{2}log *n*) work, which is the upper bound for the best sequential algorithms used in practice.

Cook, Dwork and Reischuk ^{[18]} gave an Ω(log *n*) lower bound for finding the maximum of *n* integers allowing infinitely many processors of any PRAM without simultaneous writes. Finding the maximum of *n* integers is constant-time reducible to the hidden-line problem by using *n* processors. Therefore, the hidden-line algorithm is time optimal.^{[17]}

## References[edit]

**^**L. G. Roberts.*Machine perception of three-dimensional solids*. PhD thesis, Massachusetts Institute of Technology, 1963.**^**I. E. Sutherland. Ten unsolved problems in computer graphics.*Datamation*, 12(5):22–27, 1966.- ^
^{a}^{b}^{c}^{d}^{e}F. Devai. Quadratic bounds for hidden line elimination; in*Proc. 2nd Annual Symp. on Computational Geometry*, SCG ’86, pp 269–275, New York, NY, USA, 1986. - ^
^{a}^{b}A. Appel, the notion of quantitative invisibility and the machine rendering of solids. In*Proc. 22nd National Conference*, ACM ’67, pp 387–393, New York, NY, USA, 1967. **^**R. Galimberti and U. Montanari. An algorithm for hidden line elimination.*Commun. ACM*, 12(4):206–211, April 1969.**^**Ch. Hornung. An approach to a calculation-minimized hidden line algorithm.*Computers & Graphics*, 6(3):121–126, 1982.**^**P. P. Loutrel. A solution to the hidden-line problem for computer-drawn polyhedra.*IEEE Trans. Comput*., 19(3):205–213, March 1970.**^**J. F. Blinn. Fractional invisibility.*IEEE Comput. Graph. Appl*., 8(6):77–84, November 1988.- ^
^{a}^{b}Th. Ottmann and P. Widmayer. Solving visibility problems by using skeleton structures; in*Proc. Mathematical Foundations of Computer Science 1984*, pp 459–470, London, UK, 1984. Springer-Verlag. - ^
^{a}^{b}Th. Ottmann, P.Widmayer, and D.Wood. A worst-case efficient algorithm for hidden-line elimination.*Internat. J. Computer Mathematics*, 18(2):93–119, 1985. - ^
^{a}^{b}O. Nurmi. A fast line-sweep algorithm for hidden line elimination.*BIT*, 25:466–472, September 1985. **^**M. L. Fredman and B.Weide, on the complexity of computing the measure of U[a_{i}, b_{i}].*Commun. ACM*, 21:540–544, July 1978.**^**M. McKenna. Worst-case optimal hidden-surface removal.*ACM Trans. Graph.*, 6:19–28, January 1987.**^**Sh. Ghali. A survey of practical object space visibility algorithms. SIGGRAPH Tutorial Notes, 1(2), 2001.**^**F. Devai. An*O*(log*N*) parallel time exact hidden-line algorithm.*Advances in Computer Graphics Hardware II*, pp 65–73, 1988.**^**J. H. Reif and S. Sen. An efficient output-sensitive hidden surface removal algorithm and its parallelization; in*Proc. 4th Annual Symp. on Computational Geometry*, SCG ’88, pp 193–200, New York, NY, USA, 1988.- ^
^{a}^{b}F. Devai. An optimal hidden-surface algorithm and its parallelization; in*Computational Science and Its Applications*, ICCSA 2011, volume 6784 of*Lecture Notes in Computer Science*, pp 17–29. Springer Berlin/Heidelberg, 2011. **^**S. Cook, C. Dwork, and R. Reischuk. Upper and lower time bounds for parallel random access machines without simultaneous writes.*SIAM J. Comput*., 15:87–97, February 1986.

## External links[edit]

- Patrick-Gilles Maillot's Thesis an extension of the Bresenham line drawing algorithm to perform 3D hidden lines removal; also published in MICAD '87 proceedings on CAD/CAM and Computer Graphics, page 591 - ISBN 2-86601-084-1.
- Vector Hidden Line Removal An article by Walter Heger with a further description (of the pathological cases) and more citations.