Python – Sympy Polygon.is_convex() Method
Last Updated :
20 Jul, 2020
In Sympy, the function Polygon.is_convex() is used to check whether the given polygon is convex or not. A polygon is said to be convex if all its interior angles are less than 180 degrees and there are no intersections between the sides.
Syntax: Polygon.is_convex()
Returns:
True: True if this polygon is convex, False otherwise.
Example #1:
Python3
from sympy import Point, Polygon
p1, p2, p3, p4 = map (Point, [( 0 , 0 ), ( 1 , 0 ), ( 5 , 1 ), ( 0 , 1 )])
isConvex = Polygon(p1, p2, p3, p4)
print (isConvex.is_convex())
|
Output:
True
Example #2:
Python3
from sympy import Point, Polygon
p1, p2, p3, p4, p5 = map (Point, [( 0 , 0 ), ( 3 , 2 ), ( 4 , 5 ), ( 7 , 1 ), ( 6 , 3 )])
isConvex = Polygon(p1, p2, p3, p4, p5)
print (isConvex.is_convex())
|
Output:
False
Share your thoughts in the comments
Please Login to comment...