kendzi / kendzi-math

Basic math classes and utils.
BSD 3-Clause "New" or "Revised" License
19 stars 7 forks source link

How can I construct an inset of a polygon with your Skeleton class? #1

Open gvlasov opened 10 years ago

gvlasov commented 10 years ago

I want to apologize since creating an issue is not the best way to ask a question, but I couldn't find any other way to contact you.

I'm trying to use straight skeleton to construct an inset polygon of the original polygon with depth as a parameter, just like in the first illustration of Aicholzer paper (the left one: http://www.jucs.org/ujs/jucs/Journal/Volume%201/Issue_1_12/a_novel_type_of/images/30e53752.gif).

Is it possible with your straight skeleton implementation? I only see how one can obtain faces after the skeleton is created.

By the way, neat API, much better than twak implementation's.

kendzi commented 10 years ago

Hello Don't hesitate to ask question creating issues ;)

Answering, in current implementation I don't support custom depth. But it could be easily done as part of face post processing. I need that too and I'm planing to add such functionality in few weeks.

gvlasov commented 10 years ago

I don't see a way to construct inset polygon(s) from faces. Could you describe in general how should that be done or provide a link, so I can implement it for myself? I thought that to construct inset polygon(s) from straight skeleton, one would need a list of trees of nodes coming from original polygon's vertices, that is, a mutlimap from original nodes to paths that derivative nodes trace while shrinking.

kendzi commented 10 years ago

Not all nodes are shrinking, sometimes split event come first. So you need track all edges of the face.

The idea is to for all faces, generate parallel line to the edge, move it for requested depth and cutoff the part of face which is after line. And repeat process for each face. My skeleton algorithm implementation store information about edge (red line) and connected face (yellow area), so you need to generate parallel line (red dot) and find intersection with face (green dot) this what you looking for is line segment between points A and B. Naturally for edges opposite to split event you will find two line segments for one edge ;)

skeleton