(self, o)
Finds the shortest distance between a line segment and a point.

        Raises
        ======

        NotImplementedError is raised if o is not a Point

        Examples
        ========

        >>> from sympy import Point, Segment
        >>> p1, p2 = Point(0, 1), Point(3, 4)
        >>> s = Segment(p1, p2)
        >>> s.distance(Point(10, 15))
        sqrt(170)
Finds the shortest distance between a line segment and a point.
Finds the shortest distance between a line segment and a point .
def distance(self, o):
        """
        Finds the shortest distance between a line segment and a point.

        Raises
        ======

        NotImplementedError is raised if o is not a Point

        Examples
        ========

        >>> from sympy import Point, Segment
        >>> p1, p2 = Point(0, 1), Point(3, 4)
        >>> s = Segment(p1, p2)
        >>> s.distance(Point(10, 15))
        sqrt(170)
        """
        if isinstance(o, Point):
            seg_vector = self.p2 - self.p1
            pt_vector = o - self.p1
            t = seg_vector.dot(pt_vector)/self.length**2
            if t >= 1:
                distance = Point.distance(self.p2, o)
            elif t <= 0:
                distance = Point.distance(self.p1, o)
            else:
                distance = Point.distance(
                    self.p1 + Point(t*seg_vector.x, t*seg_vector.y), o)
            return distance
        raise NotImplementedError()
def distance ( self , o ) : if isinstance ( o , Point ) : seg_vector = self . p2 - self . p1 pt_vector = o - self . p1 t = seg_vector . dot ( pt_vector ) / self . length ** 2 if t >= 1 : distance = Point . distance ( self . p2 , o ) elif t <= 0 : distance = Point . distance ( self . p1 , o ) else : distance = Point . distance ( self . p1 + Point ( t * seg_vector . x , t * seg_vector . y ) , o ) return distance raise NotImplementedError ( )