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
404 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 55

Assisted Solution

by:Huseyin KAHRAMAN
Huseyin KAHRAMAN earned 334 total points
ID: 36537722
0
 
LVL 86

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 55

Accepted Solution

by:
Huseyin KAHRAMAN 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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…
One of Google's most recent algorithm changes affecting local searches is entitled "The Pigeon Update." This update has dramatically enhanced search inquires for the keyword "Yelp." Google searches with the word "Yelp" included will now yield Yelp a…
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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

691 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