There's this rectangular polygon (all angles are 90* or 270*) which happpens to be convex as well and this rectangular polyline which intersects the polygon on two occasions. The polyline thus splits the polygon into two new rectangular polygons.

Is there an easy way to obtains these two polygons in Java? I guess it can be done by memorizing the polygons' vertices on each side of the polyline and then adding the polyline vertices to each set. I suppose it could also be done if I were to implement a polygon clipping algorithm which I read about earlier, but they seem to be rather complicated. Isn't there a simpler solution, for this particular situation?