ConvexPolygonQ[poly]
gives True if the polygon poly is convex, and False otherwise.
ConvexPolygonQ
ConvexPolygonQ[poly]
gives True if the polygon poly is convex, and False otherwise.
Examples
open all close allBasic Examples (2)
Test whether a polygon is convex:
𝒫 = Polygon[{{0, 0}, {1, 0}, {0.5, 0.8}}]ConvexPolygonQ[𝒫]ConvexPolygonQ gives False for non-convex polygons:
𝒫 = Polygon[{{0, 0}, {1, 0}, {0.2, 1}, {0.9, 1}}]ConvexPolygonQ[𝒫]Scope (7)
ConvexPolygonQ works on polygons:
𝒫 = Polygon[{{0, 0}, {1, 0}, {0.5, 0.8}}]ConvexPolygonQ[𝒫]ConvexPolygonQ[Triangle[]]ConvexPolygonQ[Rectangle[]]𝒫 = Polygon[{{0, 0}, {3, 0}, {3, 3}, {0, 3}, {1, 1}, {1, 2}, {2, 2}, {2, 1}}, {1, 2, 3, 4} -> {{5, 6, 7, 8}}]ConvexPolygonQ[%]𝒫 = Polygon[{{0.35, 0.2}, {0.9, 0.75}, {0.1, 0.55}, {0.9, 0.35}, {0.42, 0.9}}]ConvexPolygonQ[%]Polygons with disconnected components:
𝒫 = Polygon[{{0, 0}, {1, 0}, {0, 1}, {1, 1}, {2, 1}, {1, 2}}, {{1, 2, 3}, {4, 5, 6}}]ConvexPolygonQ[%]Polygon[{{2, 3, 1, 0}, {6, 9, 1, 0}, {5, 4, 1, 0}, {8, 2, 1, 0}}];ConvexPolygonQ[%]ConvexPolygonQ works on polygons of geographic entities:
ℛ = Polygon[["france"]];ConvexPolygonQ[ℛ]Polygons with GeoPosition:
ℛ = Polygon[GeoPosition[{{{40.083441, -88.235716}, {40.083607, -88.257488}, {40.082603, -88.257149},
{40.076136999999996, -88.25740499999999}, {40.076178, -88.270888}, {40.076516, -88.271558},
{40.083686, -88.271512}, {40.083659999999995, -88.267046}, ... 33323}, {40.098112, -88.228687},
{40.095216, -88.228627}, {40.095179, -88.238547}, {40.094480999999995, -88.238546},
{40.094508999999995, -88.23267}, {40.094106, -88.232556}, {40.090666999999996, -88.232477},
{40.090741, -88.235745}}}]];ConvexPolygonQ[ℛ]Polygons with GeoPositionXYZ:
ℛ = Polygon[GeoPositionXYZ[{{{150451.6968462432, -4.884430486484052*^6, 4.085078564164219*^6},
{148595.27532671497, -4.884475441490381*^6, 4.085092666620835*^6},
{148626.35829777512, -4.884546311005128*^6, 4.0850073717259285*^6},
{148618.5908634042 ... 7*^6, 4.0860187668081024*^6},
{150697.56410771207, -4.8836599487428395*^6, 4.085984535480795*^6},
{150711.88303095422, -4.883905546449982*^6, 4.0856924143435075*^6},
{150433.15479548014, -4.883908845676418*^6, 4.0856987003255524*^6}}}]];ConvexPolygonQ[ℛ]Polygons with GeoPositionENU:
ℛ = Polygon[GeoPositionENU[{{{3378.2547059731055, -3369.2234780923936, -0.7440009205072329},
{1521.3211635380246, -3351.391253626573, -0.022340134218666208},
{1550.2571145363192, -3462.8657556618973, -0.08899812728964207},
{1528.5672303494055, -418 ... 63383291193, -0.37494203351275246},
{3654.121991908476, -2566.7472331234085, -0.5214977847472255},
{3375.420726854886, -2558.6597093173914, -0.3648706331350695}}},
GeoPosition[{40.11379115639895, -88.2753251202516, -1.0415787873318691}]]];ConvexPolygonQ[ℛ]ConvexPolygonQ works on polygons with GeoGridPosition:
ℛ = Polygon[GeoGridPosition[{{{-0.9950503945490105, 1.2366760550756015},
{-0.9952074890903578, 1.2369207053693891}, {-0.9952196732768064, 1.2369073327446167},
{-0.9953160063787643, 1.236848436956935}, {-0.9954141759436825, 1.2369993898475449},
{-0. ... 197645333103}, {-0.9949098578570917, 1.2368130881428654},
{-0.9948663952535768, 1.2367477711687371}, {-0.9948714472169538, 1.2367426500757825},
{-0.9949211061652593, 1.2367089232486177}, {-0.9949439717990124, 1.236746107097628}}}, "Bonne"]];ConvexPolygonQ[ℛ]Applications (4)
Generate random polygons for testing algorithms and verification of time complexity:
n = Table[Floor[10 ^ i], {i, 1, 4, 1 / 40}];polygons = Table[RandomPolygon[{"Convex", i}], {i, n}];AllTrue[polygons, ConvexPolygonQ]Time complexity for algorithms for convex polygons:
t = First[AbsoluteTiming[ConvexPolygonQ[#]]]& /@ polygons;Show[{ListPlot[Transpose[{n, t}], PlotRange -> All, Joined -> True, AxesLabel -> {"n", "Time"}], Plot[Style[Evaluate[Fit[Transpose[{n, t}], {1, x}, x]], Red, Dashed], {x, 0, 10 ^ 5}]}]Test whether a polygon is concave:
concavePolygonQ[poly_] := Not[ConvexPolygonQ[poly]]Table[RandomPolygon[RandomInteger[{3, 5}]], {4}]concavePolygonQ /@ %Attempt to test whether a geometric region is convex:
convexRegionQ[reg_] := ConvexPolygonQ[BoundaryDiscretizeRegion[reg]]convexRegionQ[Disk[]]convexRegionQ[ImplicitRegion[x ^ 2 + y ^ 3 < 1, {x, y}]]Polygon classification using machine learning. Train a classifier function on polygon examples:
trainingset = Table[(RandomPolygon[{#, RandomInteger[{3, 100}]}] -> #)&@RandomChoice[{"Simple", "Convex", "StarShaped"}], {20}];cfunc = Classify[Image[Graphics[#1]] -> #2&@@@trainingset]Use the classifier function to classify new polygons:
class = cfunc[Image[Graphics[#]]]&;𝒫 = DynamicModule[«3»];ConvexPolygonQ[𝒫]class[𝒫]𝒫 = DynamicModule[«3»];class[𝒫]𝒫 = DynamicModule[«3»];class[𝒫]Properties & Relations (6)
𝒫 = Polygon[{{0, 0}, {1, 0}, {0.5, 0.8}}]ConvexPolygonQ[𝒫]SimplePolygonQ[𝒫]The OuterPolygon of a convex polygon is convex:
𝒫 = Polygon[{{0, 0}, {1, 0}, {0.5, 0.8}}]ConvexPolygonQ[𝒫]ConvexPolygonQ[OuterPolygon[𝒫]]Convex polygons do not have inner polygons:
InnerPolygon[𝒫]A convex polygon has all interior vertex angles less than
:
𝒫 = Polygon[{{0, 0}, {1, 0}, {1, 1}, {0, 1}}]PolygonAngle[𝒫]Use PolygonDecomposition to decompose a polygon into convex polygons:
𝒫 = Polygon[{{0, 0}, {3, 0}, {3, 1}, {1, 1}, {1, 2}, {3, 2}, {3, 3}, {0, 3}}];PolygonDecomposition[𝒫, "Convex"]Graphics[{EdgeForm[Gray], %}]Use RandomPolygon to generate a convex polygon:
RandomPolygon["Convex"]ConvexPolygonQ[%]The convex polygon is the convex hull of its edges:
𝒫 = Polygon[{{0.04022499106147648, 0.5079213334078534}, {0.7075250895331173, 0.9391967832603023},
{0.6794481727691097, 0.6843684731778141}, {0.3593295805847072, 0.46785753446220335}},
{1, 4, 3, 2}];ConvexHullMesh[𝒫]Possible Issues (1)
For a nonconstant polygon, ConvexPolygonQ returns False:
𝒫 = Polygon[{{a, b}, {c, d}, {e, f}, {g, h}}];ConstantRegionQ[𝒫]ConvexPolygonQ[𝒫]Related Guides
-
▪
- Polygons
History
Text
Wolfram Research (2019), ConvexPolygonQ, Wolfram Language function, https://reference.wolfram.com/language/ref/ConvexPolygonQ.html.
CMS
Wolfram Language. 2019. "ConvexPolygonQ." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/ConvexPolygonQ.html.
APA
Wolfram Language. (2019). ConvexPolygonQ. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ConvexPolygonQ.html
BibTeX
@misc{reference.wolfram_2026_convexpolygonq, author="Wolfram Research", title="{ConvexPolygonQ}", year="2019", howpublished="\url{https://reference.wolfram.com/language/ref/ConvexPolygonQ.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_convexpolygonq, organization={Wolfram Research}, title={ConvexPolygonQ}, year={2019}, url={https://reference.wolfram.com/language/ref/ConvexPolygonQ.html}, note=[Accessed: 12-June-2026]}