intersection_segment_polyline_xy

compas.geometry.intersection_segment_polyline_xy(segment, polyline, tol=1e-06)[source]

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

Parameters
  • segment (sequence of sequence of float) – XY(Z) coordinates of two points defining a line segment.

  • polyline (sequence of sequence of float) – XY(Z) coordinates of the points of the polyline.

  • tol (float, optional) – The tolerance for intersection verification. Default is 1e-6.

Returns

  • None – If there is no intersection point.

  • point (list of tuple) – XYZ coordinates of the first intersection point if one exists (Z = 0).

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