the attached code can be used to hatch the overlap of three circles with three intersection points
hatch the overlap region of 3 circles
조회 수: 1 (최근 30일)
이전 댓글 표시
채택된 답변
추가 답변 (1개)
KSSV
2017년 6월 9일
You could have applied this logic https://in.mathworks.com/matlabcentral/answers/343595-hatch-overlap-region-of-two-circles to three circles also.
N1 = 100 ; N2 = 50 ;
th = linspace(0,2*pi,N1)' ;
r1 = 1. ; r2 = 1. ; r3 = 1. ;% radii of circles
c1 = [0 0] ; % center of first cirlce
c2 = [1.5 0] ; % center of second circle
c3 = [0.75 0.5] ;
a1 = repmat(c1,[N1 1])+[r1*cos(th) r1*sin(th)] ;
a2 = repmat(c2,[N1 1])+[r2*cos(th) r2*sin(th)] ;
a3 = repmat(c3,[N1 1])+[r3*cos(th) r3*sin(th)] ;
%
plot(a1(:,1),a1(:,2),'r') ;
hold on
plot(a2(:,1),a2(:,2),'r') ;
plot(a3(:,1),a3(:,2),'r') ;
axis equal
%%Get points of 1 circle lying in 2 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')
%%Get points of 1 circle lying in 3 circle
in13 = inpolygon(a1(:,1),a1(:,2),a3(:,1),a3(:,2)) ;
P1 = a1(in13,:) ;
% Get points of 3 circle lying in 1 circle
in31 = inpolygon(a3(:,1),a3(:,2),a1(:,1),a1(:,2)) ;
P2 = a3(in31,:) ;
% form the oval / intersection boundary
R = [P1 ;P2] ;
idx = convhull(R(:,1),R(:,2)) ;
patch(R(idx,1),R(idx,2),'r')
%%Get points of 2 circle lying in 3 circle
in23 = inpolygon(a2(:,1),a2(:,2),a3(:,1),a3(:,2)) ;
P1 = a2(in23,:) ;
% Get points of 3 circle lying in 2 circle
in32 = inpolygon(a3(:,1),a3(:,2),a2(:,1),a2(:,2)) ;
P2 = a3(in32,:) ;
% form the oval / intersection boundary
R = [P1 ;P2] ;
idx = convhull(R(:,1),R(:,2)) ;
patch(R(idx,1),R(idx,2),'r')
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!