For Intersecting Circles, how to remove overlapping arcs for 3 or more circles?
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
In the attached image if you project the red lined plane to z=0 (2D) is there a way to plot the circles with chords shown, and arcs removed in MATLAB (as well as an extension to N circles)?

I have a solution posted from a previous question (2 circles) which will be shown here (with some minor changes):
clear all
clc
m = 100; % Number of points on circle
x_max = 50; % Uppermost x location of circle center
y_max = 50; % Uppermost y location of circle center
theta = 0:2*pi/m:2*pi; % Evaluated angles for circle
i = 1;
k = 2; %%%%%%%%%%%
rad(i) = 15*rand; % Save circle radii to array
x_pos(i) = x_max*rand; % Save circle xi-positions to array
y_pos(i) = y_max*rand; % Save circle yi-positions to array
rad(k) = 15*rand; % Save circle radii to array
x_pos(k) = x_max*rand; % Save circle xk-positions to array
y_pos(k) = y_max*rand; % Save circle yk-positions to array
Xk=x_pos(k)+rad(k)*cos(theta);
Yk=y_pos(k)+rad(k)*sin(theta);
Xi=x_pos(i)+rad(i)*cos(theta);
Yi=y_pos(i)+rad(i)*sin(theta);
dC1 = sqrt((Xi-x_pos(k)).^2+(Yi-y_pos(k)).^2)>=rad(k);
dC2 = sqrt((Xk-x_pos(i)).^2+(Yk-y_pos(i)).^2)>=rad(i);
plot(Xk(dC2.'),Yk(dC2.'),'m',Xi(dC1.'),Yi(dC1.'),'c');
axis([0 100 0 100]);
hold on
axis equal
Or maybe there is a way to have N circles fit the requirements above with a carefully restricted Voronoi/Delaunay plot?
0 Kommentare
Akzeptierte Antwort
Joseph Cheng
am 18 Jun. 2014
Bearbeitet: Joseph Cheng
am 18 Jun. 2014
Well... feels like i'm answering this again but what you can do is a for loop
clear all
clc
m = 1000; % Number of points on circle
x_max = 50; % Uppermost x location of circle center
y_max = 50; % Uppermost y location of circle center
theta = 0:2*pi/m:2*pi; % Evaluated angles for circle
k=3
%generate circles and store their points.
for i =1:k
rad(i) = 15*rand; % Save circle radii to array
x_pos(i) = x_max*rand; % Save circle xi-positions to array
y_pos(i) = y_max*rand; % Save circle yi-positions to array
X{i}=x_pos(i)+rad(i)*cos(theta);
Y{i}=y_pos(i)+rad(i)*sin(theta);
end
figure,
hold on
for j=1:3
plot(X{j},Y{j})
end
%perform loops for comparison.
for i=1:k-1
for j=i+1:k
dC1 = sqrt((X{i}-x_pos(j)).^2+(Y{i}-y_pos(j)).^2)>=rad(j);
X{i}(~dC1)=NaN;
Y{i}(~dC1)=NaN;
dC2 = sqrt((X{j}-x_pos(i)).^2+(Y{j}-y_pos(i)).^2)>=rad(i);
X{j}(~dC2)=NaN;
Y{j}(~dC2)=NaN;
end
end
figure,
hold on
for j=1:3
X{j}(isnan(X{j})) = [];
Y{j}(isnan(Y{j})) = [];
plot(X{j},Y{j})
end
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!