1

In a Javascript-based environment, I am starting with points that define segments of a Hilbert curve, e.g., an order-7 curve, partitioned into 24 arbitrary segments defined over a 128 x 128 2D space:

Order-7, 24-segment Hilbert curve

For each segment, given sets of points (x, y) for that segment, I would like to find the edges of the concave polygon that bounds those points.

For example, for segment 1, I would like to define a set of points that outline its associated concave polygon, as shown in this sketch(*):

Order-7, 24-segment Hilbert curve - Segment 1 w/path outlined

And so on, for segments 2 through 24.

What are common algorithms for finding the edges of concave polygons defined by a set of points, some/most of which may be inside said polygon?

Javascript implementations are great. Pseudocode is fine, as well, which can be reimplemented in Javascript.

(*: By sketch, I mean just that. This is not an "implementation" but a sketch made in an illustration tool. Thanks for answering the question, as written!)

Alex Reynolds
  • 95,983
  • 54
  • 240
  • 345
  • Have you tried anything yet? If you don't have a specific problem with your implementation, you might get better answers at one of the computer-science-focused Stack Exchanges ([Computer Science](https://cs.stackexchange.com/), [Computational Science](https://scicomp.stackexchange.com/), [Theoretical Computer Science](https://cstheory.stackexchange.com/), etc...). Just be sure to check that your question is on topic there. – D M Apr 21 '22 at 19:44
  • 2
    Since one of your "shapes" is essentially a solid collection of adjacent points on an integer grid, the processing seems straight-forward. Find all the edge points (points that are open on any of their eight adjacencies), then sort that list of points such that those that are cardinally (four direction) adjacent are also adjacent in the list. – Ouroborus Apr 21 '22 at 19:44
  • 1
    Thanks, Ouroborus, this is an answer along the lines I am looking for. – Alex Reynolds Apr 21 '22 at 21:10

0 Answers0