determine an order of points so they form a simple closed path
SimpleClosedPath( P )
SimpleClosedPath( P, a )
2-D array of point coordinates (in the same form as the array in PointOrientation for highest efficiency), or a listlist of point coordinates
(optional) the index of the point from which to start the curve. The point with minimal y-coordinate is used by default. The output is not guaranteed to be simple unless the anchor is on the convex hull.
The SimpleClosedPath command returns a list of indices of the points in P so that they form a non-self-intersecting polygon in counterclockwise orientation.
The algorithm starts with an anchor point a and sorts the remaining points by the angle of the segment they form with a. The angle is not computed explicitly, but rather PointOrientation is used to determine the order implicitly.
P ≔ 0.17,0.13,0.39,0.74,0.76,0.68,0.93,0.85,0.036,0.66,0.96,0.79,0.92,0.42,0.14,0.80,0.48,0.96,0.97,0.16,0.96,0.96,0.55,0.28,0.098,0.63,0.91,0.13,0.91,0.82
P is not a simple polygon in the order given
path ≔ SimpleClosedPath⁡P
The output of SimpleClosedPath is a simple polygon.
There are many possible orders; the convex hull gives some but not all of them.
ch ≔ ConvexHull⁡P
M ≔ plots:-display⁡Matrix⁡2,4,seq⁡plots:-polygonplot⁡seq⁡Pi,i∈SimpleClosedPath⁡P,c,'color'=c,'scaling'='constrained','title'=cat⁡anchor=,c,c∈ch,'PLOT⁡AXESSTYLE⁡NONE'
The ComputationalGeometry[SimpleClosedPath] command was introduced in Maple 2023.
For more information on Maple 2023 changes, see Updates in Maple 2023.
Download Help Document