Recently I’ve been thinking about how to transform a complex polygon into a non-complex polygon. How is this done?
This is the sort of thing I want to do:

I’m going to end up with JavaScript when I’m done, but any form of a solution is fine (language, algorithm, or just plain English).
I would use the same heuristic that I would use when drawing the polygon by hand (which is probably not the most mathematically efficient way to caluclaute that polygon, but probably the easiest to understand/implement).
Here is an example implementation on jsfiddle. Note: it isn’t optimized.