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
399 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Scott A. Helmers Partner, Harvard Computing Group Microsoft Visio MVP Background Microsoft has added more enhancements and new features to Visio 2010 than to any release since they purchased the Visio product line in 2000. In addition, the com…
Article by: Nadia
Suppose you use Uber application as a rider and you request a ride to go from one place to another. Your driver just arrived at the parking lot of your place. The only thing you know about the ride is the license plate number. How do you find your U…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

759 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now