azrafe7 / hxGeomAlgo

Small collection of computational geometry algorithms in Haxe.
http://azrafe7.github.io/hxGeomAlgo/index.html
Other
159 stars 13 forks source link

ADDED self-intersecting polygon decomposition #5

Open pshtif opened 10 years ago

pshtif commented 10 years ago

Added a method decomposeSelfIntersecting which will decompose specified polygon into an array of simple polygons. Its just a first draft out of my mind with possible optimizations, I didn't use any source material.

azrafe7 commented 10 years ago

Thanks for taking a crack at this. It would be really nice to have this feature.

From testing your initial impl. I can see that the resulting decomposing polys can sometimes overlap, which could be unwanted (you can try it with a star-shaped self-intersecting poly).

pshtif commented 10 years ago

Yea I am well aware that results can overlap thats what I was after instead of substraction of such polys which is common behavior in some other poly renderers. Anyway this method has bugs and will not work when first/last segment intersect with something I already fixed that and will commit new.