Example #1
0
def is_point_on_polyline(point, polyline, tol=0.0):
    """Determine if a point is on a polyline.

    Parameters
    ----------
    point : sequence of float
        XYZ coordinates.
    polyline : sequence of sequence of float
        XYZ coordinates of the points of the polyline.
    tol : float, optional
        The tolerance.
        Default is ``0.0``.

    Returns
    -------
    bool
        ``True`` if the point is on the polyline.
        ``False`` otherwise.

    """
    for i in range(len(polyline) - 1):
        a = polyline[i]
        b = polyline[i + 1]
        c = closest_point_on_segment(point, (a, b))

        if distance_point_point(point, c) <= tol:
            return True

    return False
Example #2
0
 def get_distance(self, point):
     """
     single point distance function
     """
     if not isinstance(point, Point):
         point = Point(*point)
     p = closest_point_on_segment(point, self.segment)
     return point.distance_to_point(p) - self.radius