MATLAB Function Reference |
Syntax
Description
[V,C] = voronoin(X)
returns Voronoi vertices V
and the Voronoi cells C
of the Voronoi diagram of X
. V
is a numv
-by-n
array of the numv
Voronoi vertices in n-dimensional space, each row corresponds to a Voronoi vertex. C
is a vector cell array where each element contains the indices into V
of the vertices of the corresponding Voronoi cell. X
is an m
-by-n
array, representing m
n-dimensional points, where n > 1
and m >= n+1
.
The first row of V
is a point at infinity. If any index in a cell of the cell array is 1
, then the corresponding Voronoi cell contains the first point in V
, a point at infinity. This means the Voronoi cell is unbounded.
[V,C] = voronoin(X,options)
specifies a cell array of strings options
to be used in Qhull. The default options are
If options
is []
, the default options are used. If code
is {''}
, no options are used, not even the default. For more information on Qhull and its options, see http://www.qhull.org.
Visualization
You can plot individual bounded cells of an n-dimensional Voronoi diagram. To do this, use convhulln
to compute the vertices of the facets that make up the Voronoi cell. Then use patch
and other plot functions to generate the figure. For an example, see Tessellation and Interpolation of Scattered Data in Higher Dimensions in the MATLAB documentation.
Examples
[V,C] = voronoin(x) V = Inf Inf 0.3833 0.3833 0.7000 -1.6500 0.2875 0.0000 -0.0000 0.2875 -0.0000 -0.0000 -0.0500 -0.5250 -0.0500 -0.0500 -1.7500 0.7500 -1.4500 0.6500 C = [1x4 double] [1x5 double] [1x4 double] [1x4 double] [1x4 double] [1x5 double] [1x4 double]
Use a for
loop to see the contents of the cell array C
.
In particular, the fifth Voronoi cell consists of 4 points: V(10,:)
, V(5,:)
, V(6,:)
, V(8,:)
.
Example 2. The following example illustrates the options
input to voronoin
. The commands
? qhull input error: can not scale last coordinate. Input is cocircular or cospherical. Use option 'Qz' to add a point at infinity.
The error message indicates that you should add the option 'Qz'
. The following command passes the option 'Qz'
, along with the default 'Qbb'
, to voronoin
.
[V,C] = voronoin(X,{'Qbb','Qz'}) V = Inf Inf 0 0 C = [1x2 double] [1x2 double] [1x2 double] [1x2 double]
Algorithm
voronoin
is based on Qhull [2]. For information about qhull
, see http://www.qhull.org. For copyright information, see http://www.qhull.org/COPYING.txt.
See Also
convhull
, convhulln
, delaunay
, delaunayn
, voronoi
Reference
[1] Barber, C. B., D.P. Dobkin, and H.T. Huhdanpaa, "The Quickhull Algorithm for Convex Hulls," ACM Transactions on Mathematical Software, Vol. 22, No. 4, Dec. 1996, p. 469-483. Available in PDF format at http://www.acm.org/pubs/ citations/journals/toms/1996-22-4/p469-barber/.
[2] National Science and Technology Research Center for Computation and Visualization of Geometric Structures (The Geometry Center), University of Minnesota. 1993.
voronoi | wait |
© 1994-2005 The MathWorks, Inc.