hatch the overlap region of 3 circles

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