0

We all know how to check if a 2D point is inside a 2D polygon but what about checking precisely if a point is inside a complex contour made by lines, arcs, elliptical arcs and splines? I mean without converting it to a 2D polygon using a deviation tolerance.

Do you know any robust approach to the problem?

Thanks.

abenci
  • 8,422
  • 19
  • 69
  • 134
  • I think the crossing number is good , but you have to do the crossing thing yourself depending on your data type – tintin Sep 12 '13 at 08:51

2 Answers2

3

The winding/crossing tests will work with more than polygons. You just need the ability to intersect the contour with a particular line (and in the case of the winding number, to evaluate the tangent of the contour at that point). You also need to be a little careful about numerical accuracy, and remember that double roots count as 2 intersections.

For splines, while there are line/spline intersection methods, discretizing to a polygon (and remember that you only need the little bits of the polygon that pass through the line) is probably the simplest approach.

Sneftel
  • 40,271
  • 12
  • 71
  • 104
0

I'm not sure about the kind of data you are using, but if you can somehow draw an analogy to image processing... Ray Casting Algorithm can help you find the answer.

The point in polygon problem can be implemented in any kind of complex structure and usually works well. Check this link for a pseudo-code: Ray Casting.

However, this won't work if you do not have any well defined method for finding intersection in your complex contour.

You may try to break into sub-problems of finding intersections:

  1. The intersection point between a spline and a line
  2. Line Segment Circle Intersection
Community
  • 1
  • 1
metsburg
  • 2,021
  • 1
  • 20
  • 32