ConvexPolygonQ

ConvexPolygonQ[poly]

gives True if the polygon poly is convex, and False otherwise.

Details

  • A polygon is convex if no line segment between two points in the polygon ever goes outside the polygon:
  • A convex polygon is visible from all points in the polygon.

Examples

open allclose all

Basic Examples  (2)

Test whether a polygon is convex:

ConvexPolygonQ gives False for non-convex polygons:

Scope  (7)

ConvexPolygonQ works on polygons:

Triangle:

Rectangle:

Polygon with holes:

Self-intersecting polygons:

Polygons with disconnected components:

Polygon in :

ConvexPolygonQ works on polygons of geographic entities:

Polygons with GeoPosition:

Polygons with GeoPositionXYZ:

Polygons with GeoPositionENU:

ConvexPolygonQ works on polygons with GeoGridPosition:

Applications  (4)

Generate random polygons for testing algorithms and verification of time complexity:

Time complexity for algorithms for convex polygons:

Test whether a polygon is concave:

Attempt to test whether a geometric region is convex:

Polygon classification using machine learning. Train a classifier function on polygon examples:

Use the classifier function to classify new polygons:

A simple polygon:

A starshaped polygon:

Properties & Relations  (6)

A convex polygon is simple:

The OuterPolygon of a convex polygon is convex:

Convex polygons do not have inner polygons:

A convex polygon has all interior vertex angles less than :

Use PolygonDecomposition to decompose a polygon into convex polygons:

Use RandomPolygon to generate a convex polygon:

The convex polygon is the convex hull of its edges:

Possible Issues  (1)

For a nonconstant polygon, ConvexPolygonQ returns False:

Introduced in 2019
 (12.0)