straight-skeleton
straight-skeleton copied to clipboard
Find center Line?
Hi there,
is there an easy way to get the center line from the edges? so for example the red line here:
Any idea would be great! Thanks a lot
Good question. I think what you can do to achieve this is the following:
- Initialize a list of line segments.
- 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.
- Process the list: remove duplicates, merge edges into a graph, etc.
For a more complex polygon the result should look like this:
Let me know if you have any further questions.
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.