1

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?

enter image description here

sergio
  • 45
  • 5

1 Answers1

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