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 Center および File ExchangeAnnotations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by