File Exchange

image thumbnail

Voronoi Sphere

version (34 KB) by Bruno Luong
Compute voronoi's diagram of points on the 2-sphere


Updated 19 Jul 2018

View License

Return diagram as list of vertices, index of spherical polygons, and discretized polygons

Cite As

Bruno Luong (2020). Voronoi Sphere (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (16)

Bruno Luong

Wenhui, can you send me your input data that trigger this error?

Wenhui Tang

Hi, sometimes I get the error like this but sometimes not. My input is a series of carries with the unit length.

Brace indexing is not supported for variables of this type.

Error in voronoisphere>cycling_edge (line 164)
K = [K{:}];

Error in voronoisphere (line 102)
v = cycling_edge(edgeofcell{j}, vid);

jiajia li

jiajia li


I would like a better understanding of how the Center function works. Is there any documentation of how A, B and C are defined, and perhaps a sketch of the trigonometry used to calculate the centers.

Working great on 2017b, thanks!

One small issue: when three or more points happen to fall on the same great-arc (e.g. I am using the function on a hemispherical dome with several points around the base), the center of those Delaunay-triangles is actually the center of the sphere, and should be 'pushed' to the surface. To fix it, at the end of the 'Center' function I added:

P(:,s==0) = AxB(:,s==0)./rssq(AxB(:,s==0));

This includes also the possibility that several triangles can share the same center, so I had to filter the calculated set of centers, and eliminate the degenerate edges:
k = [k{:}];
vid = allids(k.');

% Center of the circumscribed Delaunay triangles
V = Center(xyz, T);

% Check that triangle centers do not match (e.g. two triangles on same great-arc)
[~,ia,ic] = unique(V','rows');
if numel(ia) ~= numel(ic)
V = V(:,ia);
vid = ic(vid);
degenerate = vid(:,1) == vid(:,2);
vid = vid(~degenerate,:);
k = k(:,~degenerate);

% each row is 2 cell ids of the edge
cellofedge = E(k(1,:),:); % ne x 2

With these changes I get beautiful beach-ball-like divisions on the half of the dome with no points.

Bruno Luong

Make quick test, still working on R2017a contrary to Garrett's claim

No longer works:

Cell contents reference from a non-cell array object.

Error in voronoisphere>cycling_edge (line 164)
K = [K{:}];

Error in voronoisphere (line 102)
v = cycling_edge(edgeofcell{k}, vid);

I would like to get figure 10.gif from

but I'm getting two square faces and not one as on the site. I use for xyz data.


This is great! Thank you

Bruno Luong

To Eric: the output (K) _is_ sorted as the input seeds.


This is great. Is it possible to re-sort the output so that it preserves the order of the input? I am trying to apply specific individual patch colors.



France 2018

"cAllez les bleus " screenshot

Upload right files

Upload right source files

Can now deal with small (<=3) number of nodes
Robust the solid_angle calculation by making sure the right topology patch

Add function to compute solid angles of the voronoi cells

New simplified code

Change typo in the title

Add test file and optimize the code

MATLAB Release Compatibility
Created with R2013a
Compatible with any release
Platform Compatibility
Windows macOS Linux