ComputationalGeometry
SimpleClosedPath
determine an order of points so they form a simple closed path
Calling Sequence
Parameters
Description
Examples
Compatibility
SimpleClosedPath( P )
SimpleClosedPath( P, a )
P
-
2-D array of point coordinates (in the same form as the array in PointOrientation for highest efficiency), or a listlist of point coordinates
a
(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.
with⁡ComputationalGeometry:
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
plots:-polygonplot⁡P,style=line
path≔SimpleClosedPath⁡P
path≔1,14,10,7,12,6,3,15,4,11,9,2,8,13,5
The output of SimpleClosedPath is a simple polygon.
plots:-polygonplot⁡seq⁡Pi,iinpath,style=line
There are many possible orders; the convex hull gives some but not all of them.
ch≔ConvexHull⁡P
ch≔10,11,9,8,5,1,14
M≔plots:-display⁡Matrix⁡2,4,seq⁡plots:-polygonplot⁡seq⁡Pi,iinSimpleClosedPath⁡P,c,color=c,scaling=constrained,title=cat⁡anchor=,c,cinch,INTERFACE_PLOT⁡AXESSTYLE⁡NONE
The ComputationalGeometry[SimpleClosedPath] command was introduced in Maple 2023.
For more information on Maple 2023 changes, see Updates in Maple 2023.
See Also
PointOrientation
Download Help Document