フィルターのクリア

points lying in the intersection of 2 circles

2 ビュー (過去 30 日間)
Ananya Malik
Ananya Malik 2016 年 8 月 26 日
編集済み: KSSV 2016 年 8 月 26 日
Suppose i have 2 points (x1, y1) and (x2,y2). I draw circle with radius 'r'. I want to find "all" the points which lie in the intersection region of the 2 circles.
  2 件のコメント
KSSV
KSSV 2016 年 8 月 26 日
Two circles intersect at two points..you want to get these two points? or the intersection region would be oval in shape, you want to generate points inside this oval?
Ananya Malik
Ananya Malik 2016 年 8 月 26 日
All the points within the oval.

サインインしてコメントする。

採用された回答

KSSV
KSSV 2016 年 8 月 26 日
編集済み: KSSV 2016 年 8 月 26 日
clc; clear all ;
N1 = 100 ; N2 = 50 ;
th = linspace(0,2*pi,N1)' ;
r1 = 1. ; r2 = 1. ; % Radii of circles
c1 = [0 0] ; % Center of first circle
c2 = [1.5 0] ; % Center of second circle
a1 = repmat(c1,[N1 1])+[r1*cos(th) r1*sin(th)] ; % form circle 1
a2 = repmat(c2,[N1 1])+[r2*cos(th) r2*sin(th)] ; % form circle 2
%
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,:) ;
plot(a1(in12,1),a1(in12,2),'.b') ;
%%Get points of second circle lying in first circle
in21 = inpolygon(a2(:,1),a2(:,2),a1(:,1),a1(:,2)) ;
P2 = a2(in21,:) ;
plot(a2(in21,1),a2(in21,2),'.b') ;
%%form the oval / intersection boundary
R = [P1 ;P2] ;
%%Form a suare grid around ovel region
x = linspace(c1(1),c2(1),N2) ;
y = linspace(-r1,r2,N2) ;
[X,Y] = meshgrid(x,y) ;
XX = X(:) ; YY = Y(:) ;
%%Get the points inside the region
in = inpolygon(XX,YY,R(:,1),R(:,2)) ;
plot(XX(in),YY(in),'.k') ;
Can be further refined...

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange3-D Scene Control についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by