% Plot commands for the 3D voronoi polyhedra. M = [0 0 0]; BOUND = [148.3282 -388.3282 0;... -148.3282 -388.3282 0;... -240.0000 -240.0000 240.0000;... 0 -148.3282 388.3282;... 240.0000 -240.0000 240.0000;... 0 148.3282 -388.3282;... -240.0000 240.0000 -240.0000;... -148.3282 388.3282 0;... 148.3282 388.3282 0;... 240.0000 240.0000 -240.0000;... 0 -148.3282 -388.3282;... -240.0000 -240.0000 -240.0000;... -388.3282 0 -148.3282;... -388.3282 0 148.3282;... -240.0000 240.0000 240.0000;... 0 148.3282 388.3282;... 240.0000 240.0000 240.0000;... 388.3282 0 148.3282;... 388.3282 0 -148.3282;... 240.0000 -240.0000 -240.0000]; F = [M; BOUND]; [V,C] = voronoin(F); hold on; for hull = 1:size(M,1); % For each volume 'hull' X = V(C{hull},:) % View hull Voronoi cell. K = convhulln(X); figure(hull) d = [1:size(K,2), 1]; % d = [1 2 3 1]; % Index into K % For each face i; for i = 1:size(K,1) j = K(i,d); % Plot a polygon that is white with black lines, on each face i h(i)=patch(X(j,1),X(j,2),X(j,3),'w'); % Uncomment this for transparent polyhedra. % set(h(i),'facecolor', 'none'); end end hold off view(3) axis equal title('One cell of a Voronoi diagram') rotate3d;