Solved

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

Posted on 2011-09-14
4
402 Views
Last Modified: 2012-05-12
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
Comment
Question by:Kelvin4
  • 2
4 Comments
 
LVL 51

Assisted Solution

by:HainKurt
HainKurt earned 334 total points
ID: 36537722
0
 
LVL 85

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 166 total points
ID: 36537736
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
 
LVL 51

Accepted Solution

by:
HainKurt earned 334 total points
ID: 36537745
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
 

Author Closing Comment

by:Kelvin4
ID: 36548355
Thanks!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This algorithm (in C#) will resize any image down to a given size while maintaining the original aspect ratio. The maximum width and max height are both optional but if neither are given, the original image is returned. This example is designed t…
Meetings to discuss business process can waste time, and often do .  The meeting's dialog can get confusing when participants have different professional perspectives and backgrounds.  A jointly-developed process picture helps wade through the confu…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

838 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question