Merging overlapping circles and remove the union part

조회 수: 5 (최근 30일)
HAINGKHARRAN GUNASEKARAN
HAINGKHARRAN GUNASEKARAN 2021년 6월 12일
댓글: Star Strider 2021년 6월 12일
Hello, I've plot 2 circles on different positions (different centres) on a picture. The 2 circles overlap with one another and I wish to merge the overlapping part as shown in the attachment (the union part is removed). Is it possible to do this on MATLAB? Is there any specific coding for this? Thank you.

채택된 답변

Star Strider
Star Strider 2021년 6월 12일
One approach —
t = linspace(0,2*pi,500); % Allow Adequate Resolution For Best Results
r = 1;
x = @(t) r*cos(t);
y = @(t) r*sin(t);
xc1 = -0.7;
xc2 = +0.7;
circ1 = [x(t)+xc1; y(t)]; % First Circle
circ2 = [x(pi-t)+xc2; y(pi-t)]; % 'Phase' Second Circle So 'inpolygon' Works Correctly
incirc1 = inpolygon(circ1(1,:),circ1(2,:), circ2(1,:),circ2(2,:)); % Detect Intersections
incirc2 = inpolygon(circ2(1,:),circ2(2,:), circ1(1,:),circ1(2,:)); % Detect Intersections
figure
plot(circ1(1,~incirc1),circ1(2,~incirc1),'-k', circ2(1,~incirc2),circ2(2,~incirc2),'-k')
axis('equal')
axis([-2 2 -1.5 1.5])
Interesting problem!
.
  댓글 수: 2
HAINGKHARRAN GUNASEKARAN
HAINGKHARRAN GUNASEKARAN 2021년 6월 12일
Thank you so much,I'll go through it.
Star Strider
Star Strider 2021년 6월 12일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by