Determine the condition to find elements inside semi circular region in a rectangular mesh
You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Show older comments
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.
Accepted Answer
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 Comments
Is it possible to do same for 3D meshgrid or cuboid? For example in a slice of 3D volume?
KSSV
on 7 Nov 2018
Yes very much...but not with inpolygon.
Could you please suggest for 3D also?
KSSV
on 7 Nov 2018
For cuboid you want to get points which are inside sphere?
No, It is like the flat semi-circular notch. I have attached the picture for the reference. Thanks!
KSSV
on 8 Nov 2018
Do you have points for the above? I have to create and check..so asking..
Abhishek Saini
on 8 Nov 2018
Edited: Abhishek Saini
on 8 Nov 2018
Yes, I have but that is quite a huge file. Maybe we could check by creating 3D meshgrid. I could create a smaller one.
KSSV
on 8 Nov 2018
Yes..do it..and attach the data..3d points and semi circle. Actually, you can use the same inpolygon for this. YOu see the semi circle and the points lie on some plane..where you can discard one dimension which is common....and input the other 2d points.
Abhishek Saini
on 4 Dec 2018
Edited: Abhishek Saini
on 4 Dec 2018
Hi,
Sorry for the dealy.
I have attached the data. I ahve generated the small data for the testing.
px, py and pz are the coordinate points in x, y and z direction.
I want to select points in semi circular pattern. Attacehd is the picture.
Cordinate system
x = horizontal
z = vertical
y = 3rd dimention i.e. width
You've accepted an answer so we assume the problem has been solved.
Whether this question will be considered or not?
More Answers (0)
Categories
Find more on Get Started with Computer Vision Toolbox in Help Center and File Exchange
Tags
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)