intersection_segment_polyline_xy

compas.geometry.intersection_segment_polyline_xy(segment, polyline, tol=None)[source]

Calculate the intersection point of a segment and a polyline on the XY-plane.

Parameters:
segment[point, point] | compas.geometry.Line

A line segment defined by two points, with at least XY coordinates.

polylinesequence[point] | compas.geometry.Polyline

A polyline defined by a sequence of points, with at least XY coordinates.

tolfloat, optional

Tolerance for computing the intersection points between the segment and the polyline segments. Default is TOL.absolute.

Returns:
[float, float, 0.0] | None

XYZ coordinates of the first intersection point if one exists. None otherwise

Examples

>>> from compas.geometry import is_point_on_polyline_xy
>>> from compas.geometry import is_point_on_segment_xy
>>> from compas.geometry import distance_point_point
>>> p = [(0.0, 0.0, 0.0), (1.0, 0.0, 0.0), (2.0, 0.0, 0.0)]
>>> s = [(0.5, -0.5, 0.0), (0.5, 0.5, 0.0)]
>>> x = intersection_segment_polyline_xy(s, p)
>>> is_point_on_polyline_xy(x, p)
True
>>> is_point_on_segment_xy(x, s)
True
>>> distance_point_point((0.5, 0.0, 0.0), x) < 1e-6
True