Fast Computation of Generalized Voronoi Diagrams
Fast Computation of Generalized Voronoi Diagrams
Kenneth E. Hoff III, Tim Culver, John Keyser, Ming Lin, Dinesh Manocha
University of North Carolina at Chapel Hill
Department of Computer Science
Figure 1: Image of the sampled distance functions for two point 4 THE DISTANCE FUNCTIONS
sites. Uniform point sampling induces a rectangular cell subdivision
of space. For both 2D and 3D, our discrete Voronoi diagram computation
has been reduced to finding a 3D polygonal mesh approximation
to the distance function of a Voronoi site over a planar 2D
rectangular grid of point samples. The error in the approximation
must be bounded so that by rendering this mesh using graphics
hardware, we can efficiently and accurately compute the distances
between the site and all of the point samples.
In this section, we describe the distance functions associated with
various sites, and provide efficient methods for meshing these
functions within a specified error tolerance.
a b
Figure 3: The distance meshes used for a point (left) and a line
segment (right). The XY-plane containing the site is shown above
each mesh.
4.1.1 Points in 2D
The distance function for a point in the plane is a right circular Figure 5: The per-feature Voronoi diagram of a quadrilateral (left).
cone. We approximate cones as a triangle fan proceeding radially The corresponding distance mesh (right).
outward from the apex (Figures 3a and 4-left). A point’s Voronoi
region can potentially extend to any portion of the region of Polygons are rendered as a series of linear segments connected at
interest, and thus the radius at the cone’s base must be of size M√2 the vertices. Each edge and vertex is a feature. For the vertices,
if the scene is contained in an M×M square.The mesh’s radial lines rendering a triangle fan connecting two adjacent edges, rather than
lie on the cone. The maximum error in distance occurs at the cone a full point distance mesh cone, saves on the total number of
base between adjacent vertices. Because the cone is right circular, triangles computed and ensures that the distance meshes for
the error in approximating the circular base as viewed from above adjacent features join smoothly. See Figure 5-right for an
is equal to the error in distance. illustration.
z d
y y
x x
4.2.2 Line Segments in 3D Figure 9: A bounded-error distance mesh for the line-segment site
(left) and the point site (right).
The graph of the distance function for a line segment site is an
elliptical cone (Figure 7). The apex of the cone lies at the
intersection of the segment's line with the slice, and the cone’s 4.3 Generalization to Curved Sites
eccentricity is determined by the relative angle of the line and the
slice. The 3D region of influence of a line segment lies between The exact distance function for a curved site can be rather
two parallel planes through the endpoints, since a point outside complicated, and for splines or algebraic curves is a high-degree
these planes is closer to one of the endpoints than to the segment. algebraic function. We simplify this by creating a linear
tessellation of the curved site, and then meshing the distance
function of this approximation. We can use algorithms such as in
[Filip87] and [Kumar96] to obtain bounded-error tessellations.
Figure 10 shows the mesh for a Bézier curve. Since the mesh for a
linear segment is exact, the distance error for any of the linear
segments is just the error in the deviation of the line from the
z d
y y
original curve. The endpoints of the curve must be treated as
x x points, just as for the line segment. The distance mesh for the
“joints” between linear segments is a portion of the radial mesh of
Figure 7: A line-segment site and its region of influence in a slice triangles. An overall maximum error bound of ε can be obtained
(left). The corresponding conical distance function (right). for the entire curve by:
• tessellating the curve into linear segments with maximum error
4.2.3 Points in 3D bound of ε;
The distance function for a point site is shown in Figure 8. Its
• rendering the distance mesh for the linear segments; and
graph is one sheet of a hyperboloid of revolution of two sheets. If
the point lies in the slice, the distance function is a cone rather • treating the endpoints and joints as points, and rendering each
than a hyperboloid. The region of influence for a single point is point distance mesh with maximum error bound of ε.
the entire slice.
This approach generalizes to 3D surfaces, which can be tesselated
into a polygonal mesh. The error is bounded in a similar way.
z d
y y
x x
Figure 8: A point site and its region of influence in a slice (left). The
corresponding hyperbolic distance function (right).
4.2.4 Meshes for Line Segments and Points in 3D Figure 10: The Voronoi diagram of a Bézier curve and 5 points
The construction of bounded-error meshes for the line-segment (left). The distance mesh for the Bézier curve that has been
tessellated into 16 segments (right).
and point distance functions is detailed in [Hoff99]. The method
attempts to minimize the complexity of the mesh by committing
the maximum allowable error ε in each mesh cell. The structure of 4.4 Weighted and Farthest-site Diagrams
the mesh depends only on the resolution of the Voronoi diagram,
defined by the ratio of the diameter M of the model to the In a weighted Voronoi diagram, the distance functions are
maximum meshing error ε. The mesh structure is precomputed; additively or multiplicatively weighted [Okabe92]. Translation of
during the Voronoi diagram construction, the mesh is constructed a distance mesh along the distance axis accounts for additive
weights. Linear scaling along the distance axis accounts for neighbors that are a different color from the current pixel's. All
multiplicative weights. In 2D, this is equivalent to changing the visited pixels are marked and avoided in the recursion.
angle of the cone or tent. Scaling the distance mesh also scales the
meshing error. This algorithm also finds the Voronoi neighbors–pairs of sites that
share a Voronoi boundary. This concept is useful in a wide variety
In a farthest-site Voronoi diagram, the farthest site from each of applications, including computing the dual of the ordinary
point is found. Unlike in the nearest-site diagram, the distance Voronoi diagram–the Delaunay triangulation. The boundary
function monotonically decreases as we move away from the site. finding algorithms find pairs of adjacent pixels with different
We obtain the proper distance relationships by negating the colors. The sites corresponding to those two colors are reported to
distance functions. In practice, however, we need only reverse the be Voronoi neighbors. Connecting Voronoi neighbors with line
depth-test (less-than to greater-than) and change the depth segments constructs the Delaunay triangulation.
initialization from ∞ to 0.
6 SOURCES OF ERROR
5 BOUNDARIES AND NEIGHBORS
In this section we analyze all sources of error in our approach, and
A continuous Voronoi diagram representation usually specifies the discuss how to reduce this error. We consider two broad
Voronoi boundaries that separate the set of Voronoi regions. In categories: error in distance approximation and combinatorial
our discrete representation, we must search for the boundaries error.
using approaches similar to iso-surface extraction and root-finding
techniques [Bloom97]. However, instead of trying to bracket zero-
crossings between sample points where iso-surface functions 6.1 Distance Error
evaluate to values of opposite sign, we simply find the boundaries Distance error is the error in the distance computed from a pixel to
in the space between pixel samples of different color. Using the a site. There are three sources of distance error:
same approaches, we can either point-sample the boundary or
compute an approximate mesh representation. In order to increase • Meshing error, from approximating the true distance function
the precision, we must either use a higher overall resolution or by the distance mesh. We discussed how to bound this error in
adaptively refine. Section 4.
One approach is to examine each pair of adjacent cells in 2D or • Tessellation error, from tessellating a curved site into a number
3D. If the colors are different, the location between the samples is of linear sites. The tessellation algorithms presented in [Filip87,
marked as a point on the Voronoi boundary. The operation is very Kumar96] give tight bounds. Tessellation error is reduced by
simple and can be accelerated through image operations in using a finer approximation to the site.
graphics hardware.
• Hardware precision error, from the use of fixed-precision
Another approach is based on a continuation method that starts at arithmetic (integer or floating-point) during rasterization.
a point known to be on the boundary and walks along the Hardware precision error cannot be removed without resorting
boundary until all boundary points have been found [Bloom97]. to multiple-precision arithmetic, but hardware error is usually
Since we only compare locations near known boundaries, it is negligible compared to meshing error.
output sensitive. The correctness of the continuation method
depends on whether the Voronoi boundaries are connected. The These errors are additive–i.e. the error from one source is not
boundaries of a generalized Voronoi diagram of a collection of magnified by the other sources. The total distance error is at most
convex sites are always connected, so the method is correct for the sum of the errors from these three sources.
inputs consisting of point, line-segment, or convex polygonal
sites. The method may fail in the presence of curves, curved 6.2 Combinatorial Error
surfaces, or concave sites where the generalized Voronoi diagram
may have isolated components. Combinatorial error refers to qualitative error as opposed to
quantitative. For example, a pixel is assigned the wrong color, or
In this approach, at least one boundary point must be known as a the algorithm reports an incorrect pair of Voronoi neighbors.
“seed” value. Assuming convex sites, some Voronoi boundary There are three sources that contribute to combinatorial error:
passes through the edge of the bounded region in which we are
computing the diagram, so the method begins by examining every • Distance error, as described in the previous section. With
window border pixel. When all Voronoi boundaries are connected significant distance error, depth comparison at a pixel may
only one seed point is needed since all others can be reached from make a farther site appear closer, causing the pixel to be
that first point. Starting from a seed point, we recursively check all colored incorrectly.
• Resolution error, a result of discrete sampling. If this sampling right color. Assume that there is no Z-buffer precision error, and
is too coarse, we may miss some Voronoi regions or find that we can bound the maximum distance error by ε, as described
spurious neighbors. Handling resolution error is described earlier. For a pixel P colored with the ID of site A and with a
below. computed depth buffer value of D, we know that:
• Z-buffer precision error, the limitations of the number of bits of D - ε ≤ dist(P,A) ≤ D + ε
precision provided by the Z-buffer. Current graphics systems
have 24 bits or 32 bits of precision for each pixel in the Z- Furthermore, we know that for any other site B,
buffer, which is more than the 23 bits provided in standard D - ε ≤ dist(P,B)
floating-point. If the distances between two pixels cannot be
determined within that precision, the Z-buffer cannot From this information, we easily determine that
accurately choose the correct color. This effect is small when dist(P,A) ≤ dist(P,B) + 2ε
compared to the other two, but can be significant at very high
resolutions with very little distance error. A higher-precision Z- where dist(X,Y) means the distance from the center of pixel X to
buffer can be simulated in software at a significant loss in site Y. That is, if a pixel is colored with the ID of A, then site A is
efficiency. no more than 2ε farther from the pixel center than any other site.
The same bound holds in 3D.
Adaptive resolution allows us to “zoom in” on a region of interest,
reducing potential resolution error. This involves identifying a
window of interest and applying the appropriate linear 7 APPLICATIONS
transformation for zooming into that region. Figure 13 shows an
example. Note that when zooming in, sites outside of the viewing There are many applications that benefit from fast computation of
region can still have Voronoi regions inside the region. Thus, the a discrete Voronoi diagram, an approximation to the distance
“maximum distance to a site” must be adjusted appropriately when function, or both. We describe three that we have implemented.
computing the distance error bounds.
7.1 Motion Planning
Motion planning is a fundamental problem in robotics and
computational geometry, with applications to the animation of
digital actors, maintainability studies in virtual prototyping, and
robot-assisted medical surgery. The classic Piano Mover’s
problem involves finding a collision-free path for a robot moving
from one location (and orientation) to another in an environment
filled with obstacles. Numerous approaches to this problem have
Figure 13: Adaptive resolution allows us to zoom in on features that been proposed, some of which are based on generalized Voronoi
could otherwise be missed. diagrams [Latom91]. The underlying idea is to treat the obstacles
as sites. The Voronoi boundaries then provide paths of maximal
Resolution error can cause a number of combinatorial problems, clearance between the obstacles. Due to the practical complexity
such as missing the entire Voronoi region of a site. One such of computing generalized Voronoi diagrams, the applications of
example is shown in Figure 14 (left two images). When no cell has such planners have been limited to environments composed of a
the color of a particular site, we can separately render the site few simple obstacles.
itself, computing the pixels covering that site. By zooming around
Our discrete Voronoi computation algorithm can be applied to
those pixels, we will find pixels in the Voronoi region of that site.
motion planning in both static and dynamic environments. The
The same technique can be applied to cells in 3D. Another
Voronoi algorithm computes the approximate distance to the
problem arising from resolution error is incorrectly finding
nearest obstacle. The basic approach we implemented is based on
Voronoi neighbors (shown in Figure 14 – right two images). This
the potential field method, which repels a robot away from the
problem (when due solely to resolution error) can be alleviated by
obstacles and towards the goal using a carefully designed artificial
adaptively zooming in on all boundary pixels.
potential function. Other Voronoi diagram or distance-based
approaches are also possible. The details of our motion planning
algorithm are provided in [Hoff99].
We demonstrate our planner’s effectiveness in a complex
environment: the interior of a house, composed of over 100,000
triangles. We use the x- and y-components of the polygons to give
Figure 14: Problems caused by resolution error. An entire region in the 2D input primitives for our algorithm. The robot has three
the center will be missed since it does not hit any pixel centers (left degrees of freedom: x- and y-translation along the ground and
two images). The left and right regions, which should meet, become rotation about the z-axis. Color plate 2 and the video show a
disconnected after rasterization (right two images). sequence of piano motions automatically generated by our motion
planner in a static environment. Color plate 2 also shows an image
of the distance function for the house. We also apply our planner
6.3 Error Bounds to environments with moving obstacles. Our video demonstrates
the movement of a music stand through a house filled with
Distance error occasionally causes a pixel to be colored moving furniture. The entire potential field and the motion
incorrectly. However, in a certain sense, the pixel is “almost” the planning sequence are computed in real time.
400 Mhz Intel Pentium II PC with an Intergraph Intense 3D Pro
3410-T graphics accelerator was comparable to the SGI
performance. In fact, in boundary finding, neighbor finding, and
particle motion planning applications, the performance exceeded
the high-end SGI. This was mainly due to intense buffer readback
requirements. Each distance mesh must cover every pixel, so
performance is bounded by the graphics hardware’s pixel fill-rate.
For large numbers of input sites, therefore, the SGI outperforms
the PC.
When the distance-error tolerance is relaxed, the amount of
geometry rendered for each site can be reduced, slightly
Figure 15: Motion planning of falling particles. Sites are avoided by improving performance. However, the biggest gains are achieved
using the Voronoi diagram’s distance buffer (right) to create a by reducing the number of pixels filled. In many practical cases,
potential field. This same principle is used in the rigid-body planner. we can increase the performance significantly by bounding the site
distance functions to a maximum distance. This allows reduction
of the size of the distance meshes drawn so that only a portion of
7.2 Selection in Complex User Interfaces the screen is covered for each site. We exploit this observation to
obtain interactive rates in the 1,000-point example shown in color
Complex 2D user interfaces sometimes require quick plate 1, in the 10,000-point example shown in the video, and in the
determination of the object nearest to the cursor. The Voronoi general case for the computation of the potential field used in the
diagram of the interface can be used as a nearest-object lookup motion-planner. For closed higher-order primitives, such as
table indexed by sample points. Given the cursor position, it is polygons, we can further increase performance by restricting the
simple to find the nearest sample point, and thus the nearest distance function to only the inside or outside regions. This is
object. In some interfaces it may be desirable to know the distance useful in computing potential fields and medial axes.
to the selected object as well. We used this technique in our 2D
implementation to allow the user to interactively move sites with
the mouse. 9 CONCLUSIONS AND FUTURE WORK
We have presented a method for rapid computation of generalized
7.3 Mosaics discrete Voronoi diagrams in two and three dimensions using
We can use our approach for generating Voronoi diagrams to graphics hardware. We have presented techniques for creating a
create an interesting artistic effect called mosaicing. A mosaic is a mesh of the distance function for each site with bounded error, and
tiled image, where each tile has a single color. The Voronoi described how this distance mesh allows us to compute the
diagram of a point set can be used as a tiling [Haebe90]. Each Voronoi diagram rapidly. We have analyzed various sources of
Voronoi tile is colored with a color taken locally from the image. error, as well as how to bound or reduce those errors. Finally, we
In our implementation, each tile is colored by the image pixel have demonstrated a few applications using our approach.
closest to the point site (see color plate 1). Our algorithm can In the future, we would like to extend this work in the following
perform this operation very quickly, allowing dynamic mosaics in ways: generalizations of distance functions and site geometry,
which the mosaic tiling, the source image, or both may change in further applications, other distance meshing strategies, and more
real time. acceleration techniques for the 3D Voronoi volume computation.
By randomly distributing point sites across an image, we obtain an
effect similar to many mosaic filter effects seen in image editing ACKNOWLEDGEMENTS
programs. By clustering point sites around areas of higher detail,
we obtain a classic tiling seen in many real-life mosaics where Supported in part by ARO Contract DAAH04-96-1-0257 and
smaller tiles are used in areas of greater detail. DAAG55-98-1-0322, NSF Career Award CCR-9625217, NSF
grants EIA-9806027 and DMI-9900157, NIH Research Resource
Award 2P41RR02170-13, ONR Young Investigator Award and
8 IMPLEMENTATION Intel. We would also like to thank Sarah Hoff for extensive help
For the 2D case, we implemented a complete interactive system with editing and color plates, Chris Weigle for suggesting
incorporating all of the features and applications described here. mosaicing using 2D point Voronoi diagrams, the UNC-
Example output is shown throughout the paper. The video walkthrough group for the house model, and the reviewers for
demonstrates interactive computation of more complex diagrams. their helpful comments.
In 3D, we show results from a prototype system that uses a
simpler distance meshing strategy (see color plate 3 and the video REFERENCES
for example output).
[Auren91] F. Aurenhammer. Voronoi Diagrams: A Survey of a
We implemented the 2D and 3D systems in C++ using the Fundamental Geometric Data Structure. ACM Computing
OpenGL graphics library and the GLUT toolkit. Any graphics API Surveys, 23:345−405, 1991.
[Bloom97] J. Bloomenthal, C. Bajaj, J. Blinn, M-P. Cani-Gascuel, A.
specification that uses a standard Z-buffered interpolation-based Rockwood, B. Wyvill, and G. Wyvill. Introduction to Implicit
raster graphics system is sufficient to support the Voronoi diagram Surfaces. Morgan Kaufmann Publishers, Inc. San Francisco,
computation. Motion planning and the basic operations of CA. 1997.
boundary and neighbor finding require reading back of the color [Chian92] C–S. Chiang. The Euclidean Distance Transform. Ph. D. thesis,
Dept. Comp. Sci., Purdue Univ., West Lafayette, IN, August
and depth buffers. Our system runs, without source modification, 1992. Report CSD-TR 92−050.
on both an MS-Windows-based PC and a high-end SGI Onyx2
with InfiniteReality Graphics. Surprisingly, the performance on a
[Culve99] T. Culver, J. Keyser, and D. Manocha. Accurate Computation [Vleug95] J. Vleugels and M. Overmars. Approximating Generalized
of the Medial Axis of a Polyhedron. Proc. of the Fifth Symp. on Voronoi Diagrams in Any Dimension. Technical Report UU-
Solid Modeling and Applications. 1999. CS-1995-14, Dept. of Comp. Sci., Utrecht University, 1995.
[Dutta93] D. Dutta and C.M. Hoffmann. On the Skeleton of Simple CSG [Vleug96] J. Vleugels, V. Ferrucci, M. Overmars, and A. Rao. Hunting
Objects. Journal of Mechanical Design, ASME Transactions, Voronoi Vertices. Comp. Geom. Theory Appl., 6:329−354,
115(1):87−94, 1993. 1996.
[Diric50] G.L. Dirichlet. Uber die Reduktion der Positiven [Voron08] G.M. Voronoi. Nouvelles Applications des Paramètres
Quadratischen Formen mit Drei Unbestimmten Ganzen Continus à la Théorie des Formes Quadratiques. Deuxième
Zahlen. J. Reine Angew. Math., 40:209−27, 1850. Mémoire: Recherches sur les Parallélloèdres Primitifs. J.
[Filip87] D. Filip and R. Goldman. Conversion from Bézier-rectangles to Reine Angew. Math., 134:198−287, 1908.
Bézier-triangles. CAD, 19:25−27, 1987. [Woo97] M. Woo, J. Neider, and T. Davis. OpenGL Programming
[Fortu86] S. Fortune. A Sweepline Algorithm for Voronoi Diagrams. In Guide, Second Edition. Addison Wesley, 1997.
Proc. 2nd Annual ACM Symp. on Comp. Geom., pages
313−322, 1986.
[Goldf89] J. Goldfeather, S. Molnar, G. Turk, and H. Fuchs. Near Real-
time CSG Rendering Using Tree Normalization and Geometric
Pruning. IEEE Computer Graphics and Applications,
9(3):20−28, May 1989.
[Haebe90] P. Haeberli. Paint by Numbers: Abstract Image Representation.
Computer Graphics (SIGGRAPH ’90 Proc). vol. 25. pgs 207-
214.
[Held97] M. Held. Voronoi Diagrams and Offset Curves of Curvilinear
Polygons. Computer-Aided Design, 1997.
[Hoff99] K. Hoff, T. Culver, J. Keyser, M. Lin, and D. Manocha. Fast
Computation of Generalized Voronoi Diagrams Using
Graphics Hardware. Technical Report TR99-011, Dept. of
Comp. Sci., University of North Carolina at Chapel Hill, 1999.
[Hoffm94] C.M. Hoffmann. How to Construct the Skeleton of CSG
Objects. In A. Bowyer and J. Davenport, editors. Proc. of the
Fourth IMA Conference, The Mathematics of Surfaces,
University of Bath, UK, Sept. 1990. Oxford University Press,
New York, 1994.
[Inaga92] H. Inagaki, K. Sugihara, and N. Sugie. Numerically Robust
Incremental Algorithm for Constructing Three-dimensional
Voronoi Diagrams. In Proc. 4th Canad. Conf. Comp. Geom.,
pgs 334-339, 1992.
[Kumar96] S. Kumar, D. Manocha, and A. Lastra. Interactive Display of
Large NURBS Models. IEEE Trans. on Vis. and Computer
Graphics. vol 2, no 4, pgs 323-336, Dec 1996.
[Latom91] J.C. Latombe. Robot Motion Planning. Kluwer Academic
Publishers, 1991.
[Laven92] D. Lavender, A. Bowyer, J. Davenport, A. Wallis, and J.
Woodwark. Voronoi Diagrams of Set-theoretic Solid Models.
IEEE Computer Graphics and Applications, 12(5):69−77, Sept
1992.
[Lee82] D.T. Lee. Medial Axis Transformation of a Planar Shape.
IEEE Trans. Pattern Anal. Mach. Intell., PAMI−4:363−369,
1982.
[Lengy90] J. Lengyel, M. Reichert, B.R. Donald, and D.P. Greenberg.
Real-time Robot Motion Planning Using Rasterizing Computer
Graphics Hardware. Computer Graphics (SIGGRAPH ‘90
Proc.), vol. 24, pgs 327−335, Aug 1990.
[Milen93] V. Milenkovic. Robust Construction of the Voronoi Diagram of
a Polyhedron. In Proc. 5th Canadian. Conference on Comp.
Geom., pgs 473-478, 1993.
[Milen93b]V. Milenkovic. Robust Polygon Modeling. Computer Aided
Design, 25(9), 1993. (special issue on Uncertainties in
Geometric Design).
[Okabe92] A. Okabe, B. Boots, and K. Sugihara. Spatial Tessellations:
Concepts and Applications of Voronoi Diagrams. John Wiley
& Sons, Chichester, UK, 1992.
[Rossi92] J. Rossignac, A. Megahed, and B. Schneider. Interactive
Inspection of Solids: Cross-sections and Interferences.
Computer Graphics (SIGGRAPH ‘92 Proc.), vol. 26, pgs
353−360, July 1992.
[Rossi86] J.R. Rossignac and A.A.G. Requicha. Depth-buffering Display
Techniques for Constructive Solid Geometry. IEEE Computer
Graphics and Applications, 6(9):29−39, 1986.
[Sheeh95] D.J. Sheehy, C.G. Armstrong, and D.J. Robinson. Computing
the Medial Surface of a Solid from a Domain Delaunay
Triangulation. In Proc. ACM/IEEE Symp. on Solid Modeling
and Applications, May 1995.
[Shamo75] M.I. Shamos and D.Hoey. Closest-point Problems. In Proc.
16th Annual IEEE Symposium on Foundations of Comp. Sci.,
pages 151−162, 1975.
[Sugih94] K. Sugihara and M. Iri. A Robust Topology-oriented
Incremental Algorithm for Voronoi Diagrams. International
Journal of Comp. Geom. Appl., 4:179−228, 1994.
[Sherb95] E.C. Sherbrooke, N.M. Patrikalakis, and E. Brisson.
Computation of the Medial Axis Transform of 3D Polyhedra. In
Solid Modeling, pages 187−199. ACM, 1995.
[Teich97] M. Teichmann and S. Teller. Polygonal Approximation of
Voronoi Diagrams of a Set of Triangles in Three Dimensions.
Tech Rep 766, Lab of Comp. Sci., MIT, 1997.