We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexDiscussionExhibition › polygon detection from intersecting line segments
Page Index Toggle Pages: 1
polygon detection from intersecting line segments (Read 860 times)
polygon detection from intersecting line segments
Nov 7th, 2008, 5:43am
 
http://www.openprocessing.org/visuals/?visualID=598

I needed to get a set of adjoining, non-overlapping polygons from a set of intersecting line segments for another project that I'm working on.

I use dijkstra's algorithm as implemented by St33d's Pathfinder library (http://robotacid.com/PBeta/AILibrary/Pathfinder/index.html) to find the shortest distance from one intersection point to an adjacent intersection point that doesn't include the connecting segment.

There are some approximations and stupid hack-together decisions in the code so it doesn't always do well with small shapes, but it's fun to play with.  I've been making little "stained glass" pictures instead of actually implementing the code in the larger project for a good little while now.
Re: polygon detection from intersecting line segme
Reply #1 - Nov 7th, 2008, 1:39pm
 
not sure if this algorithm archive helps -  detailed information and c based code implementations which can easily be ported to processing.

Re: polygon detection from intersecting line segme
Reply #2 - Nov 7th, 2008, 2:55pm
 
That's a really nice link, thanks!

Hmm.  Does it make sense to think about the problem as decomposing a non-simple polygon into simple ones?

Anyway, I uploaded a slightly-improved version of the code.  Same link -- http://www.openprocessing.org/visuals/?visualID=598
Page Index Toggle Pages: 1