skspatial.objects.LineSegment.intersect_line_segment

LineSegment.intersect_line_segment(other: skspatial.objects.line_segment.LineSegment) skspatial.objects.point.Point[source]

Intersect the line segment with another.

Parameters
otherLineSegment
Returns
Point

The intersection point of the two line segments.

Raises
ValueError

If the line segments do not intersect.

Examples

>>> from skspatial.objects import LineSegment
>>> segment_a = LineSegment([-1, 0], [1, 0])
>>> segment_b = LineSegment([0, -1], [0, 1])
>>> segment_a.intersect_line_segment(segment_b)
Point([0., 0.])
>>> segment_b = LineSegment([0, 1], [0, 2])
>>> segment_a.intersect_line_segment(segment_b)
Traceback (most recent call last):
...
ValueError: The line segments must intersect.