3

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

Community
  • 1
  • 1
brianmearns
  • 9,581
  • 10
  • 52
  • 79
  • 3
    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 Sep 04 '13 at 11:15

1 Answers1

-1

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.

Lajos Arpad
  • 64,414
  • 37
  • 100
  • 175
  • Determining the points of intersection is easy enough, but it's not any more clear to me how I can use this to find the area of either side. – brianmearns Sep 03 '13 at 17:45
  • You can calculate the area of a Polygon already if I am not mistaken. You can create another Polygon object and you can calculate its area and then using the result you can calculate the area of the other polygon by subtracting the area of the first polygon from the total area. This way you are initializing a single polygon and you will have the area of both polygons. – Lajos Arpad Sep 03 '13 at 18:05
  • Right, that's basically what I said in the question. The other question I linked to shows how to get the new polygons from the split, and calculating their area is easy. I'm looking for a way to calculate the area without having to determine the new polygons. – brianmearns Sep 03 '13 at 18:14
  • Nope, "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." You said you can calculate the area of each polygons. My answer tells you that you can calculate the area of a single polygon and then you know the area of the second polygon by subtracting the area of the first polygon from the total area. You are working half as much this way. – Lajos Arpad Sep 03 '13 at 20:31
  • Yup: "(or of the green, either way)" Kind of implies (or at least was meant to) that I understand the premise of subtracting the area of one part from the area of the whole in order to get the are of the other part. However, it does not address the most basic problem of how to find the area of one part. – brianmearns Sep 03 '13 at 23:38
  • If you can determine the intersection points of the line and the polygon, then you can determine which old points of the polygon are on a side of the line. Using this you can build your polygon and can calculate its area. – Lajos Arpad Sep 04 '13 at 04:10
  • Just to close the loop on this: the whole point of the question is that I _don't want to create any new polygons_. I know how to create the polygons, and I know how to calculate the area of a polygon. What I'm looking for is a way to calculate the partial areas _without_ creating the polygons. It may not be possible, but none of the comments in this answer actually address what I'm looking for. – brianmearns Jun 19 '14 at 11:48