-
Notifications
You must be signed in to change notification settings - Fork 42
/
getVoronoiWeights.m
27 lines (25 loc) · 967 Bytes
/
getVoronoiWeights.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function voronoi_weights = getVoronoiWeights(dirs)
%GETVORONOIWEIGHTS Compute voronoi diagram spherical areas for set of points
%
% dirs: directions of the K points on the sphere in the
% [azi1 elev1;... aziK elevK] convention
%
% voronoi_weights: Kx1 vector of the areas of the voronoi cells around
% each point. The areas sum to 4*pi.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Archontis Politis, 20/02/2015
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[dirs_x, dirs_y, dirs_z] = sph2cart(dirs(:,1), dirs(:,2), 1);
% perform delaunay triangulation
delaunay.vert = [dirs_x, dirs_y, dirs_z];
delaunay.face = sphDelaunay(dirs);
% get voronoi cells from delaunay
voronoi = sphVoronoi(dirs, delaunay.face);
% get areas of spherical voronoi polygons
voronoi = sphVoronoiAreas(voronoi);
voronoi_weights = voronoi.area;
end