我寫了一個MATLAB代碼以便能夠看到一些圓圈。請看我的下面的代碼和附件作爲輸出。在MATLAB中刪除重疊的圓圈
clc;
clear;
close all;
% X and Y of each Center
Xloc = [1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5];
Yloc = [1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,4,4,4,4,4,5,5,5,5,5];
% Radius of each circle
radius = unifrnd(0,1,[1 numel(Xloc)]);
% Random colours
allColours = rand(numel(Xloc),3);
% Transform the data into position = [left bottom width height]
pos = [Xloc(:)-radius(:) Yloc(:)-radius(:) 2*radius(:)*[1 1]];
% Create and format the axes
H = axes;
hold on;
axis equal;
box on;
set(H,'XTickLabel',[],'YTickLabel',[]);
% Create the circles
for idx = 1:numel(Xloc);
rectangle(...
'Position',pos(idx,:),...
'Curvature',[1 1],...
'FaceColor',allColours(idx,:),...
'EdgeColor','none');
end
輸出數字是(是隨機產生的圈子半徑,因此,如果執行該代碼,就會用新的輸出面):
正如可以在看到圖中,圓圈之間有重疊。我想知道如何將中心彼此分開以便彼此不重疊,並且同時它們保持原始距離(或相似距離)彼此在[Xloc Yloc]
減小半徑? –
@AnderBiguri,半徑顯示了圓的擴展,這意味着最高半徑代表最重要的圓圈 –
我不知道信息如何幫助。你有圈子。你不想改變他們的立場。你想讓他們不要碰。讓他們變小是唯一的選擇 –