Intersection of 3 circles with chords present, and arcs removed
2 次查看(过去 30 天)
显示 更早的评论
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/165120/image.gif)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/165121/image.jpeg)
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 中查找有关 Matrices and Arrays 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!