I'm trying to get the ordered coordinates of a convex hull using MeshCoordnates[ConvexHullMesh[data]], but the coordinates are uselessly out of order:
With[{d = RandomReal[{0, 1}, {20, 2}]},
ListPlot[
d,
AspectRatio -> 1,
Epilog -> Polygon[MeshCoordinates[ConvexHullMesh[d]]]
]
]
The older ComputationalGeometry`ConvexHull function works correctly:
Needs["ComputationalGeometry`"]
With[{d = RandomReal[{0, 1}, {20, 2}]},
ListPlot[
d,
AspectRatio -> 1,
Epilog -> {Opacity[0.2], Polygon[d[[ConvexHull[d]]]]}
]
]
Is there some way to get the ordered coordinates from ConvexHullMesh?
Edit: I need to manipulate the polygon; the goal is not to just display the graphics.








FindCurvePath. I wonder if the ComputationalGeometryPackage uses that internally, or if it has a more direct and efficient approach (assumingFindCurvePathis somewhat expensive?). – ZachB Apr 21 '16 at 23:15ComputationalGeometrypackage, but we should be able to see the code forConvexHullfunction. – kglr Apr 21 '16 at 23:19ConvexHullusingnb = NotebookOpen[ ToFileName[{$InstallationDirectory, "AddOns", "Packages", "ComputationalGeometry"}, "ComputationalGeometry.m"]]; NotebookFind[nb, "compute 2D convex hull using Graham's scan \ algorithm"]– kglr Apr 21 '16 at 23:26{. – kglr Apr 21 '16 at 23:56ConvexHullMeshdoes not have properties like "BoundaryVertices" at least in 13.2. So this answer needs an update. – matheorem Jul 09 '23 at 10:02