• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 412
  • Last Modified:

How to identify x,y coordinates that lie within a closed polygon whose vertices are defined by x,y coordinates

I have a set of shapes in a field, each with known x,y coordinates, height and width.

I wish to select a subset of these shapes whose centres lie within a closed polygonal line with known coordinates to its vertices.

I program in  VBA and unfortunately am not multi-lingual. However, given the principles, I'd hope to progress to write it in vba.

Can someone please help / point me to accessible resources?

Thanks!
Kelvin4


0
Kelvin4
Asked:
Kelvin4
  • 2
3 Solutions
 
HainKurtSr. System AnalystCommented:
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
You could use GDI objects.  Create a Region from your known vertices then hit-test with PtInRegion():
http://msdn.microsoft.com/en-us/library/dd183511(VS.85).aspx
http://msdn.microsoft.com/en-us/library/dd162883(VS.85).aspx
0
 
HainKurtSr. System AnalystCommented:
from page above:

Ray casting algorithm

The number of intersections for a ray passing from the exterior of the polygon to any point, if odd, shows the point lies inside the polygon. If the even, the point lies outside the polygon; this test also works in three dimensions.
One simple way of finding whether the point is inside or outside a simple polygon is to test how many times a ray starting from the point intersects the edges of the polygon. If the point in question is not on the boundary of the polygon, the number of intersections is an even number if the point is outside, and it is odd if inside.
0
 
Kelvin4Author Commented:
Thanks!
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now