Detecting if line cuts Polygon

Hey there community!

So here is the deal:

I have a polygon and a line-segment. Both start- and endpoint of the line lie on an edge of the polygon.

My question is: How can I detect the difference between these two situatiuons:


In both cases th line is between two edges but only in one case does it actually “cut” the polygon.

How would you go about this? :smiley:

Not a full answer really so I’ll just comment it here. Not sure if there is any fancy way of detecting this with concave polygons that I’m just not aware of (quite possible). But a way that I could suggest is to remove the complication of the convex polygon and instead test against each of the concave triangles that make up that polygon (all polygons can be represented as triangles), that way you can just test the line against each triangle, if the line spans across any of the triangles, then at least part of the polygon is getting “chopped” by the line.