Reducing the area of ​​voronoi cells and determining the coordinates of new vertices

I wrote MATLAB code to create a shape attached using voronoi. My area of ​​interest is the red circle. Consequently, the seeds for crow were stored within the area.

+4
source share
2 answers

couldn't follow your implementation of the CST-link idea, but the one that works (I tested it in Matlab, but not yet in abaqus, the code that 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 

Seeing the results of this, I think you will need another way to reduce your sides. either to subtract a fixed area, or some other formula.

+1

:. C{k} X(k,:) R, 0 < R < 1. , , (.. R 2 ).

, "" , Voronoi /, [V,C] , . , , - , ( , ).

2D-:

A   = [1,2];        %'Center'
B   = [10,1];       %'To be transformed'
R   = 0.8;          %'Transformation ratio'
trB = A + R*(B-A);  %'Transformed'
+2

Source: https://habr.com/ru/post/1611290/


All Articles