필터 지우기
필터 지우기

Intersection of 3 circles with chords present, and arcs removed

조회 수: 2 (최근 30일)
Sean
Sean 2014년 7월 1일
답변: Jian Wei 2014년 7월 23일
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?

답변 (1개)

Jian Wei
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.

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by