Edge extraction from a voronoi tessellation

Hello everyone,
I'm having a lot of problems about extracting edges from a random Voronoi tessellation.
Would any of you know how? Is there any function that allows you to do this?
Thank you.

Answers (1)

Hi,
can you specify what you mean by "a random voronoi tesselation"?
Are you creating a 3D voronoi tesselation and trying to extract its edges?If so, Using voronoin /VoronoiDiagram functions output arguments,
[v,c]= voronoin(P); % P is matrix with coordinates
returns matrix v which represent Vertices of edges and a cell array c where each element of c containes the row indices of the Voronoi vertices v that make up a Voronoi cell.
v(c{i},:)
would return the vertices corresponding to cell number 'i'
You can refer to this Computing the Voronoi Diagram for more insight
Hope this helps!

6 Comments

Hi, yes I generated a Voronoi tessellation with random seeds. The problem is to try to extract the sides of the polygons generated by the tessellation. Is there a way to reorder the indexes of the vertices so that I can work on every single polygon? The sides, once extracted, I need to assign them a thickness. Thank you.
Can you post the code that you have used to create voronoi diagram.
Vcub=[0 0 0; 1 0 0; 0 1 0; 0 0 1;
1 1 1; 0 1 1; 1 0 1; 1 1 0];
% Vcub(:,2)=2*Vcub(:,2);
N=100;
seeds=1.5*rand(N,3)-0.25;
[Ver,Cel,C_tst]=voronoi3d_cuboid(seeds,Vcub);
figure
hold on
axis('equal')
view([-36 27])
for k = 1:length(Cel)
if ~isempty(Cel{k})
col=rand(1,3);
Vk = Ver(Cel{k},:); Fk = convhull(Vk);
if exist('mergeCoplanarFaces.m','file')==2
[Vk, Fk] = mergeCoplanarFaces(Vk, Fk);
for i=1:length(Fk)
patch('Vertices',Vk,'Faces',Fk{i},'FaceColor',col,'FaceAlpha',0,'EdgeAlpha',1)
end
else
trisurf(Fk,Vk(:,1),Vk(:,2),Vk(:,3),'FaceColor',col, ...
'FaceAlpha', 1,'EdgeAlpha',1,'EdgeColor','k')
end
end
end
For assigning thickness values to edges, There is a property 'LineWidth' for patch and trisurf functions .Refer this.
So the edges are already contained within the patch? Don't need a matrix to extract the sides of the various polygons? And also is it possible to convert this into an STL file? Thank you.

Sign in to comment.

Categories

Asked:

on 19 Oct 2020

Commented:

HG
on 14 Jun 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!