polygon_line_intersections¶
- glue.utils.geometry.polygon_line_intersections(px, py, xval=None, yval=None)[source]¶
Find all the segments of intersection between a polygon and an infinite horizontal/vertical line.
The polygon is assumed to be closed. Due to numerical precision, the behavior at the edges of polygons is not always predictable, i.e. a point on the edge of a polygon may be considered inside or outside the polygon.
- Parameters:
- px, py~numpy.ndarray
The vertices of the polygon
- xvalfloat, optional
The x coordinate of the line (for vertical lines). This should only be specified if yval is not specified.
- yvalfloat, optional
The y coordinate of the line (for horizontal lines). This should only be specified if xval is not specified.
- Returns:
- segmentslist
A list of segments given as tuples of coordinates along the line.