Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find center Line? #5

Open
pcace opened this issue Oct 4, 2023 · 2 comments
Open

Find center Line? #5

pcace opened this issue Oct 4, 2023 · 2 comments

Comments

@pcace
Copy link

pcace commented Oct 4, 2023

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

@StrandedKitty
Copy link
Owner

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.

@SimoneyBV
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants