Made a Flash on Wonderfl the other day.
My friend studying for his PhD at Georgia Tech in architecture called me regarding a problem. He said,
“I need to program something to create a polygon from points. Right now, the points are not being drawn in the right order so lines are being overlapped. How do I have the program draw them in the right order?”
So I came up with a theory of how to do it. The idea is that you find the average point between the points, and from that point you find the arc tangent to each of the points and order the points based on their angle to the center. This idea would only work in 2D, but I’m sure there is a general way to do it for all dimensions.
Here is the code written in actionscript. You can click to add a point and ctrl+click to delete a point. I put it on wonderfl because I am thinking some people could fork some more interesting things from it.
2 thoughts on “Auto create polygon AS3”
Son of a gun, this is so hpeulfl!
I really like this. I think it is something i would like to try and see if i suit it before purchasing though. Might have to take a trip down to the shop and try it on first if possible.
Thanks for showing me this though wouldn\’t of thought of this if not.