3
votes

I need to split a polygon with a line, similar to this: How can I split a Polygon by a Line?, but I don't actually care about the resulting polygons, I just want to know the area on each side of the line.

I know I can just do the split and calculate the area of each resulting part, but I was wondering if there is any more efficient algorithm if I just need the area.

For instance, in the image below, the yellow shape shows an original polygon and the line across it shows how I want to split it. Notice that the split line always goes between to vertices, but does not necessarily cross the entire polygon. (Note: the fact that the cut line seems to pass through a third vertex is just an accident: this may be the case but is not necessarily so).

The red and green shapes show the resulting splits, and all I'm interested in is the total area of the red polygons (or of the green, either way)

example polygon split

1
I do not think there is a more efficient method than splitting the polygon into pieces. The area really does depend on exactly where the splitting line crosses each edge, so you must compute all the intersection points. And that is tantamount to splitting.Joseph O'Rourke

1 Answers

-1
votes

If you can determine the intersection points of the split then you can calculate the area of the first one and subtract it from the total area to determine the area of the second one.