user21 says it isn't guaranteed that the vertices will be in counter-clockwise order, but I can't find a counter-example.
Using the method described here we can make a little function that tests a polygon for whether its vertices are CCW
ccwQ[list_List] :=
Positive@Total[Subtract @@@ (list RotateLeft[Reverse /@ list])]
ccwQ[poly_Polygon] := ccwQ@First@poly
ccwQ[mesh_MeshRegion] := And @@ (ccwQ /@ MeshPrimitives[mesh, 2])
ccwQ[mesh_BoundaryMeshRegion] :=
And @@ (ccwQ /@ MeshPrimitives[mesh, 2])
Check that it works,
ccwQ /@ {Polygon[{{0, 0}, {1, 0}, {0, 1}}],
Polygon[{{0, 0}, {0, 1}, {1, 0}}]}
(* {True, False} *)
And then apply it to 50 examples of random 800-point DelaunayMesh
regions, verifying that every single triangle is CCW:
In[119]:= Table[ccwQ@DelaunayMesh[RandomReal[1, {800, 2}]], {50}]
Out[119]= {True, True, True, True, True, True, True, True, True,
True, True, True, True, True, True, True, True, True, True, True,
True, True, True, True, True, True, True, True, True, True, True,
True, True, True, True, True, True, True, True, True, True, True,
True, True, True, True, True, True, True, True}
This seems to be general for the MeshRegion
objects. It works on VoronoiMesh
:
ccwQ@VoronoiMesh[RandomReal[1, {8000, 2}]]
(* True *)
as well as DiscretizeRegion
results:
DiscretizeRegion[
ImplicitRegion[x^3 - y^7 <= 1, {{x, -2, 2}, {y, -2, 2}}]]
ccwQ@%
ccwQ@DiscretizeRegion[Disk[]]
So I haven't looked at the underlying code to see if it is guaranteed to always be true, but it seems to always be true. Chime in if you can find a counter-example