How to find distance from point to a grid line?

조회 수: 1 (최근 30일)
Atiqah Zakirah
Atiqah Zakirah 2017년 5월 17일
댓글: KSSV 2017년 5월 18일
I need to calculate the percentage of the circle in each rectangular region. The rectangular regions are meant to be a grid lines. To do so, I need to find the distance from a data point within the circle to each grid line (the three lines from the point in the green region). Is there any way to solve this? I have no idea how to approach this so any help would be great. Thanks!

답변 (1개)

KSSV
KSSV 2017년 5월 17일
편집: KSSV 2017년 5월 17일
Two options:
1. If you have image as the input:
I = imread('mathworksqn.jpg') ;
imshow(I);
axis on
h = imdistline ;
Move the line to the points where you want the distance. This will give you distance.
2. If you have data in hand:
You can calculate the distance using the distance formula on knowing the data points.
If you have data in your hand...then you must be having coordinates of the grid and circle..then you can get the area of the part you want using polyarea, trapz. Read about them.
  댓글 수: 2
Atiqah Zakirah
Atiqah Zakirah 2017년 5월 18일
Thanks for the answer! So far, I've found the intersection points of the grid lines and circles. The data is stored in a 2x8 matrix "P". From there, how do I use the polyarea function to calculate the area of each shaded region?
KSSV
KSSV 2017년 5월 18일
Okay..you got the intersections from this link. First it would be nice to accept the answer as it helped you.
Yes, if you have points in hand which form the polygon..._polyarea_ will give your area.

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

Community Treasure Hunt

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

Start Hunting!

Translated by