intersection_line_line
- compas.geometry.intersection_line_line(l1, l2, tol=1e-06)[source]
Computes the intersection of two lines.
- Parameters
l1 (tuple, list) – XYZ coordinates of two points defining the first line.
l2 (tuple, list) – XYZ coordinates of two points defining the second line.
tol (float, optional) – A tolerance for membership verification. Default is
1e-6
.
- Returns
tuple – 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 the return is (None, None).
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)