I have a set of line segments and I want to find what polygons are formed by the intersection of those lines. For example, suppose I have the following two line sequences:
(-0.5, 0.5) to (0, -0.5) to (0, 1) to (1, 1) to (1, 0) to (-0.5, 0)
and
(0, 2) to (0.5, 0) to (1, 2)
How can I find the 4 polygon shapes as identified by the red arrows in the following diagram:

OK here's the solution I found. It requires using a 'noder' to find all the line intersections.