skspatial.objects.Line.intersect_line

Line.intersect_line(other: Line, check_coplanar: bool = True, **kwargs) Point[source]

Intersect the line with another.

The lines must be coplanar and not parallel.

Parameters:
otherLine

Other line.

check_coplanarbool, optional

Check that the lines are coplanar (default True). If False, this method may not return an actual intersection point, but an approximate one.

kwargsdict, optional

Additional keywords passed to Vector.is_parallel().

Returns:
Point

The point at the intersection.

Raises:
ValueError

If the lines don’t have the same dimension. If the line dimension is greater than three. If the lines are parallel. If the lines are not coplanar.

References

http://mathworld.wolfram.com/Line-LineIntersection.html

Examples

>>> from skspatial.objects import Line
>>> line_a = Line([0, 0], [1, 0])
>>> line_b = Line([5, 5], [0, 1])
>>> line_a.intersect_line(line_b)
Point([5., 0.])
>>> line_a = Line([0, 0, 0], [1, 1, 1])
>>> line_b = Line([5, 5, 0], [0, 0, -8])
>>> line_a.intersect_line(line_b)
Point([5., 5., 5.])
>>> line_a = Line([0, 0, 0], [1, 0, 0])
>>> line_b = Line([0, 0], [1, 1])
>>> line_a.intersect_line(line_b)
Traceback (most recent call last):
...
ValueError: The lines must have the same dimension.
>>> line_a = Line(4 * [0], [1, 0, 0, 0])
>>> line_b = Line(4 * [0], [0, 0, 0, 1])
>>> line_a.intersect_line(line_b)
Traceback (most recent call last):
...
ValueError: The line dimension cannot be greater than 3.
>>> line_a = Line([0, 0], [0, 1])
>>> line_b = Line([0, 1], [0, 1])
>>> line_a = Line([0, 0], [1, 0])
>>> line_b = Line([0, 1], [2, 0])
>>> line_a.intersect_line(line_b)
Traceback (most recent call last):
...
ValueError: The lines must not be parallel.
>>> line_a = Line([1, 2, 3], [-4, 1, 1])
>>> line_b = Line([4, 5, 6], [3, 1, 5])
>>> line_a.intersect_line(line_b)
Traceback (most recent call last):
...
ValueError: The lines must be coplanar.