hatch overlap region of two circles

1 Ansicht (letzte 30 Tage)
sahar
sahar am 6 Jun. 2017
Kommentiert: sahar am 7 Jun. 2017
I would like to know how can I hatch overlap region of two circles?

Akzeptierte Antwort

KSSV
KSSV am 7 Jun. 2017
N1 = 100 ; N2 = 50 ;
th = linspace(0,2*pi,N1)' ;
r1 = 1. ; r2 = 1. ; % radii of circles
c1 = [0 0] ; % center of first cirlce
c2 = [1.5 0] ; % center of second circle
a1 = repmat(c1,[N1 1])+[r1*cos(th) r1*sin(th)] ;
a2 = repmat(c2,[N1 1])+[r2*cos(th) r2*sin(th)] ;
%
plot(a1(:,1),a1(:,2),'r') ;
hold on
plot(a2(:,1),a2(:,2),'r') ;
axis equal
%%Get points of first circle lying in second circle
in12 = inpolygon(a1(:,1),a1(:,2),a2(:,1),a2(:,2)) ;
P1 = a1(in12,:) ;
%%Get points of second circle lying in first circle
in21 = inpolygon(a2(:,1),a2(:,2),a1(:,1),a1(:,2)) ;
P2 = a2(in21,:) ;
%%form the oval / intersection boundary
R = [P1 ;P2] ;
idx = convhull(R(:,1),R(:,2)) ;
patch(R(idx,1),R(idx,2),'r')
  1 Kommentar
sahar
sahar am 7 Jun. 2017
thank for the useful answer.BTW, can you describe the approach to hatch the overlap of 3 circles with 3 intersection points?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by