필터 지우기
필터 지우기

Determine the condition to find elements inside semi circular region in a rectangular mesh

조회 수: 3 (최근 30일)
I have a rectangular mesh of 500000x500000. I extracted the coordinates of the mesh elements. Now I would like to remove elements in the semicircular form from this rectangular mesh. I have the function to remove elements. But I am struggling to set the condition for the semicircular region to determine all the elements inside the semicircular region. For example if ex and ey are the coordinates of elements in mesh, then I am using
find(ex<=R*cos(theta) & ey <=R*sin(theta)).
How to set this condition according to the grid points in the rectangular mesh. I have also attached the image for more clarity.
Thanks.

채택된 답변

KSSV
KSSV 2018년 11월 6일
편집: KSSV 2018년 11월 6일
Read about inpolygon. This should help you.
M = 100 ;
N = 100 ;
x = linspace(0,1,M) ;
y = linspace(0,1,N) ;
[X,Y] = meshgrid(x,y) ;
% semi circle
O = [0.5 0. ]; % origin of circle
R = 0.3 ; % RAdius of circle
th = linspace(0,2*pi) ;
xc = O(1)+R*cos(th) ;
yc = O(2)+R*sin(th) ;
% Get points lying inside circle
idx = inpolygon(X(:),Y(:),xc,yc) ;
% plot
figure
hold on
plot(X,Y,'.r') ;
plot(xc,yc,'b')
plot(X(idx),Y(idx),'.k')
  댓글 수: 11
Image Analyst
Image Analyst 2018년 12월 4일
You've accepted an answer so we assume the problem has been solved.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by