Friday 15 January 2010

Polygon subdivision!

i am quite exited about this one. It looks rather dull for now maybe, but once it will be integrated into psykopaint it will do some crazy shit!!

It was quite tricky to obtain actually.
I wanted to subdivide polygons with a point and an angle. First i thought of voronoi and complex algorythm, but too complex for my little head.
So i went for the simplicity of oop and created a class Polygon in which i would have a method which will return 2 polygons with the point and angle.

- First get the 2 intersection points between the polygons segments and the line that extend the point and the angle.

- Then Compose 2 polygons whose segments are the ones of the parent polygon until it finds the intersection segment and then bypass the previous segments.

Not sure if it is clear, but here is the result:



CLICK inside the red rectangle several time.
It gets very pretty after a moment

No comments: