Merging overlapping circles and remove the union part

4 次查看(过去 30 天)
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!
.

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by