#NEWLINE# def projection( self , o ) : #NEWLINE# #INDENT# 'Project a point, line, ray, or segment onto this linear entity.\n\n        Parameters\n        ==========\n\n        other : Point or LinearEntity (Line, Ray, Segment)\n\n        Returns\n        =======\n\n        projection : Point or LinearEntity (Line, Ray, Segment)\n            The return type matches the type of the parameter ``other``.\n\n        Raises\n        ======\n\n        GeometryError\n            When method is unable to perform projection.\n\n        Notes\n        =====\n\n        A projection involves taking the two points that define\n        the linear entity and projecting those points onto a\n        Line and then reforming the linear entity using these\n        projections.\n        A point P is projected onto a line L by finding the point\n        on L that is closest to P. This point is the intersection\n        of L and the line perpendicular to L that passes through P.\n\n        See Also\n        ========\n\n        sympy.geometry.point.Point3D, perpendicular_line\n\n        Examples\n        ========\n\n        >>> from sympy import Point3D, Line3D, Segment3D, Rational\n        >>> p1, p2, p3 = Point3D(0, 0, 1), Point3D(1, 1, 2), Point3D(2, 0, 1)\n        >>> l1 = Line3D(p1, p2)\n        >>> l1.projection(p3)\n        Point3D(2/3, 2/3, 5/3)\n\n        >>> p4, p5 = Point3D(10, 0, 1), Point3D(12, 1, 3)\n        >>> s1 = Segment3D(p4, p5)\n        >>> l1.projection(s1)\n        [Segment3D(Point3D(10/3, 10/3, 13/3), Point3D(5, 5, 6))]\n\n        ' #NEWLINE# tline = Line3D ( self . p1 , _project . p2 ) #NEWLINE# def _project( p ) : #NEWLINE# #INDENT# 'Project a point onto the line representing self.' #NEWLINE# if ( p in tline ) : #NEWLINE# #INDENT# return p #NEWLINE# #UNINDENT# l1 = tline . perpendicular_line ( p ) #NEWLINE# return tline . intersection ( l1 ) [ 0 ] #NEWLINE# #UNINDENT# projected = None #NEWLINE# if isinstance ( o , Point3D ) : #NEWLINE# #INDENT# return _project ( o ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( o , LinearEntity3D ) : #NEWLINE# #INDENT# n_p1 = _project ( o . p1 ) #NEWLINE# n_p2 = _project ( o . p2 ) #NEWLINE# if ( n_p1 == n_p2 ) : #NEWLINE# #INDENT# projected = n_p1 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# projected = o . __class__ ( n_p1 , n_p2 ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( projected is None ) : #NEWLINE# #INDENT# n1 = self . __class__ . __name__ #NEWLINE# n2 = o . __class__ . __name__ #NEWLINE# raise GeometryError ( ( 'Do not know how to project %s onto %s' % ( n2 , n1 ) ) ) #NEWLINE# #UNINDENT# return self . intersection ( projected )