Whether or not a line intersects a polygon depends (in this case) on the triangulation of the polygon.
Take a look at this example:
The green and the blue polygon consist of the same vertices, but are displayed at different places, and they are triangulated differently, because the vertices are given in a different order. The red line intersects the green polygon. But it does not intersect the blue polygon.
Therefore, the only real “intersection test” that one can do is to intersect a line or line segment with a single triangle. This is offered in IntersectionTests.lineSegmentTriangle
.
(As far as I know, there is no “public” way of obtaining the triangles that are actually rendered when rendering a polygon, though - related: Getting polygons' rendered triangles' - #2 by sam.rothstein )
A sandcastle that shows what’s also shown in the screenshot: