intersection_segment_polyline
- compas.geometry.intersection_segment_polyline(segment, polyline, tol=1e-06)[source]
Calculate the intersection point of a segment and a polyline.
- Parameters
segment (sequence of sequence of float) – XYZ coordinates of two points defining a line segment.
polyline (sequence of sequence of float) – XYZ coordinates of the points of the polyline.
tol (float, optional) – The tolerance for intersection verification. Default is
1e-6
.
- Returns
point or None
Examples
>>> from compas.geometry import is_point_on_polyline >>> from compas.geometry import is_point_on_segment >>> from compas.geometry import distance_point_point >>> from compas.geometry import centroid_points >>> p = [(0.0, 0.0, 0.0), (1.0, 0.0, 0.5), (2.0, 0.5, 1.0)] >>> s = [(0.5, 0.0, 0.0), (0.5, 0.0, 2.0)] >>> x1, x2 = intersection_segment_polyline(s, p) >>> x = centroid_points([x1, x2])
>>> is_point_on_polyline(x, p) True
>>> is_point_on_segment(x, s) True
>>> distance_point_point((0.5, 0.0, 0.25), x) < 1e-6 True