(self, p)
return hit_odd
Return True if p is enclosed by (is inside of) self.

        Notes
        =====

        Being on the border of self is considered False.

        Parameters
        ==========

        p : Point

        Returns
        =======

        encloses_point : True, False or None

        See Also
        ========

        sympy.geometry.point.Point, sympy.geometry.ellipse.Ellipse.encloses_point

        Examples
        ========

        >>> from sympy import Polygon, Point
        >>> from sympy.abc import t
        >>> p = Polygon((0, 0), (4, 0), (4, 4))
        >>> p.encloses_point(Point(2, 1))
        True
        >>> p.encloses_point(Point(2, 2))
        False
        >>> p.encloses_point(Point(5, 5))
        False

        References
        ==========

        [1] http://www.ariel.com.au/a/python-point-int-poly.html
Return True if p is enclosed by (is inside of) self.
Return True if p is enclosed by ( is inside of ) self .
def encloses_point(self, p):
        """
        Return True if p is enclosed by (is inside of) self.

        Notes
        =====

        Being on the border of self is considered False.

        Parameters
        ==========

        p : Point

        Returns
        =======

        encloses_point : True, False or None

        See Also
        ========

        sympy.geometry.point.Point, sympy.geometry.ellipse.Ellipse.encloses_point

        Examples
        ========

        >>> from sympy import Polygon, Point
        >>> from sympy.abc import t
        >>> p = Polygon((0, 0), (4, 0), (4, 4))
        >>> p.encloses_point(Point(2, 1))
        True
        >>> p.encloses_point(Point(2, 2))
        False
        >>> p.encloses_point(Point(5, 5))
        False

        References
        ==========

        [1] http://www.ariel.com.au/a/python-point-int-poly.html

        """
        p = Point(p)
        if p in self.vertices or any(p in s for s in self.sides):
            return False

        # move to p, checking that the result is numeric
        lit = []
        for v in self.vertices:
            lit.append(v - p)  # the difference is simplified
            if lit[-1].free_symbols:
                return None
        self = Polygon(*lit)

        # polygon closure is assumed in the following test but Polygon removes duplicate pts so
        # the last point has to be added so all sides are computed. Using Polygon.sides is
        # not good since Segments are unordered.
        args = self.args
        indices = range(-len(args), 1)

        if self.is_convex():
            orientation = None
            for i in indices:
                a = args[i]
                b = args[i + 1]
                test = ((-a.y)*(b.x - a.x) - (-a.x)*(b.y - a.y)).is_negative
                if orientation is None:
                    orientation = test
                elif test is not orientation:
                    return False
            return True

        hit_odd = False
        p1x, p1y = args[0].args
        for i in indices[1:]:
            p2x, p2y = args[i].args
            if 0 > min(p1y, p2y):
                if 0 <= max(p1y, p2y):
                    if 0 <= max(p1x, p2x):
                        if p1y != p2y:
                            xinters = (-p1y)*(p2x - p1x)/(p2y - p1y) + p1x
                        if p1x == p2x or 0 <= xinters:
                            hit_odd = not hit_odd
            p1x, p1y = p2x, p2y
        return hit_odd
def encloses_point ( self , p ) : p = Point ( p ) if p in self . vertices or any ( p in s for s in self . sides ) : return False # move to p, checking that the result is numeric lit = [ ] for v in self . vertices : lit . append ( v - p ) # the difference is simplified if lit [ - 1 ] . free_symbols : return None self = Polygon ( * lit ) # polygon closure is assumed in the following test but Polygon removes duplicate pts so # the last point has to be added so all sides are computed. Using Polygon.sides is # not good since Segments are unordered. args = self . args indices = range ( - len ( args ) , 1 ) if self . is_convex ( ) : orientation = None for i in indices : a = args [ i ] b = args [ i + 1 ] test = ( ( - a . y ) * ( b . x - a . x ) - ( - a . x ) * ( b . y - a . y ) ) . is_negative if orientation is None : orientation = test elif test is not orientation : return False return True hit_odd = False p1x , p1y = args [ 0 ] . args for i in indices [ 1 : ] : p2x , p2y = args [ i ] . args if 0 > min ( p1y , p2y ) : if 0 <= max ( p1y , p2y ) : if 0 <= max ( p1x , p2x ) : if p1y != p2y : xinters = ( - p1y ) * ( p2x - p1x ) / ( p2y - p1y ) + p1x if p1x == p2x or 0 <= xinters : hit_odd = not hit_odd p1x , p1y = p2x , p2y return hit_odd