Merging overlapping circles and remove the union part
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
HAINGKHARRAN GUNASEKARAN
am 12 Jun. 2021
Kommentiert: Star Strider
am 12 Jun. 2021
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.
0 Kommentare
Akzeptierte Antwort
Star Strider
am 12 Jun. 2021
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 Kommentare
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!