How to find distance from point to a grid line?

1 view (last 30 days)
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!

Answers (1)

KSSV
KSSV on 17 May 2017
Edited: KSSV on 17 May 2017
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 Comments
Atiqah Zakirah
Atiqah Zakirah on 18 May 2017
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 on 18 May 2017
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.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!