3
$\begingroup$

The problem I want to solve, is to quickly decide, whether a point $p=(x^*,y^*)$ is inside or outside of a polygon $P := (p_1, p_2,..., p_n=p_1), p_i := (x_i,y_i)$, with $n$ potentially very large.

Edit:
In view of Joseph's answer, I see the need to give some additional information about what the actual situation is.

  • The polygons I encounter, have an approximately fractal boundary and an otherwise fairly well behaved shape, i.e. the difference between the area of the largest enclosed and the smallest enclosing convex polygon is 'small'. This well behavedness of shape is the reason for looking at implicit functions e.g. largest enclosed and smallest enclosing ellipse.
  • The number of point in polygon queries is extremely high, so that any kind of preprocessing pays off for a sufficiently large number of queries
  • the probability of a point to be in polygon $P$ is not known, but suggestions for inclusion tests, that are optimal on average, may assume a known probability.

(end of edit)

My idea was to try to find the series-expansion of a bivariate function $f(x,y)$ with the following properties:

  • $f(x,y) := \sum_{i=0}^{\infty}\sum_{j=0}^{\infty}a_{ij}x^iy^j$
  • $\sum_{i=0}^{n}\sum_{j=0}^{n}a_{ij}x^iy^j=0$ resembles a jordan curve, that does not intersect the polygon $P$
  • if the jordan curve encloses the polygon, then the enclosed area should be minimal and maximal if the jordan curve is inside the polygon.
  • the jordan curves related to different partial sums should be nested

Questions:

Note: I formulated the series expansion as a Taylor series but other expansions would also be appreciated.

Computational Geometry solutions that aim at minimizing the average time that is needed for a point-in-polygon query in the above setting are also welcome.

$\endgroup$
0

2 Answers 2

4
$\begingroup$

This problem is called the point-in-polygon problem in the graphics and computational geometry literature, and searching that phrase will bring you to much discussion and working code. It is rather firmly established that the best method is the ray-shooting algorithm, described, e.g., in Wikipedia here.
      Wikipedia image
Straightforward implementation runs in $O(n)$ time, and you can find this all over the web, including my own implementation here. If you are going to repeatedly query, sophisticated data structures will allow $O(\log n)$ per query.

$\endgroup$
2
  • $\begingroup$ thanks for your reply; I have some CG background and know the standard algorithms for point in polygon tests. What I really want, but did not state explicitly, is an algorithm that yields 'fastest' execution on the average given the probability that a point is inside the polygon vs outside of it - hence the inner/outer approximation. The implicit functions (e.g. ellipse) would promise quick decisions if the polygons enclose large empty areas despite having a very rugged boundary like e.g. borders of countries. I will edit problem description accordingly. $\endgroup$ Commented Jan 31, 2014 at 5:24
  • $\begingroup$ @ManfredWeis: Now that you've explained the problem more fully, I wonder if it might not be best to find inscribing and circumscribing polygons of fewer edges (for which there are algorithms), and use ray-shooting on those as a filter. $\endgroup$ Commented Jan 31, 2014 at 12:26
3
$\begingroup$

From a computational geometry point of view, this article http://compgeom.com/~piyush/papers/occluder.pdf that I just found, comes closest to what I need.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .