Python – Sympy Polygon.encloses_point() method
Last Updated :
01 Aug, 2020
In Sympy, the function Polygon.encloses_point() is used to check whether the given point is enclosed by polygon or not. It returns True if the given point lies inside of the polygon, otherwise False. Being on the border of the polygon is also considered False.
Syntax: Polygon.encloses_point(p)
Parameters:
p: Point
Returns:
True: if point lies inside polygon, otherwise False.
Example #1:
Python3
from sympy import Point, Polygon
p1, p2, p3 = map (Point, [( 0 , 0 ), ( 5 , 0 ), ( 5 , 5 )])
poly = Polygon(p1, p2, p3)
isEnclosed = poly.encloses_point(Point( 2 , 1 ))
print (isEnclosed)
|
Output:
True
Example #2:
Python3
from sympy import Point, Polygon
p1, p2, p3 = map (Point, [( 0 , 0 ), ( 4 , 0 ), ( 4 , 4 )])
poly = Polygon(p1, p2, p3)
isEnclosed = poly.encloses_point(Point( 2 , 2 ))
print (isEnclosed)
|
Output:
False
Share your thoughts in the comments
Please Login to comment...