straight-skeleton icon indicating copy to clipboard operation
straight-skeleton copied to clipboard

Find center Line?

Open pcace opened this issue 2 years ago • 2 comments

Hi there,

is there an easy way to get the center line from the edges? so for example the red line here:

image

Any idea would be great! Thanks a lot

pcace avatar Oct 04 '23 15:10 pcace

Good question. I think what you can do to achieve this is the following:

  1. Initialize a list of line segments.
  2. For each polygon in the straight skeleton, iterate over its edges and add them to the list with the exception of these 3 edges: the edge that connectes the first node and the last node, and two edges adjacent to it. So an n-gon would contribute n - 3 edges to the list.
  3. Process the list: remove duplicates, merge edges into a graph, etc.

For a more complex polygon the result should look like this:

image

Let me know if you have any further questions.

StrandedKitty avatar Oct 06 '23 22:10 StrandedKitty

I'm probably really late to the party but I'm trying to do the same thing. I ended up doing something very similar but instead of excluding the edges from the polygons I only add the edges if both nodes have a z-value (the last value of the vertex) greater than zero and if their winding number is positive.

SimoneyBV avatar Oct 19 '24 17:10 SimoneyBV