hatch the overlap region of 3 circles

조회 수: 1 (최근 30일)
sahar
sahar 2017년 6월 9일
답변: sahar 2017년 6월 10일
I like to know how to hatch the overlap of 3 circles with 3 intersection points?

채택된 답변

sahar
sahar 2017년 6월 10일
the attached code can be used to hatch the overlap of three circles with three intersection points

추가 답변 (1개)

KSSV
KSSV 2017년 6월 9일
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')
  댓글 수: 1
sahar
sahar 2017년 6월 10일
Dear KSSV unfortunately, this code does not work correctly. it hatches more than overlap of three circles. I attached the result

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

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by