(*args)
return Polygon(*convexHull)
The convex hull surrounding the Points contained in the list of entities.

    Parameters
    ==========

    args : a collection of Points, Segments and/or Polygons

    Returns
    =======

    convex_hull : Polygon

    Notes
    =====

    This can only be performed on a set of non-symbolic points.

    References
    ==========

    [1] http://en.wikipedia.org/wiki/Graham_scan

    [2] Andrew's Monotone Chain Algorithm
    (A.M. Andrew,
    "Another Efficient Algorithm for Convex Hulls in Two Dimensions", 1979)
    http://geomalgorithms.com/a10-_hull-1.html

    See Also
    ========

    sympy.geometry.point.Point, sympy.geometry.polygon.Polygon

    Examples
    ========

    >>> from sympy.geometry import Point, convex_hull
    >>> points = [(1,1), (1,2), (3,1), (-5,2), (15,4)]
    >>> convex_hull(*points)
    Polygon(Point(-5, 2), Point(1, 1), Point(3, 1), Point(15, 4))
The convex hull surrounding the Points contained in the list of entities.
The convex hull surrounding the Points contained in the list of entities .
def convex_hull(*args):
    """The convex hull surrounding the Points contained in the list of entities.

    Parameters
    ==========

    args : a collection of Points, Segments and/or Polygons

    Returns
    =======

    convex_hull : Polygon

    Notes
    =====

    This can only be performed on a set of non-symbolic points.

    References
    ==========

    [1] http://en.wikipedia.org/wiki/Graham_scan

    [2] Andrew's Monotone Chain Algorithm
    (A.M. Andrew,
    "Another Efficient Algorithm for Convex Hulls in Two Dimensions", 1979)
    http://geomalgorithms.com/a10-_hull-1.html

    See Also
    ========

    sympy.geometry.point.Point, sympy.geometry.polygon.Polygon

    Examples
    ========

    >>> from sympy.geometry import Point, convex_hull
    >>> points = [(1,1), (1,2), (3,1), (-5,2), (15,4)]
    >>> convex_hull(*points)
    Polygon(Point(-5, 2), Point(1, 1), Point(3, 1), Point(15, 4))

    """
    from .entity import GeometryEntity
    from .point import Point
    from .line import Segment
    from .polygon import Polygon

    p = set()
    for e in args:
        if not isinstance(e, GeometryEntity):
            try:
                e = Point(e)
            except NotImplementedError:
                raise ValueError('%s is not a GeometryEntity and cannot be made into Point' % str(e))
        if isinstance(e, Point):
            p.add(e)
        elif isinstance(e, Segment):
            p.update(e.points)
        elif isinstance(e, Polygon):
            p.update(e.vertices)
        else:
            raise NotImplementedError(
                'Convex hull for %s not implemented.' % type(e))

    p = list(p)
    if len(p) == 1:
        return p[0]
    elif len(p) == 2:
        return Segment(p[0], p[1])

    def _orientation(p, q, r):
        '''Return positive if p-q-r are clockwise, neg if ccw, zero if
        collinear.'''
        return (q.y - p.y)*(r.x - p.x) - (q.x - p.x)*(r.y - p.y)

    # scan to find upper and lower convex hulls of a set of 2d points.
    U = []
    L = []
    p.sort(key=lambda x: x.args)
    for p_i in p:
        while len(U) > 1 and _orientation(U[-2], U[-1], p_i) <= 0:
            U.pop()
        while len(L) > 1 and _orientation(L[-2], L[-1], p_i) >= 0:
            L.pop()
        U.append(p_i)
        L.append(p_i)
    U.reverse()
    convexHull = tuple(L + U[1:-1])

    if len(convexHull) == 2:
        return Segment(convexHull[0], convexHull[1])
    return Polygon(*convexHull)
def convex_hull ( * args ) : from . entity import GeometryEntity from . point import Point from . line import Segment from . polygon import Polygon p = set ( ) for e in args : if not isinstance ( e , GeometryEntity ) : try : e = Point ( e ) except NotImplementedError : raise ValueError ( '%s is not a GeometryEntity and cannot be made into Point' % str ( e ) ) if isinstance ( e , Point ) : p . add ( e ) elif isinstance ( e , Segment ) : p . update ( e . points ) elif isinstance ( e , Polygon ) : p . update ( e . vertices ) else : raise NotImplementedError ( 'Convex hull for %s not implemented.' % type ( e ) ) p = list ( p ) if len ( p ) == 1 : return p [ 0 ] elif len ( p ) == 2 : return Segment ( p [ 0 ] , p [ 1 ] ) def _orientation ( p , q , r ) : '''Return positive if p-q-r are clockwise, neg if ccw, zero if
        collinear.''' return ( q . y - p . y ) * ( r . x - p . x ) - ( q . x - p . x ) * ( r . y - p . y ) # scan to find upper and lower convex hulls of a set of 2d points. U = [ ] L = [ ] p . sort ( key = lambda x : x . args ) for p_i in p : while len ( U ) > 1 and _orientation ( U [ - 2 ] , U [ - 1 ] , p_i ) <= 0 : U . pop ( ) while len ( L ) > 1 and _orientation ( L [ - 2 ] , L [ - 1 ] , p_i ) >= 0 : L . pop ( ) U . append ( p_i ) L . append ( p_i ) U . reverse ( ) convexHull = tuple ( L + U [ 1 : - 1 ] ) if len ( convexHull ) == 2 : return Segment ( convexHull [ 0 ] , convexHull [ 1 ] ) return Polygon ( * convexHull )