I'm doing path planning, where a vehicle should follow a path through a cluttered environment. My algorithm is really forgiving, such that I only need a boolean answer for the following question: Is this line within a polygon (the polygon is an obstacle). Naturally any intersection of polygon and line is to be avoided. I did my research on the web, but I only find things like those (in tons): wrong cases, valid for points only, more points.
My algorithm generates paths by connecting two points, which in turn are checked to not be inside the polygon upon generation.
Checking pointwise is not precise enought, since I can't risk any collisions. Intersecting lines of the polygon and the line was my first guess, but since each (endless) line intersects another (except for parallel ones) I'd have to check the intersection point to be outside all other edges. This seems very slow to me and the questions is, is there a better way or is this a "good" solution? [Or how do I check finite length line segments against each other?]
After the good comments, it boils down to: I need a fast way to check line segment-segment intersections. (I'm aware of bounding boxes and I will do that first.)
I'm using C++, if that matters.