Intersection of 3 circles with chords present, and arcs removed
1 回表示 (過去 30 日間)
古いコメントを表示
Something like this, but with the arcs within another circle removed, as well as the remaining chord length after the chords intersect (similarly to the second image).
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
This code (posted by Joseph Cheng) does well for circle interactions until 3 overlap. Is there a way to allow this?
0 件のコメント
回答 (1 件)
Jian Wei
2014 年 7 月 23 日
Please try executing the attached code to see if it generates the result you need.
Generally, you first need to compute the chords and check if they intersect with each other. If they do, you need to compute the intersection point of these chords. Finally, remove the overlapped part of the arcs and chords, and add the intersection point to the proper locations in the arrays which store the coordinates of the arc points.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Lighting, Transparency, and Shading についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!