I have written a MATLAB code to create the figure attached using the voronoi. My region of interest is the red circle. Hence the seeds for voronoi were kept within the region.
-
1It's computationally a bit involved, but if you know each vertex of each cell, then you could loop over every pair of cells, check their common vertices, then draw a thick line along that vertex. Come to think of it, it's probably much quicker and simpler to loop along every cell, then manually draw the cell boundary with a thick line. You will have each border twice, but that shouldn't be much of a problem. – Andras Deak -- Слава Україні Oct 12 '15 at 14:32
-
@AndrasDeak Thank you for your comment. My intention is not to increase the width of the cells. But to reduce the area. So that when I import the part in abaqus software, the boundary can be considered as a separate region, and can be allotted different material properties. I am not sure if I am sounding clear enough. – rcty Oct 12 '15 at 14:38
-
1If you clarify on what you want to do in Abaqus, then it would be easier to suggest a solution. Do you want an assembly of parts, or one part with different properties for each Voronoi cell? – will Oct 12 '15 at 16:39
-
@will I want to create a partition of the voronoi cells on a circle of radius (r). The 'blank' regions will be similar to grain boundaries and the voronoi cells will be the grains. That is, the grains are separated from each other by a grain boundary. – rcty Oct 12 '15 at 16:58
-
@will it won't be an assembly of parts, but a partition on a part. The region between can be allotted a different material property than the grains. Something similar to this, but much more refined and within a circle http://s24.postimg.org/j3624pr1x/Original.jpg – rcty Oct 12 '15 at 17:47
-
1Thanks for adding the second picture, this is much clearer. if cst's answer is not good enough, add to your question. if you only need to do this once, and are not going to script it in python, then you might be able to use the offset tool in the sketcher. this is a bit laborious, but might suffice if its a one off problem. – will Oct 12 '15 at 18:28
-
@will I am using Matlab to generate the python script to be used in abaqus. I have tried using cst's answer, but it doesn't seem to work, or probably I am getting something wrong. I have added that part of the code to the question. – rcty Oct 12 '15 at 18:32
2 Answers
Idea: One approach would be to use a homothetic transformation of the Voronoi cell C{k}
about the corresponding point X(k,:)
, with a ratio R such as 0 < R < 1. The shape of the cells—the number of corners and their associated angles—will be preserved, and the areas will be reduced proportionally (i.e. by a factor R2, and not by a constant value).
Please note that this will "destroy" your cells, because the reduced Voronoi cells will not share anymore vertices/edges, thus the [V,C]
representation doesn't work anymore as it is. Also, the distances between what were once common edges will depend on the areas of the original cells (bigger cells, bigger distances between adjacent edges).
Transformation example for 2 2D points:
A = [1,2]; %'Center'
B = [10,1]; %'To be transformed'
R = 0.8; %'Transformation ratio'
trB = A + R*(B-A); %'Transformed'
-
thank you for your reply. That sounds very appropriate. I can use the centroid of the polygons as the center and the transform each vertices by the ratio. Let me try that out. Thanks! – rcty Oct 12 '15 at 14:59
-
1I also thought about this, but this will shrink each cell about the point. @rcy's version using the polygon centroids fixes this issue and makes it more appealing visually. – Andras Deak -- Слава Україні Oct 12 '15 at 15:52
-
1@AndrasDeak Didn't try to represent graphically, so I'd rather take your word on it. :-) My thought was to preserve at least one of the properties of the Voronoi cells, i.e. equal distances from points to the (transformed) common edge. – Oct 12 '15 at 15:59
couldn't follow your implementation of CST-link's idea, but here is one that works (i tested it in matlab, but not yet in abaqus, the code it spits out looks like abaqus should be happy with it)
rng(0);
x=rand(40,2);
plot(x(:,1),x(:,2),'x')
[v,c]=voronoin(x);
fact=0.9;
for i=1:length(c)
cur_cell=c{i};
coords=v(cur_cell,:);
if isfinite(coords)
%fact=somefunctionofarea?;
centre=x(i,:); % i used the voronoi seeds as my centres
coords=bsxfun(@minus,coords,centre); %move everything to a local coord sys centred on the seed point
[theta,rho] = cart2pol(coords(:,1),coords(:,2));
[xnew, ynew]= pol2cart(theta,rho*fact);
xnew=xnew+centre(1); % put back in real coords.
ynew=ynew+centre(2);
xnew2=circshift(xnew,1);
ynew2=circshift(ynew,1);
fprintf('s1.Line(point1=(%f,%f),point2=(%f,%f))\n',...
[xnew, ynew, xnew2,ynew2]');
line(xnew,ynew); %testing purposes - doesn't plot last side in matlab
end
end
Having seen the results of this one, i think you will need a different way factor to shrink your sides. either to subtract a fixed area or some other formula.

- 377
- 1
- 10
-
thanks a lot for your code, yes it very close to what I wanted. Since the last side is not plotted, abaqus is not able to sketch the part out. I think I will try to work on that. Atleast now I am close to my goal. Thanks again! – rcty Oct 12 '15 at 19:45
-
1@rcy It's not plotted in Matlab, but it is drawn in abaqus. The abaqus line Matlab line commands are different, so the new and new2 points are made for abaqus, not Matlab. – will Oct 12 '15 at 19:48
-
it works now! My bad! I was making a typo error. Thanks a lot for your help! – rcty Oct 12 '15 at 20:04