The source-code for Haxe, PHP and JS as well as a Flash-AS3 demo can be found on my Git-Hub.
|input, divide, extract, result|
- traverse the polygon clockwise and find vertices with counterclockwise rotation
- split the graph from those vertices to any direction
- pick a vertex and traverse the adjusted graph clockwise to build your rectangles