Skip to main content
12-Amethyst
June 10, 2014
Solved

Finding if a point is inside of an drawn area or not

  • June 10, 2014
  • 23 replies
  • 8923 views

Hi

I try to make a relatively simple program how to find if a point is inside an drawn area or not.

The problem is illustrated in the attached calculation sheet.

Thank you for your advices in advance.

Best answer by RichardJ

Here's one that works for both points. This was written by Stuart, not by me. I just pulled it from my collection.

23 replies

19-Tanzanite
June 10, 2014

The attached has a simple routine to do what you want (I hope!).

It needs to be tested more extensively and should probably be vectorised, but I'll leave that to you.

Alan

1-Visitor
June 10, 2014

Nice work Alan. I started to write a routine going down a similar route to what you have and then realised I have actual work to do

12-Amethyst
June 10, 2014

Hi Alan

Thanks for your programmin work.

I tested your code a bit, but unfortunately at least one point resulted into incorrect answer,

see attached.

Werner_E
25-Diamond I
June 10, 2014

Here is a testsheet to compare different algorithms with different data sets. I included Alan's second approach and Stuart's algorithm and hope I moved them over correctly. I also added one where I count how often a point is orbited by the polygon. This number should be zero for points outside the polygon. The algorithm seems to work pretty well also with non well behaved polygons, but still would need some work as some vertices are counted as in and some as out. The same goes for points lying on a polygon side. This is sure not an issue for the problem under discussion here, though.

Werner_E
25-Diamond I
June 11, 2014

Here is my second try. It seems that omitting the polygon sides which contain the point to be checked from building the angle sum and adding a tolerance to copy with roundoff error does the job. Now all points of the polygon (vertices and sides) are considered being inside.

EDIT: Only exception seems to be the point of intersection of the self crossing "infinity" (dataset 4).

12-Amethyst
June 11, 2014

Hi all,

It is nice to see that this problem has generated discussion.

The situation for which I need this inside/outside -test, was illustrated in the last section of the attachment in my original question (, but not very clearly, my apologizes for that...)

In principle, from a CPT (Cone penetration test) which is used for soil investigations, we get a large number of

sleeve resistance values fs and tip resistance values qt. Typical CPT test result is shown in attachment.

With these two values, the soil type can be defined using the charts presented in the second attached picture.

The main issue is to find, that in which area each fs/qt - qt -point hit.

My intention was that after this issue with one polygon is solved, I'll make a program that checks all the areas and defines in which area each point has hit. From those evaluations soil layers could be defined for all depths.