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? :D
Answer by HenryStrattonFW · Jan 21, 2017 at 04:23 PM
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.
Thats actually good advice. If you want to rewrite this into an answer id like to accept it :D
sure thing.
I'd normally like to provide a bit more of an example or some code to support the idea but I've not done anything like this one before and it's not a simple problem to write some quick test code for. Best of luck with your polygon cutting!
Your answer
Follow this Question
Related Questions
Circle-line Intersection Points 3 Answers
Intersection of a Plane and an object 0 Answers
"Tile" a 2D polygon 0 Answers
Vectors side determing by a line. Please help me out !!!! 0 Answers