intersection_segment_segment
- compas.geometry.intersection_segment_segment(ab, cd, tol=None)[source]
Compute the intersection of two lines segments.
- Parameters:
- ab[point, point] |
compas.geometry.Line
XYZ coordinates of two points defining a line segment.
- cd[point, point] |
compas.geometry.Line
XYZ coordinates of two points defining another line segment.
- tolfloat, optional
Tolerance value for computing the intersection points of the underlying lines, and for verifying that those points are contained by the segments. Default is
TOL.absolute
.
- ab[point, point] |
- Returns:
- tuple[[float, float, float], [float, float, float]] | tuple[None, None]
Two intersection points. If the segments intersect and the intersection points lie on the respective segments, the two points are identical. If the segments are skew and the apparent intersection points lie on the respective segments, the two points are different. In all other cases there are no intersection points.
Examples
The 2 intersection points of intersecting segments are identical.
>>> s1 = [0, 0, 0], [1, 0, 0] >>> s2 = [0, 0, 0], [0, 1, 0] >>> intersection_segment_segment(s1, s2) ([0.0, 0.0, 0.0], [0.0, 0.0, 0.0])
Unlike lines, segments don’t extend beyond their start and end points.
>>> s1 = [0, 0, 0], [1, 0, 0] >>> s2 = [2, 0, 0], [0, 1, 0] >>> intersection_segment_segment(s1, s2) (None, None)
Skew segments have two different intersection points.
>>> s1 = [0, 0, 0], [1, 0, 0] >>> s2 = [0, 0, 1], [0, 1, 1] >>> intersection_segment_segment(s1, s2) ([0.0, 0.0, 0.0], [0.0, 0.0, 1.0])
Parallel segments don’t intersect.
>>> s1 = [0, 0, 0], [1, 0, 0] >>> s2 = [0, 0, 0], [1, 0, 0] >>> intersection_segment_segment(s1, s2) (None, None)