I created a 2D plane using matplotlib and have generated a user-entered amount of randomly placed triangles. Given two(2) random points, an origin, and an endpoint, how would I go about detecting if the line segment created would touch or intersect one of the shapes? In the photo provided, how could I assure the program detected the line intersected the triangle?
Asked
Active
Viewed 179 times
1
-
1Share some relevant code. – Zabir Al Nazi May 13 '20 at 00:17
1 Answers
1
Look into the geometric objects provided in the shapely library. You can create polygons objects from those triangles and a line string object with two points. The objects have methods which check for intersection.

Noah Smith
- 187
- 4