Filter löschen
Filter löschen

points lying inside a polygon and a circle

10 Ansichten (letzte 30 Tage)
KalMandy
KalMandy am 30 Jan. 2017
Bearbeitet: Matt J am 25 Apr. 2019
How can I find the number of point lies inside both a circle and a polygon (the point should lie in the mutual/overlapping area in between the circle and the polygon) ?

Akzeptierte Antwort

Matt J
Matt J am 30 Jan. 2017
Bearbeitet: Matt J am 25 Apr. 2019
If the circle is centered at (x0,y0), with radius R and the polygon has vertices xv,yv, you could do,
count = sum( inpolygon(x,y,xv,yv) & ((x-x0).^2+(y-y0).^2<=R^2) )
  3 Kommentare
Matt J
Matt J am 30 Jan. 2017
Yes.
KalMandy
KalMandy am 30 Jan. 2017
Thanks a lot!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Image Analyst
Image Analyst am 30 Jan. 2017
Did you try
count = 0;
if inpolygon(x,y,xCircle,yCircle) && inpolygon(x,y,xPoly,yPoly)
count = count + 1
end
where you call inpolygon twice, once passing in the circle coordinates and once passing in the polygon coordinates and then ANDing the two results together?
  6 Kommentare
KalMandy
KalMandy am 30 Jan. 2017
I have the radius and the coordinates of the center of the circle. what is given by xCircle,yCircle? Thanks for your response.
hanif hamden
hanif hamden am 25 Apr. 2019
If i put (x,y) in geographical coordinate and I want my radius is 10km. How should I do that?

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Computational Geometry finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by