# intersection_line_line

compas.geometry.intersection_line_line(l1, l2, tol=1e-06)[source]

Computes the intersection of two lines.

Parameters
Returns

tuple[[float, float, float], [float, float, float]] | tuple[None, None] – Two intersection points. If the lines intersect, these two points are identical. If the lines are skewed and thus only have an apparent intersection, the two points are different. In all other cases there are no intersection points.

Examples

The 2 intersection points of intersecting lines are identical.

>>> l1 = [0, 0, 0], [1, 0, 0]
>>> l2 = [0, 0, 0], [0, 1, 0]
>>> intersection_line_line(l1, l2)
([0.0, 0.0, 0.0], [0.0, 0.0, 0.0])


Note that lines extend beyond their start and end points.

>>> l1 = [0, 0, 0], [1, 0, 0]
>>> l2 = [2, 0, 0], [0, 1, 0]
>>> intersection_line_line(l1, l2)
([2.0, 0.0, 0.0], [2.0, 0.0, 0.0])


Skew lines have two different intersection points.

>>> l1 = [0, 0, 0], [1, 0, 0]
>>> l2 = [0, 0, 1], [0, 1, 1]
>>> intersection_line_line(l1, l2)
([0.0, 0.0, 0.0], [0.0, 0.0, 1.0])


Parallel lines don’t intersect.

>>> l1 = [0, 0, 0], [1, 0, 0]
>>> l2 = [0, 0, 0], [1, 0, 0]
>>> intersection_line_line(l1, l2)
(None, None)