#NEWLINE# def distance( self , o ) : #NEWLINE# #INDENT# '\n        Finds the shortest distance between a line segment and a point.\n\n        Raises\n        ======\n\n        NotImplementedError is raised if o is not a Point3D\n\n        Examples\n        ========\n\n        >>> from sympy import Point3D, Segment3D\n        >>> p1, p2 = Point3D(0, 0, 3), Point3D(1, 1, 4)\n        >>> s = Segment3D(p1, p2)\n        >>> s.distance(Point3D(10, 15, 12))\n        sqrt(341)\n        >>> s.distance((10, 15, 12))\n        sqrt(341)\n        ' #NEWLINE# if is_sequence ( o ) : #NEWLINE# #INDENT# o = Point3D ( o ) #NEWLINE# #UNINDENT# if isinstance ( o , Point3D ) : #NEWLINE# #INDENT# seg_vector = ( self . p2 - self . p1 ) #NEWLINE# pt_vector = ( o - self . p1 ) #NEWLINE# t = ( seg_vector . dot ( pt_vector ) / ( self . length ** 2 ) ) #NEWLINE# if ( t >= 1 ) : #NEWLINE# #INDENT# distance = Point3D . distance ( self . p2 , o ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( t <= 0 ) : #NEWLINE# #INDENT# distance = Point3D . distance ( self . p1 , o ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# distance = Point3D . distance ( ( self . p1 + Point3D ( ( t * seg_vector . x ) , ( t * seg_vector . y ) , ( t * seg_vector . y ) ) ) , o ) #NEWLINE# #UNINDENT# #UNINDENT# return distance #NEWLINE# #UNINDENT# raise NotImplementedError ( )