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?

Wait... If you are talking about rectangular polygon, there is no such a 270 degree??? If you traverse a rectangular polygon, you will never change your turn ever (all left-turns or all right-turns)! As a result, you will always get 90 degree. Also, 270 degree is NOT a convex but a concave! The reason is that you are looking at the angle from the outer (bigger) part of it. If you are talking about 2 right angles intersect each other to create a rectangle, that is different.

Or are you talking about 1 rectangular polygon with a line? I am not sure what you mean by 'rectangular polyline'??? If it is a right angle poly line, then the possibility of intersect the polygon can be many ways -- 1, 2, 3, 4, or infinite intersecting points. I am not sure what you mean???

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.