I am really looking just for the least amount of code needed to do this but it is still readable.
Here is the same polygon but the border is respectively split up into 10, 20, and 30 points along the perimeter:
The code I used to produce this is:
OrderVerticesClockwise[pts_List] := Module[
{pivot, sorted, remainingPoints},
(* Find the pivot: the lowest and leftmost point *)
pivot = First[SortBy[pts, {Last, First}]];
(* Remove the pivot from the list *)
remainingPoints = DeleteCases[pts, pivot];
(* Sort the remaining vertices based on the polar angle relative to the pivot *)
sorted = SortBy[remainingPoints, ArcTan[#[[1]] - pivot[[1]], #[[2]] - pivot[[2]]] &];
(* Return ordered vertices with the pivot at the beginning *)
Prepend[sorted, pivot]
]
Clear[EquidistantPoints];
EquidistantPoints[pts_List, n_Integer] := Module[
{
closedPts = Append[pts, First[pts]],
lengths, totalLength, interval, accumulatedLengths, currentPt, nextPt,
distRemaining, currentIndex, result = {}
},
lengths = EuclideanDistance @@@ Partition[closedPts, 2, 1];
totalLength = Total[lengths];
interval = totalLength/n;
accumulatedLengths = Accumulate[lengths];
Do[
distRemaining = i*interval;
currentIndex = 1;
While[distRemaining > accumulatedLengths[[currentIndex]],
currentIndex++;
];
distRemaining -= If[currentIndex > 1, accumulatedLengths[[currentIndex - 1]], 0];
currentPt = closedPts[[currentIndex]];
nextPt = closedPts[[currentIndex + 1]];
AppendTo[result, currentPt + (distRemaining/lengths[[currentIndex]]) * (nextPt - currentPt)];
, {i, 0, n - 1}
];
result
]
equiArcLengthPointQuantity=20;
poly = RandomPolygon[12];
vertices = PolygonCoordinates[poly];
orderedVertices = OrderVerticesClockwise[vertices];
equiArcDistances = Accumulate[Table[Perimeter[poly]/equiArcLengthPointQuantity, {i, 1, equiArcLengthPointQuantity}]];
equidistantPts = EquidistantPoints[orderedVertices, equiArcLengthPointQuantity];
Graphics[
{Polygon[orderedVertices], Red, PointSize[0.02], Point[equidistantPts]}
]
I would assume that there is a much simpler way of doing this, but I couldn't think of one. And I don't know what else to call these points. They aren't equally distanced points in Euclidean space, just along the perimeter by arc length.