To find common area between two plots.

조회 수: 4 (최근 30일)
Sanjana Dhiran
Sanjana Dhiran 2018년 7월 19일
답변: Caleb Williams 2018년 7월 19일
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??

답변 (1개)

Caleb Williams
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.

카테고리

Help CenterFile Exchange에서 Computational Geometry에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by