HomeLanguagesPython – Sympy Polygon.is_convex() Method

Python – Sympy Polygon.is_convex() Method

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




# import Point, Polygon
from sympy import Point, Polygon
  
# creating points using Point()
p1, p2, p3, p4 = map(Point, [(0, 0), (1, 0), (5, 1), (0, 1)])
  
# creating polygon using Polygon()
isConvex = Polygon(p1, p2, p3, p4)
  
# using is_convex()
print(isConvex.is_convex())


Output:

True

Example #2:

Python3




# import Point, Polygon
from sympy import Point, Polygon
  
# creating points using Point()
p1, p2, p3, p4, p5 = map(Point, [(0, 0), (3, 2), (4, 5), (7, 1), (6, 3)])
  
# creating polygon using Polygon()
isConvex = Polygon(p1, p2, p3, p4, p5)
  
# using is_convex()
print(isConvex.is_convex())


Output:

False
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32738 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
7124 POSTS0 COMMENTS
Nicole Veronica
12255 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12337 POSTS0 COMMENTS
Shaida Kate Naidoo
7235 POSTS0 COMMENTS
Ted Musemwa
7497 POSTS0 COMMENTS
Thapelo Manthata
7215 POSTS0 COMMENTS
Umr Jansen
7185 POSTS0 COMMENTS