To find common area between two plots.
3 ビュー (過去 30 日間)
古いコメントを表示
Hello everyone, I want to find the common area between a circle whose diameter endpoints' coordinates are known and a curve formed by a set of 175 points. How to do that??
0 件のコメント
回答 (1 件)
Caleb Williams
2018 年 7 月 19 日
The first step is to turn your circle into an array of points.
theta=0:0.001*pi:2*pi;
x=cos(theta');
y=sin(theta');
The plot both the circle points and the curve's points (175x2 array named "curve") on the same figure (for visuals).
plot(x,y,'b*',curve(:,1),curve(:,2),'r*');
Now from here, you'll have two regions of the circle/curve - you've got to pick which one you want to find the area of. But once you figure that portion out, you could use a nearest neighbor search (see "knnsearch") to find the nearest neighbor in the circle to the curve. Find the elements of the curve where that distance is a minimum and then eliminate all elements outside of those.
[element,distance]=knnsearch([x y],curve);
% Find two elements in curve that have the minimum distance to [x y].
% Call them element 'a' and element 'b' (in ascending order).
curve=curve(a:b,:); % eliminates portion of curve outside of circle
Then you're going to find the area inside of the polygonal region formed by the circle and this portion of the curve. You can use MATLAB's built in "polyarea" function.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Computational Geometry についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!